Change PHP alias to modern path.
[htmlpurifier-web.git] / releases / build.sh
blobc199265c9fa72be62e23d65005d8180507ab0cba
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/php5/bin/php'
12 PATH=$HOME/usr/bin:$PATH
14 FORMAT="$1"
15 VERSION="$2"
16 REPO="$3"
17 NAME="htmlpurifier-$VERSION"
19 copy_meta_files() {
20 cp "$NAME/LICENSE" "$SNAME"
21 cp "$NAME/NEWS" "$SNAME"
22 cp "$NAME/INSTALL" "$SNAME"
23 cp "$NAME/CREDITS" "$SNAME"
26 archive() {
27 if [ "$FORMAT" = "zip" ]
28 then
29 zip -q -r "$1.zip" "$1"
30 else
31 tar -cf - "$1" | gzip -c > "$1.tar.gz"
35 if [ "$FORMAT" = "" ]
36 then
37 echo "Format of tar or zip must be specified in first param"
38 exit
41 if [ "$VERSION" = "" ]
42 then
43 echo "Version must be specified in second param"
44 exit
47 if [ "$REPO" = "" ]
48 then
49 REPO="git://repo.or.cz/htmlpurifier.git"
52 if [ "$VERSION" = "trunk" ]
53 then
54 REV="master"
55 else
56 REV="v$VERSION"
59 git clone -n "$REPO" "$NAME"
60 cd "$NAME"
62 CRLF=`git config core.autocrlf`
63 if [ "$FORMAT" = "zip" ]
64 then
65 git config core.autocrlf true
66 else
67 git config core.autocrlf false
69 git checkout "$REV"
70 rm -rf .git
71 cd ..
73 archive "$NAME"
75 SNAME="$NAME-lite"
76 mkdir "$SNAME"
77 cp -R "$NAME/library" "$SNAME"
78 copy_meta_files
79 archive "$SNAME"
80 rm -R "$SNAME"
82 SNAME="$NAME-standalone"
83 mkdir "$SNAME"
84 export PHP_IS_CLI=1
85 php "$NAME/maintenance/merge-library.php"
86 mv "$NAME/library/HTMLPurifier.standalone.php" "$SNAME"
87 mv "$NAME/library/standalone" "$SNAME"
88 rm -Rf "$NAME/tests/blanks/*"
89 archive "$SNAME"
90 rm -R "$SNAME"
92 rm -R "$NAME"
94 git config core.autocrlf "$CRLF"