Merge remote-tracking branch 'origin/master' into for-steve
[sxemacs] / contrib / make-pkg.sh
1 #!/bin/sh
2 #
3 # (C) 2008 Nelson Ferreira
4 #
5 # This program is free software; you can redistribute it and/or modify it
6 # under a BSD-like licence.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 # Redistributions of source code must retain the above copyright notice, this
11 # list of conditions and the following disclaimer.
12 # Redistributions in binary form must reproduce the above copyright notice,
13 # this list of conditions and the following disclaimer in the documentation
14 # and/or other materials provided with the distribution.
15 # Neither the name of the Technical University of Berlin nor the names of its
16 # contributors may be used to endorse or promote products derived from this
17 # software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30 #
31 echo "Complain bitterly to njsf@sxemacs.org that he has still NOT updated this script to use git"
32 exit 1
33 if [ ! -n "$1" ]; then
34     echo "Usage: $0 <package-name> [<package-location>]"
35     echo "Example: $0 sxemacs-22.1.9"
36     exit 1
37 fi
38 type tla >/dev/null 2>&1 && TLA=tla
39 if [ -z "${TLA}" ]; then
40     echo "Cannot find tla."
41     exit 1
42 fi
43 BASE=$(basename $1)
44 BASE=$(echo ${BASE} | sed -e 's/\.tgz$//g' -e 's/\.tar\.gz$//g' -e 's/\.tar$//g')
45 if [ ! -f ./autogen.sh -o ! -f ./sxemacs.pc.in ]; then
46     echo "Please run this script from the top of the sxemacs source directory.\n"
47     exit 1;
48 fi
49 STATUS=""
50 if [ -z "MAKEPKGYES" ]; then
51     echo "The next step will erase ALL files not under source control from the source tree"
52     echo -n "Continue [Y/N]"
53     read YN
54 else
55     YN="y"
56 fi
57 YN=$(echo ${YN} | tr [:upper:] [:lower:])
58 if [ "$YN" != "y" -a "$YN" != "yes" ]; then
59     echo "Stopping."
60     exit 1;
61 fi
62 ${TLA} export "/tmp/${1}" || STATUS="FAIL_EXPORT"
63 if [ -n "$STATUS" ]; then
64     echo "Either your tla does not support export or it failed to create the destination"
65     exit 1
66 fi
67 HAMMER=BHFH ./autogen.sh || STATUS="FAIL_AUTOGEN"
68 if [ -n "$STATUS" ]; then
69     echo "The autogen process failed"
70     exit 1
71 fi
72 for f in $(${TLA} inventory -p -B); do
73     cp -r -v --parents "${f}" "/tmp/${1}"
74 done
75 ${TLA} changelog --untagged > "/tmp/${1}/ChangeLog" || STATUS="FAIL_CHANGELOG"
76 if [ -n "$STATUS" ]; then
77     echo "The changelog generation failed. Continuing..."
78     STATUS=""
79 fi
80 CURDIR="$(pwd)"
81 if [ -n "$2"  ]; then
82     cd "$2"
83 else
84     echo "Using ${CURDIR} as package destination"
85 fi
86 DEST="$(pwd)/${BASE}.tar.gz"
87 cd /tmp
88 tar --create --owner=0 --group=0 --gzip --file "${DEST}" "${BASE}"
89 md5sum "${DEST}" > "${DEST}.md5"
90 /bin/rm -rf "${BASE}"
91 cd "$CURDIR"
92 echo "Done"