1#! /bin/bash -- 2# 3# mkdist.sh by pts@fazekas.hu at Wed Mar 6 09:09:01 CET 2002 4# added debian/changelog support at Fri Mar 5 19:37:45 CET 2004 5# added libevhdns Makefile.in support at Sun Apr 25 12:24:43 CEST 2010 6# based on mkdist.sh of autotrace 7# 8 9if test "$1" = --cd; then 10 MYDIR="${0%/*}" 11 test "$MYDIR" || MYDIR=. 12 cd "$MYDIR" 13fi 14 15# Get the release version number. 16if test -f debian/changelog; then 17 # PRODUCT_AND_VERSION=$PRODUCT-$VERSION 18 PRODUCT_AND_VERSION="`<debian/changelog perl -ne 'print"$1-$2"if/^(\S+) +[(]([-.\w]+?)(?:-\d+)?[)] +\w+;/;last'`" 19 if test "$PRODUCT_AND_VERSION"; then :; else 20 echo "$0: couldn't determine version from debian/changelog" >&2 21 exit 4 22 fi 23elif test -f Makefile.in && grep '^product-and-version:' <Makefile.in >/dev/null; then 24 PRODUCT_AND_VERSION="`make SHELL=/bin/bash -f Makefile.in product-and-version`" 25 if test "$?" != 0 || test -z "$PRODUCT_AND_VERSION"; then 26 echo "$0: couldn't determine version from Makefile.in" >&2 27 exit 7 28 fi 29else 30 echo "$0: missing: debian/changelog or RELEASE= in Makefile.in" >&2 31 exit 2 32fi 33 34if test "$1" = --getversion; then 35 echo "${PRODUCT_AND_VERSION##*-}" 36 exit 37fi 38 39echo "Creating distfile in $PWD" 40 41# Get the list of files. 42if test -f files; then 43 FILES="`cat files`" 44elif test -d CVS; then 45 FILES=$( IFS=' 46' 47 find -type d -name CVS | while read D; do 48 F="$D/Entries" 49 export E="${D%/CVS}/" 50 E="${E#./}" 51 perl -ne 'print"$ENV{E}$1\n"if m@^/([^/]+)/[1-9]@' <"$F" 52 done) 53else 54 echo "$0: missing: files or **/CVS/Entries" >&2 55 exit 3 56fi 57 58 59if test -e "$PRODUCT_AND_VERSION"; then 60 echo "$0: directory $PRODUCT_AND_VERSION already exists, remove it first" >&2 61 exit 5 62fi 63 64if test $# -gt 0; then 65 TGZ_NAME="$1.tar.gz"; shift 66else 67 TGZ_NAME="$PRODUCT_AND_VERSION.tar.gz" 68fi 69 70set -e # exit on error 71rm -f "../$TGZ_NAME" 72mkdir "$PRODUCT_AND_VERSION" 73(IFS=' 74'; exec tar -c -- $FILES "$@") | 75(cd "$PRODUCT_AND_VERSION" && exec tar -xv) 76# ^^^ tar(1) magically calls mkdir(2) etc. 77 78# vvv Dat: don't include sam2p-.../ in the filenames of the .tar.gz 79#(IFS=' 80#'; cd "$PRODUCT_AND_VERSION" && exec tar -czf "../../$TGZ_NAME" -- $FILES "$@") 81 82# vvv Dat: do include sam2p-.../ in the filenames of the .tar.gz 83(IFS=' 84'; export PRODUCT_AND_VERSION; exec tar -czf "../$TGZ_NAME" -- `echo "$FILES" | perl -pe '$_="$ENV{PRODUCT_AND_VERSION}/$_"'` "$@") 85 86rm -rf "$PRODUCT_AND_VERSION" 87set +e 88 89if test -s "../$TGZ_NAME"; then :; else 90 echo "$0: failed to create distfile: ../$TGZ_NAME" >&2 91 exit 6 92fi 93 94FULL_TGZ_NAME="`cd ..;echo "$PWD/$TGZ_NAME"`" 95echo "Created distfile: $FULL_TGZ_NAME" 96if type -p pts-xclip >/dev/null; then 97 echo -n "$FULL_TGZ_NAME" | pts-xclip -i 98 echo -n "$FULL_TGZ_NAME" | pts-xclip -i -selection clipboard 99 echo "Name of distfile added to the X11 primary + clipboard." 100fi 101 102# __EOF__ 103