1#!/bin/sh 2# 3# makesrcdist - make a source distribution of CUPS. 4# 5 6TMPDIR="${TMPDIR:=/tmp}" 7 8# Make sure we are running in the right directory... 9if test ! -f scripts/makesrcdist; then 10 echo "Run this script from the top-level CUPS source directory, e.g.:" 11 echo "" 12 echo " scripts/makesrcdist $*" 13 echo "" 14 exit 1 15fi 16 17# See if we have local changes (other than this script...) 18if (git status | grep -v makesrcdist | grep -v makerpm | grep -q modified:); then 19 echo Local changes remain: 20 git status | grep -v makesrcdist | grep modified: 21 exit 1 22fi 23 24# Prep for snapshot or version release... 25if test $# = 0; then 26 # Compute version for snapshot 27 rev=`git show --oneline | head -1 | awk '{print $1}'` 28 version="2.3git" 29 fileversion="2.3git-$rev" 30 fileurl="file://$TMPDIR/cups-${fileversion}-source.tar.gz" 31 SIGNFILES=no 32else 33 # Use version from command-line 34 rev="1" 35 version=$1 36 fileversion=$1 37 fileurl="https://github.com/apple/cups/releases/download/v$fileversion/cups-${fileversion}-source.tar.gz" 38 SIGNFILES=yes 39 40 echo Validating sources... 41 cupsversionpatch=`echo $version | awk -F. '{if (NF == 3) { print $3 } else { print "0" } }'` 42 cupsversion=`printf "2.03%02d" $cupsversionpatch` 43 44 temp=`grep AC_INIT configure.ac | awk '{print $2}' | sed -e '1,$s/^\[//' -e '1,$s/\],$//'` 45 if test "$temp" != $version; then 46 echo "Still need to update version to $version in configure.ac (saw $temp)" 47 exit 1 48 fi 49 50 temp=`grep CUPS_VERSION cups/cups.h | grep -v CUPS_VERSION_ | awk '{print $4}'` 51 if test "$temp" != $cupsversion; then 52 echo "Still need to update CUPS_VERSION to $cupsversion in cups/cups.h (saw $temp)" 53 exit 1 54 fi 55 56 temp=`grep CUPS_VERSION_PATCH cups/cups.h | awk '{print $4}'` 57 if test "$temp" != $cupsversionpatch; then 58 echo "Still need to update CUPS_VERSION_PATCH to $cupsversionpatch in cups/cups.h (saw $temp)" 59 exit 1 60 fi 61 62 temp=`head -1 README.md | awk '{print $5}'` 63 if test "$temp" != "v$version"; then 64 echo "Still need to update version to v$version in README.md (saw $temp)" 65 exit 1 66 fi 67 68 temp=`head -1 INSTALL.md | awk '{print $4}'` 69 if test "$temp" != "v$version"; then 70 echo "Still need to update version to v$version in INSTALL.md (saw $temp)" 71 exit 1 72 fi 73 74 temp=`head -6 CHANGES.md | grep "Changes in" | awk '{print $4}'` 75 if test "$temp" != "v$version"; then 76 echo "Still need to add Changes in v$version in CHANGES.md (saw $temp)" 77 exit 1 78 fi 79 80 echo Creating tag for release... 81 git tag -m "Tag $version" v$version 82 git push origin v$version 83fi 84 85fileurl=`echo $fileurl | sed -e '1,$s/\\//\\\\\\//g'` 86file="$HOME/cups-$fileversion-source.tar" 87 88echo Exporting $fileversion... 89rm -rf $TMPDIR/cups-$version 90mkdir $TMPDIR/cups-$version 91git archive --format tar HEAD | (cd $TMPDIR/cups-$version; tar xf -) 92 93echo Preparing files... 94cd $TMPDIR/cups-$version 95sed -e '1,$s/@CUPS_VERSION@/'$version'/' \ 96 -e '1,$s/^Source:.*/Source: '$fileurl'/' \ 97 <packaging/cups.spec.in \ 98 >packaging/cups.spec 99rm -rf .gitignore 100cd .. 101 102echo Archiving... 103tar cf $file cups-$version 104 105echo Compressing... 106if (which zopfli >/dev/null); then 107 zopfli $file 108 rm -f $file 109else 110 gzip -v9 $file 111fi 112 113if test $SIGNFILES = yes; then 114 echo Signing... 115 test -f $file.gz.sig && rm -f $file.gz.sig 116 gpg --detach-sign -u security@cups.org $file.gz 117fi 118 119echo Removing temporary files... 120rm -rf cups-$version 121 122echo "Done - files in $HOME." 123