blob: f3d0a64095b46ce4e7a55d359070443ebe771285 [file] [log] [blame]
Steve Kondikae271bc2015-11-15 02:50:53 +01001#!/bin/sh
2# $Id: make-tar.sh,v 1.15 2015/05/16 17:12:37 tom Exp $
3##############################################################################
4# Copyright (c) 2010-2013,2015 Free Software Foundation, Inc. #
5# #
6# Permission is hereby granted, free of charge, to any person obtaining a #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation #
9# the rights to use, copy, modify, merge, publish, distribute, distribute #
10# with modifications, sublicense, and/or sell copies of the Software, and to #
11# permit persons to whom the Software is furnished to do so, subject to the #
12# following conditions: #
13# #
14# The above copyright notice and this permission notice shall be included in #
15# all copies or substantial portions of the Software. #
16# #
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
20# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
23# DEALINGS IN THE SOFTWARE. #
24# #
25# Except as contained in this notice, the name(s) of the above copyright #
26# holders shall not be used in advertising or otherwise to promote the sale, #
27# use or other dealings in this Software without prior written #
28# authorization. #
29##############################################################################
30# Construct a tar-file containing only the Ada95 tree as well as its associated
31# documentation. The reason for doing that is to simplify distributing the
32# ada binding as a separate package.
33
34CDPATH=:
35export CDPATH
36
37TARGET=`pwd`
38
39: ${ROOTNAME:=ncurses-Ada95}
40: ${PKG_NAME:=AdaCurses}
41: ${DESTDIR:=$TARGET}
42: ${TMPDIR:=/tmp}
43
44grep_assign() {
45 grep_assign=`egrep "^$2\>" "$1" | sed -e "s/^$2[ ]*=[ ]*//" -e 's/"//g'`
46 eval $2=\"$grep_assign\"
47}
48
49grep_patchdate() {
50 grep_assign ../dist.mk NCURSES_MAJOR
51 grep_assign ../dist.mk NCURSES_MINOR
52 grep_assign ../dist.mk NCURSES_PATCH
53}
54
55# The rpm spec-file in the ncurses tree is a template. Fill in the version
56# information from dist.mk
57edit_specfile() {
58 sed \
59 -e "s/\\<MAJOR\\>/$NCURSES_MAJOR/g" \
60 -e "s/\\<MINOR\\>/$NCURSES_MINOR/g" \
61 -e "s/\\<YYYYMMDD\\>/$NCURSES_PATCH/g" $1 >$1.new
62 chmod u+w $1
63 mv $1.new $1
64}
65
66make_changelog() {
67 test -f $1 && chmod u+w $1
68 cat >$1 <<EOF
69`echo $PKG_NAME|tr '[A-Z]' '[a-z]'` ($NCURSES_MAJOR.$NCURSES_MINOR+$NCURSES_PATCH) unstable; urgency=low
70
71 * snapshot of ncurses subpackage for $PKG_NAME.
72
73 -- `head -n 1 $HOME/.signature` `date -R`
74EOF
75}
76
77# This can be run from either the subdirectory, or from the top-level
78# source directory. We will put the tar file in the original directory.
79test -d ./Ada95 && cd ./Ada95
80SOURCE=`cd ..;pwd`
81
82BUILD=$TMPDIR/make-tar$$
83trap "cd /; rm -rf $BUILD; exit 0" 0 1 2 5 15
84
85umask 077
86if ! ( mkdir $BUILD )
87then
88 echo "? cannot make build directory $BUILD"
89fi
90
91umask 022
92mkdir $BUILD/$ROOTNAME
93
94cp -p -r * $BUILD/$ROOTNAME/ || exit
95
96# Add the config.* utility scripts from the top-level directory.
97for i in . ..
98do
99 for j in config.guess config.sub install-sh tar-copy.sh
100 do
101 test -f $i/$j && cp -p $i/$j $BUILD/$ROOTNAME/
102 done
103done
104
105# Make rpm and dpkg scripts for test-builds
106grep_patchdate
107for spec in $BUILD/$ROOTNAME/package/*.spec
108do
109 edit_specfile $spec
110done
111for spec in $BUILD/$ROOTNAME/package/debian*
112do
113 make_changelog $spec/changelog
114done
115
116cp -p ../man/MKada_config.in $BUILD/$ROOTNAME/doc/
117if test -z "$NO_HTML_DOCS"
118then
119 # Add the ada documentation.
120 cd ../doc/html || exit
121
122 cp -p -r Ada* $BUILD/$ROOTNAME/doc/
123 cp -p -r ada $BUILD/$ROOTNAME/doc/
124fi
125
126cp -p $SOURCE/NEWS $BUILD/$ROOTNAME
127
128# cleanup empty directories (an artifact of ncurses source archives)
129
130touch $BUILD/$ROOTNAME/MANIFEST
131( cd $BUILD/$ROOTNAME && find . -type f -print |$SOURCE/misc/csort >MANIFEST )
132
133cd $BUILD || exit
134
135# Remove build-artifacts.
136find . -name RCS -exec rm -rf {} \;
137find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
138find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
139find $BUILD/$ROOTNAME -type d -exec rmdir {} \; 2>/dev/null
140
141# There is no need for this script in the tar file.
142rm -f $ROOTNAME/make-tar.sh
143
144# Remove build-artifacts.
145find . -name "*.gz" -exec rm -rf {} \;
146
147# Make the files writable...
148chmod -R u+w .
149
150tar cf - $ROOTNAME | gzip >$DESTDIR/$ROOTNAME.tar.gz
151cd $DESTDIR
152
153pwd
154ls -l $ROOTNAME.tar.gz
155
156# vi:ts=4 sw=4