]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/make-tar.sh
ncurses 6.2 - patch 20200906
[ncurses.git] / test / make-tar.sh
1 #!/bin/sh
2 # $Id: make-tar.sh,v 1.16 2020/02/02 23:34:34 tom Exp $
3 ##############################################################################
4 # Copyright 2019,2020 Thomas E. Dickey                                       #
5 # Copyright 2010-2015,2017 Free Software Foundation, Inc.                    #
6 #                                                                            #
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
35 CDPATH=:
36 export CDPATH
37
38 TARGET=`pwd`
39
40 : ${PKG_NAME:=ncurses-examples}
41 : ${ROOTNAME:=ncurses-test}
42 : ${DESTDIR:=$TARGET}
43 : ${TMPDIR:=/tmp}
44
45 grep_assign() {
46         grep_assign=`egrep "^$2\>" "$1" | sed -e "s/^$2[        ]*=[    ]*//" -e 's/"//g'`
47         eval $2=\"$grep_assign\"
48 }
49
50 grep_patchdate() {
51         grep_assign ../dist.mk NCURSES_MAJOR
52         grep_assign ../dist.mk NCURSES_MINOR
53         grep_assign ../dist.mk NCURSES_PATCH
54 }
55
56 # The rpm spec-file in the ncurses tree is a template.  Fill in the version
57 # information from dist.mk
58 edit_specfile() {
59         sed \
60                 -e "s/\\<MAJOR\\>/$NCURSES_MAJOR/g" \
61                 -e "s/\\<MINOR\\>/$NCURSES_MINOR/g" \
62                 -e "s/\\<YYYYMMDD\\>/$NCURSES_PATCH/g" $1 >$1.new
63         chmod u+w $1
64         mv $1.new $1
65 }
66
67 make_changelog() {
68         test -f $1 && chmod u+w $1
69         cat >$1 <<EOF
70 `echo $PKG_NAME|tr '[A-Z]' '[a-z]'` ($NCURSES_MAJOR.$NCURSES_MINOR+$NCURSES_PATCH) unstable; urgency=low
71
72   * snapshot of ncurses subpackage for $PKG_NAME.
73
74  -- `head -n 1 $HOME/.signature`  `date -R`
75 EOF
76 }
77
78 # This can be run from either the subdirectory, or from the top-level
79 # source directory.  We will put the tar file in the original directory.
80 test -d ./test && cd ./test
81 SOURCE=`cd ..;pwd`
82
83 BUILD=$TMPDIR/make-tar$$
84 trap "cd /; rm -rf $BUILD; exit 0" EXIT INT QUIT TERM HUP
85
86 umask 077
87 if ! ( mkdir $BUILD )
88 then
89         echo "? cannot make build directory $BUILD"
90 fi
91
92 umask 022
93 mkdir $BUILD/$ROOTNAME
94
95 cp -p -r * $BUILD/$ROOTNAME/ || exit
96
97 # Add the config.* utility scripts from the top-level directory.
98 for i in . ..
99 do
100         for j in config.guess config.sub install-sh tar-copy.sh
101         do
102                 test -f $i/$j && cp -p $i/$j $BUILD/$ROOTNAME/
103         done
104 done
105
106 # Make rpm and dpkg scripts for test-builds
107 grep_patchdate
108 for spec in $BUILD/$ROOTNAME/package/*.spec
109 do
110         edit_specfile $spec
111 done
112 for spec in $BUILD/$ROOTNAME/package/debian*
113 do
114         make_changelog $spec/changelog
115 done
116
117 cp -p $SOURCE/NEWS $BUILD/$ROOTNAME
118
119 # cleanup empty directories (an artifact of ncurses source archives)
120
121 touch $BUILD/$ROOTNAME/MANIFEST 
122 ( cd $BUILD/$ROOTNAME && find . -type f -print |$SOURCE/misc/csort >MANIFEST )
123
124 cd $BUILD || exit 
125
126 # Remove build-artifacts.
127 find . -name RCS -exec rm -rf {} \;
128 find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
129 find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
130 find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
131
132 # There is no need for this script in the tar file.
133 rm -f $ROOTNAME/make-tar.sh
134
135 # Remove build-artifacts.
136 find . -name "*.gz" -exec rm -rf {} \;
137
138 # Make the files writable...
139 chmod -R u+w .
140
141 tar cf - $ROOTNAME | gzip >$DESTDIR/$ROOTNAME.tar.gz
142 cd $DESTDIR
143
144 pwd
145 ls -l $ROOTNAME.tar.gz
146
147 # vi:ts=4 sw=4