Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 1 | #!/bin/sh |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | # $Id: make-tar.sh,v 1.23 2022/11/05 20:29:41 tom Exp $ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 3 | ############################################################################## |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 4 | # Copyright 2019-2021,2022 Thomas E. Dickey # |
| 5 | # Copyright 2010-2015,2017 Free Software Foundation, Inc. # |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 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 Ada95 tree as well as its associated |
| 32 | # documentation. The reason for doing that is to simplify distributing the |
| 33 | # ada binding as a separate package. |
| 34 | |
| 35 | CDPATH=: |
| 36 | export CDPATH |
| 37 | |
| 38 | TARGET=`pwd` |
| 39 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 40 | : "${ROOTNAME:=ncurses-Ada95}" |
| 41 | : "${PKG_NAME:=AdaCurses}" |
| 42 | : "${DESTDIR:=$TARGET}" |
| 43 | : "${TMPDIR:=/tmp}" |
| 44 | |
| 45 | # make timestamps of generated files predictable |
| 46 | same_timestamp() { |
| 47 | touch -r ../NEWS "$1" |
| 48 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 49 | |
| 50 | grep_assign() { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 51 | grep_assign=`grep -E "^$2\>" "$1" | sed -e "s/^$2[ ]*=[ ]*//" -e 's/"//g'` |
| 52 | eval "$2"=\""$grep_assign"\" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | grep_patchdate() { |
| 56 | grep_assign ../dist.mk NCURSES_MAJOR |
| 57 | grep_assign ../dist.mk NCURSES_MINOR |
| 58 | grep_assign ../dist.mk NCURSES_PATCH |
| 59 | } |
| 60 | |
| 61 | # The rpm spec-file in the ncurses tree is a template. Fill in the version |
| 62 | # information from dist.mk |
| 63 | edit_specfile() { |
| 64 | sed \ |
| 65 | -e "s/\\<MAJOR\\>/$NCURSES_MAJOR/g" \ |
| 66 | -e "s/\\<MINOR\\>/$NCURSES_MINOR/g" \ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 67 | -e "s/\\<YYYYMMDD\\>/$NCURSES_PATCH/g" "$1" >"$1.new" |
| 68 | chmod u+w "$1" |
| 69 | mv "$1.new" "$1" |
| 70 | same_timestamp "$1" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | make_changelog() { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 74 | [ -f "$1" ] && chmod u+w "$1" |
| 75 | cat >"$1" <<EOF |
| 76 | `echo $PKG_NAME|tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` ($NCURSES_MAJOR.$NCURSES_MINOR+$NCURSES_PATCH) unstable; urgency=low |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 77 | |
| 78 | * snapshot of ncurses subpackage for $PKG_NAME. |
| 79 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 80 | -- `head -n 1 "$HOME"/.signature` `date -R` |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 81 | EOF |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 82 | same_timestamp "$1" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | # This can be run from either the subdirectory, or from the top-level |
| 86 | # source directory. We will put the tar file in the original directory. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 87 | if [ -d ./Ada95 ] |
| 88 | then |
| 89 | cd ./Ada95 || exit |
| 90 | fi |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 91 | SOURCE=`cd ..;pwd` |
| 92 | |
| 93 | BUILD=$TMPDIR/make-tar$$ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 94 | trap "cd /; rm -rf $BUILD; exit 1" 1 2 3 15 |
| 95 | trap "cd /; rm -rf $BUILD" 0 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 96 | |
| 97 | umask 077 |
| 98 | if ! ( mkdir $BUILD ) |
| 99 | then |
| 100 | echo "? cannot make build directory $BUILD" |
| 101 | fi |
| 102 | |
| 103 | umask 022 |
| 104 | mkdir $BUILD/$ROOTNAME |
| 105 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 106 | cp -p -r ./* $BUILD/$ROOTNAME/ || exit |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 107 | |
| 108 | # Add the config.* utility scripts from the top-level directory. |
| 109 | for i in . .. |
| 110 | do |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 111 | for j in COPYING config.guess config.sub install-sh tar-copy.sh |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 112 | do |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 113 | [ -f $i/$j ] && cp -p $i/$j $BUILD/$ROOTNAME/ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 114 | done |
| 115 | done |
| 116 | |
| 117 | # Make rpm and dpkg scripts for test-builds |
| 118 | grep_patchdate |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 119 | for spec in "$BUILD/$ROOTNAME"/package/*.spec |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 120 | do |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 121 | edit_specfile "$spec" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 122 | done |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | for spec in "$BUILD/$ROOTNAME"/package/debian* |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 124 | do |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 125 | make_changelog "$spec"/changelog |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 126 | done |
| 127 | |
| 128 | cp -p ../man/MKada_config.in $BUILD/$ROOTNAME/doc/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 129 | if [ -z "$NO_HTML_DOCS" ] |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 130 | then |
| 131 | # Add the ada documentation. |
| 132 | cd ../doc/html || exit |
| 133 | |
| 134 | cp -p -r Ada* $BUILD/$ROOTNAME/doc/ |
| 135 | cp -p -r ada $BUILD/$ROOTNAME/doc/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 136 | |
| 137 | cd ../../Ada95 || exit |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 138 | fi |
| 139 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 140 | cp -p "$SOURCE/NEWS" $BUILD/$ROOTNAME |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 141 | |
| 142 | # cleanup empty directories (an artifact of ncurses source archives) |
| 143 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 144 | touch $BUILD/$ROOTNAME/MANIFEST |
| 145 | ( cd $BUILD/$ROOTNAME && find . -type f -print | "$SOURCE/misc/csort" >MANIFEST ) |
| 146 | same_timestamp $BUILD/$ROOTNAME/MANIFEST |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 147 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 148 | cd $BUILD || exit |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 149 | |
| 150 | # Remove build-artifacts. |
| 151 | find . -name RCS -exec rm -rf {} \; |
| 152 | find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null |
| 153 | find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null |
| 154 | find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null |
| 155 | |
| 156 | # There is no need for this script in the tar file. |
| 157 | rm -f $ROOTNAME/make-tar.sh |
| 158 | |
| 159 | # Remove build-artifacts. |
| 160 | find . -name "*.gz" -exec rm -rf {} \; |
| 161 | |
| 162 | # Make the files writable... |
| 163 | chmod -R u+w . |
| 164 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 165 | # Cleanup timestamps |
| 166 | [ -n "$TOUCH_DIRS" ] && "$TOUCH_DIRS" "$ROOTNAME" |
| 167 | |
| 168 | tar cf - $TAR_OPTIONS $ROOTNAME | gzip >"$DESTDIR/$ROOTNAME.tar.gz" |
| 169 | cd "$DESTDIR" || exit |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 170 | |
| 171 | pwd |
| 172 | ls -l $ROOTNAME.tar.gz |
| 173 | |
| 174 | # vi:ts=4 sw=4 |