Fix build script with appropriate alias.
[htmlpurifier-web.git] / releases / build.sh
blobd8a92359d8a83a2a26d7ba59ce9f3d38b3b30462
1 #!/bin/bash
3 # Build script for HTML Purifier distributions. Syntax:
5 # ./build.sh (tar|zip) 1.2.3 git://repo.or.cz/htmlpurifier.git
7 # Tar will actually produce tar.gz, and the repository third parameter can
8 # be replaced with any valid repository path that contains the necessary tags.
10 shopt -s expand_aliases
11 alias php='/usr/local/dh/cgi-system/php5.cgi'
13 FORMAT="$1"
14 VERSION="$2"
15 REPO="$3"
16 NAME="htmlpurifier-$VERSION"
18 copy_meta_files() {
19 cp "$NAME/LICENSE" "$SNAME"
20 cp "$NAME/NEWS" "$SNAME"
21 cp "$NAME/INSTALL" "$SNAME"
22 cp "$NAME/CREDITS" "$SNAME"
25 archive() {
26 if [ "$FORMAT" = "zip" ]
27 then
28 zip -r "$1.zip" "$1"
29 else
30 tar -cvf - "$1" | gzip -c > "$1.tar.gz"
34 if [ "$FORMAT" = "" ]
35 then
36 echo "Format of tar or zip must be specified in first param"
37 exit
40 if [ "$VERSION" = "" ]
41 then
42 echo "Version must be specified in second param"
43 exit
46 if [ "$REPO" = "" ]
47 then
48 REPO="git://repo.or.cz/htmlpurifier.git"
51 if [ "$VERSION" = "trunk" ]
52 then
53 REV="master"
54 else
55 REV="v$VERSION"
58 git clone -n "$REPO" "$NAME"
59 cd "$NAME"
61 CRLF=`git config core.autocrlf`
62 if [ "$FORMAT" = "zip" ]
63 then
64 git config core.autocrlf true
65 else
66 git config core.autocrlf false
68 git checkout "$REV"
69 rm -rf .git
70 cd ..
72 archive "$NAME"
74 SNAME="$NAME-lite"
75 mkdir "$SNAME"
76 cp -R "$NAME/library" "$SNAME"
77 copy_meta_files
78 archive "$SNAME"
79 rm -R "$SNAME"
81 SNAME="$NAME-standalone"
82 mkdir "$SNAME"
83 export PHP_IS_CLI=1
84 php "$NAME/maintenance/merge-library.php"
85 mv "$NAME/library/HTMLPurifier.standalone.php" "$SNAME"
86 mv "$NAME/library/standalone" "$SNAME"
87 rm -Rf "$NAME/tests/blanks/*"
88 archive "$SNAME"
89 rm -R "$SNAME"
91 rm -R "$NAME"
93 git config core.autocrlf "$CRLF"