Initial git import
[sxemacs] / contrib / make-pkg.sh
1 #!/bin/sh
2 #
3 if [ ! -n "$1" ]; then
4     echo "Usage: $0 <package-name> [<package-location>]"
5     echo "Example: $0 sxemacs-22.1.9"
6     exit 1
7 fi
8 type tla >/dev/null 2>&1 && TLA=tla
9 if [ -z "${TLA}" ]; then
10     echo "Cannot find tla."
11     exit 1
12 fi
13 BASE=$(basename $1)
14 BASE=$(echo ${BASE} | sed -e 's/\.tgz$//g' -e 's/\.tar\.gz$//g' -e 's/\.tar$//g')
15 if [ ! -f ./autogen.sh -o ! -f ./sxemacs.pc.in ]; then
16     echo "Please run this script from the top of the sxemacs source directory.\n"
17     exit 1;
18 fi
19 STATUS=""
20 if [ -z "MAKEPKGYES" ]; then
21     echo "The next step will erase ALL files not under source control from the source tree"
22     echo -n "Continue [Y/N]"
23     read YN
24 else
25     YN="y"
26 fi
27 YN=$(echo ${YN} | tr [:upper:] [:lower:])
28 if [ "$YN" != "y" -a "$YN" != "yes" ]; then
29     echo "Stopping."
30     exit 1;
31 fi
32 ${TLA} export "/tmp/${1}" || STATUS="FAIL_EXPORT"
33 if [ -n "$STATUS" ]; then
34     echo "Either your tla does not support export or it failed to create the destination"
35     exit 1
36 fi
37 HAMMER=BHFH ./autogen.sh || STATUS="FAIL_AUTOGEN"
38 if [ -n "$STATUS" ]; then
39     echo "The autogen process failed"
40     exit 1
41 fi
42 for f in $(${TLA} inventory -p -B); do
43     cp -r -v --parents "${f}" "/tmp/${1}"
44 done
45 ${TLA} changelog --untagged > "/tmp/${1}/ChangeLog" || STATUS="FAIL_CHANGELOG"
46 if [ -n "$STATUS" ]; then
47     echo "The changelog generation failed. Continuing..."
48     STATUS=""
49 fi
50 CURDIR="$(pwd)"
51 if [ -n "$2"  ]; then
52     cd "$2"
53 else
54     echo "Using ${CURDIR} as package destination"
55 fi
56 DEST="$(pwd)/${BASE}.tar.gz"
57 cd /tmp
58 tar --create --owner=0 --group=0 --gzip --file "${DEST}" "${BASE}"
59 md5sum "${DEST}" > "${DEST}.md5"
60 /bin/rm -rf "${BASE}"
61 cd "$CURDIR"
62 echo "Done"
63