summaryrefslogtreecommitdiff
path: root/tools/makesrcdist
blob: ed7c05f56e0a8694f493d07723609b080e7c10de (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
106
107
108
109
110
111
112
113
114
#!/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 -v testrpm | 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.3git"
	fileversion="2.3git-$rev"
	fileurl="file://$TMPDIR/cups-${fileversion}-source.tar.gz"
	SIGNFILES=no
else
	# Use version from command-line
	rev="1"
	version=$1
	fileversion=$1
	fileurl="https://github.com/apple/cups/releases/download/v$fileversion/cups-${fileversion}-source.tar.gz"
	SIGNFILES=yes

	echo Validating sources...
	cupsversionpatch=`echo $version | awk -F. '{if (NF == 3) { print $3 } else { print "0" } }'`
	cupsversion=`printf "2.03%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.md | awk '{print $4}'`
	if test "$temp" != "v$version"; then
		echo "Still need to update version to v$version in README.md (saw $temp)"
		exit 1
	fi

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

	temp=`head -6 CHANGES.md | grep "Changes in" | awk '{print $4}'`
	if test "$temp" != "v$version"; then
		echo "Still need to add Changes in v$version in CHANGES.md (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'`
file="cups-$fileversion-source.tar.gz"

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 $file cups-$version

if test $SIGNFILES = yes; then
	echo Signing...
	test -f $file.sig && rm -f $file.sig
	gpg --detach-sign -u security@cups.org $file
fi

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

echo "Done - files in $TMPDIR."