blob: df4b66aadab6ca18e2b931e7e9638574c2773282 [file] [log] [blame]
Steve Kondikae271bc2015-11-15 02:50:53 +01001#!/bin/sh
micky3879b9f5e72025-07-08 18:04:53 -04002# $Id: make-tar.sh,v 1.21 2022/11/05 19:41:33 tom Exp $
Steve Kondikae271bc2015-11-15 02:50:53 +01003##############################################################################
micky3879b9f5e72025-07-08 18:04:53 -04004# Copyright 2019-2021,2022 Thomas E. Dickey #
5# Copyright 2010-2015,2017 Free Software Foundation, Inc. #
Steve Kondikae271bc2015-11-15 02:50:53 +01006# #
7# Permission is hereby granted, free of charge, to any person obtaining a #
8# copy of this software and associated documentation files (the "Software"), #
9# to deal in the Software without restriction, including without limitation #
10# the rights to use, copy, modify, merge, publish, distribute, distribute #
11# with modifications, sublicense, and/or sell copies of the Software, and to #
12# permit persons to whom the Software is furnished to do so, subject to the #
13# following conditions: #
14# #
15# The above copyright notice and this permission notice shall be included in #
16# all copies or substantial portions of the Software. #
17# #
18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
21# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
23# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
24# DEALINGS IN THE SOFTWARE. #
25# #
26# Except as contained in this notice, the name(s) of the above copyright #
27# holders shall not be used in advertising or otherwise to promote the sale, #
28# use or other dealings in this Software without prior written #
29# authorization. #
30##############################################################################
31# Construct a tar-file containing only the test tree as well as its associated
32# scripts. The reason for doing that is to simplify distributing the test
33# programs as a separate package.
34
35CDPATH=:
36export CDPATH
37
38TARGET=`pwd`
39
micky3879b9f5e72025-07-08 18:04:53 -040040: "${PKG_NAME:=ncurses-examples}"
41: "${ROOTNAME:=ncurses-test}"
42: "${DESTDIR:=$TARGET}"
43: "${TMPDIR:=/tmp}"
44
45# make timestamps of generated files predictable
46same_timestamp() {
47 [ -f ../NEWS ] || echo "OOPS $1"
48 touch -r ../NEWS "$1"
49}
Steve Kondikae271bc2015-11-15 02:50:53 +010050
51grep_assign() {
micky3879b9f5e72025-07-08 18:04:53 -040052 grep_assign=`grep -E "^$2\>" "$1" | sed -e "s/^$2[ ]*=[ ]*//" -e 's/"//g'`
53 eval "$2"=\""$grep_assign"\"
Steve Kondikae271bc2015-11-15 02:50:53 +010054}
55
56grep_patchdate() {
57 grep_assign ../dist.mk NCURSES_MAJOR
58 grep_assign ../dist.mk NCURSES_MINOR
59 grep_assign ../dist.mk NCURSES_PATCH
60}
61
62# The rpm spec-file in the ncurses tree is a template. Fill in the version
63# information from dist.mk
64edit_specfile() {
65 sed \
66 -e "s/\\<MAJOR\\>/$NCURSES_MAJOR/g" \
67 -e "s/\\<MINOR\\>/$NCURSES_MINOR/g" \
micky3879b9f5e72025-07-08 18:04:53 -040068 -e "s/\\<YYYYMMDD\\>/$NCURSES_PATCH/g" "$1" >"$1.new"
69 chmod u+w "$1"
70 mv "$1.new" "$1"
71 same_timestamp "$1"
Steve Kondikae271bc2015-11-15 02:50:53 +010072}
73
74make_changelog() {
micky3879b9f5e72025-07-08 18:04:53 -040075 [ -f "$1" ] && chmod u+w "$1"
76 cat >"$1" <<EOF
77`echo $PKG_NAME|tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` ($NCURSES_MAJOR.$NCURSES_MINOR+$NCURSES_PATCH) unstable; urgency=low
Steve Kondikae271bc2015-11-15 02:50:53 +010078
79 * snapshot of ncurses subpackage for $PKG_NAME.
80
micky3879b9f5e72025-07-08 18:04:53 -040081 -- `head -n 1 "$HOME"/.signature` `date -R`
Steve Kondikae271bc2015-11-15 02:50:53 +010082EOF
micky3879b9f5e72025-07-08 18:04:53 -040083 same_timestamp "$1"
Steve Kondikae271bc2015-11-15 02:50:53 +010084}
85
86# This can be run from either the subdirectory, or from the top-level
87# source directory. We will put the tar file in the original directory.
micky3879b9f5e72025-07-08 18:04:53 -040088if [ -d ./test ]
89then
90 cd ./test || exit
91fi
Steve Kondikae271bc2015-11-15 02:50:53 +010092SOURCE=`cd ..;pwd`
93
94BUILD=$TMPDIR/make-tar$$
micky3879b9f5e72025-07-08 18:04:53 -040095trap "cd /; rm -rf $BUILD; exit 1" 1 2 3 15
96trap "cd /; rm -rf $BUILD; exit 0" 0
Steve Kondikae271bc2015-11-15 02:50:53 +010097
98umask 077
99if ! ( mkdir $BUILD )
100then
101 echo "? cannot make build directory $BUILD"
102fi
103
104umask 022
105mkdir $BUILD/$ROOTNAME
106
micky3879b9f5e72025-07-08 18:04:53 -0400107cp -p -r ./* $BUILD/$ROOTNAME/ || exit
Steve Kondikae271bc2015-11-15 02:50:53 +0100108
109# Add the config.* utility scripts from the top-level directory.
110for i in . ..
111do
micky3879b9f5e72025-07-08 18:04:53 -0400112 for j in COPYING config.guess config.sub install-sh tar-copy.sh
Steve Kondikae271bc2015-11-15 02:50:53 +0100113 do
micky3879b9f5e72025-07-08 18:04:53 -0400114 [ -f $i/$j ] && cp -p $i/$j $BUILD/$ROOTNAME/
Steve Kondikae271bc2015-11-15 02:50:53 +0100115 done
116done
117
118# Make rpm and dpkg scripts for test-builds
119grep_patchdate
micky3879b9f5e72025-07-08 18:04:53 -0400120for spec in "$BUILD/$ROOTNAME"/package/*.spec
Steve Kondikae271bc2015-11-15 02:50:53 +0100121do
micky3879b9f5e72025-07-08 18:04:53 -0400122 edit_specfile "$spec"
Steve Kondikae271bc2015-11-15 02:50:53 +0100123done
micky3879b9f5e72025-07-08 18:04:53 -0400124for spec in "$BUILD/$ROOTNAME"/package/debian*
Steve Kondikae271bc2015-11-15 02:50:53 +0100125do
micky3879b9f5e72025-07-08 18:04:53 -0400126 make_changelog "$spec"/changelog
Steve Kondikae271bc2015-11-15 02:50:53 +0100127done
128
micky3879b9f5e72025-07-08 18:04:53 -0400129cp -p "$SOURCE/NEWS" "$BUILD/$ROOTNAME"
Steve Kondikae271bc2015-11-15 02:50:53 +0100130
131# cleanup empty directories (an artifact of ncurses source archives)
132
micky3879b9f5e72025-07-08 18:04:53 -0400133touch $BUILD/$ROOTNAME/MANIFEST
134( cd $BUILD/$ROOTNAME && find . -type f -print | "$SOURCE/misc/csort" >MANIFEST )
135same_timestamp $BUILD/$ROOTNAME/MANIFEST
Steve Kondikae271bc2015-11-15 02:50:53 +0100136
micky3879b9f5e72025-07-08 18:04:53 -0400137cd $BUILD || exit
Steve Kondikae271bc2015-11-15 02:50:53 +0100138
139# Remove build-artifacts.
140find . -name RCS -exec rm -rf {} \;
141find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
142find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
143find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
144
145# There is no need for this script in the tar file.
146rm -f $ROOTNAME/make-tar.sh
147
148# Remove build-artifacts.
149find . -name "*.gz" -exec rm -rf {} \;
150
151# Make the files writable...
152chmod -R u+w .
153
micky3879b9f5e72025-07-08 18:04:53 -0400154# Cleanup timestamps
155[ -n "$TOUCH_DIRS" ] && "$TOUCH_DIRS" "$ROOTNAME"
156
157tar cf - $TAR_OPTIONS $ROOTNAME | gzip >"$DESTDIR/$ROOTNAME.tar.gz"
158cd "$DESTDIR" || exit
Steve Kondikae271bc2015-11-15 02:50:53 +0100159
160pwd
161ls -l $ROOTNAME.tar.gz
162
163# vi:ts=4 sw=4