summaryrefslogtreecommitdiff
path: root/tools/makesrcdist
blob: 5b2a74c990227eccfe8749af94d9f7e0094f08ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#
# makesrcdist - make a source distribution of CUPS.
#

TMPDIR="${TMPDIR:=/tmp}"

# Make sure we are running in the right directory...
if test ! -f tools/makesrcdist; then
        echo "Run this script from the top-level CUPS source directory, e.g.:"
        echo ""
        echo "    tools/makesrcdist $*"
        echo ""
        exit 1
fi

# See if we have local changes (other than this script...)
if (git status | grep -v makesrcdist | grep -q modified:); then
        echo Local changes remain:
        git status | grep -v makesrcdist | grep modified:
        exit 1
fi

# Prep for snapshot or version release...
if test $# = 0; then
	# Compute version for snapshot
	rev=`git show --oneline | head -1 | awk '{print $1}'`
	version="2.2git"
	fileversion="2.2git-$rev"
	fileurl="file://$TMPDIR/cups-$fileversion.tar.gz"
else
	# Use version from command-line
	rev="1"
	version=$1
	fileversion=$1
	fileurl="https://github.com/apple/cups/releases/download/release-$fileversion/cups-$fileversion-source.tar.gz"

	echo Validating sources...
	cupsversionpatch=`echo $version | awk -F. '{if (NF == 3) { print $3 } else { print "0" } }'`
	cupsversion=`printf "2.02%02d" $cupsversionpatch`

        temp=`grep AC_INIT configure.ac | awk '{print $2}' | sed -e '1,$s/^\[//' -e '1,$s/\],$//'`
        if test "$temp" != $version; then
		echo "Still need to update version to $version in configure.ac (saw $temp)"
		exit 1
	fi

	temp=`grep CUPS_VERSION cups/cups.h | grep -v CUPS_VERSION_ | awk '{print $4}'`
	if test "$temp" != $cupsversion; then
		echo "Still need to update CUPS_VERSION to $cupsversion in cups/cups.h (saw $temp)"
		exit 1
	fi

	temp=`grep CUPS_VERSION_PATCH cups/cups.h | awk '{print $4}'`
	if test "$temp" != $cupsversionpatch; then
		echo "Still need to update CUPS_VERSION_PATCH to $cupsversionpatch in cups/cups.h (saw $temp)"
		exit 1
	fi

	temp=`head -1 README.txt | awk '{print $4}'`
	if test "$temp" != "v$version"; then
		echo "Still need to update version to v$version in README.txt (saw $temp)"
		exit 1
	fi

	temp=`head -1 INSTALL.txt | awk '{print $4}'`
	if test "$temp" != "v$version"; then
		echo "Still need to update version to v$version in INSTALL.txt (saw $temp)"
		exit 1
	fi

	temp=`head -4 CHANGES.txt | grep "CHANGES IN" | awk '{print $4}'`
	if test "$temp" != "V$version"; then
		echo "Still need to add CHANGES IN V$version in CHANGES.txt (saw $temp)"
		exit 1
	fi

	echo Creating tag for release...
	git tag -m "Tag $version" v$version
	git push origin v$version
fi

fileurl=`echo $fileurl | sed -e '1,$s/\\//\\\\\\//g'`

echo Exporting $fileversion...
rm -rf $TMPDIR/cups-$version
mkdir $TMPDIR/cups-$version
git archive --format tar HEAD | (cd $TMPDIR/cups-$version; tar xf -)

echo Preparing files...
cd $TMPDIR/cups-$version
sed -e '1,$s/@CUPS_VERSION@/'$version'/' \
	-e '1,$s/^Source:.*/Source: '$fileurl'/' \
	<packaging/cups.spec.in \
	>packaging/cups.spec
rm -rf tools .gitignore
cd ..

echo Archiving...
tar czf cups-$fileversion-source.tar.gz cups-$version

echo Removing temporary files...
#rm -rf cups-$version

echo "Done - files in $TMPDIR."