Fix bug, where variable names cannot have underscores.
[htmlpurifier-web.git] / releases / build.sh
blob68c4eb0433a1e23164249a84e5da67754c1c04a3
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 FORMAT="$1"
11 VERSION="$2"
12 REPO="$3"
13 NAME="htmlpurifier-$VERSION"
15 copy_meta_files() {
16 cp "$NAME/LICENSE" "$SNAME"
17 cp "$NAME/NEWS" "$SNAME"
18 cp "$NAME/INSTALL" "$SNAME"
19 cp "$NAME/CREDITS" "$SNAME"
22 archive() {
23 if [ "$FORMAT" = "zip" ]
24 then
25 zip -r "$1.zip" "$1"
26 else
27 tar -cvf - "$1" | gzip -c > "$1.tar.gz"
31 if [ "$FORMAT" = "" ]
32 then
33 echo "Format of tar or zip must be specified in first param"
34 exit
37 if [ "$VERSION" = "" ]
38 then
39 echo "Version must be specified in second param"
40 exit
43 if [ "$REPO" = "" ]
44 then
45 REPO="git://repo.or.cz/htmlpurifier.git"
48 if [ "$VERSION" = "trunk" ]
49 then
50 REV="master"
51 else
52 REV="v$VERSION"
55 git clone -n "$REPO" "$NAME"
56 cd "$NAME"
58 CRLF=`git config core.autocrlf`
59 if [ "$FORMAT" = "zip" ]
60 then
61 git config core.autocrlf true
62 else
63 git config core.autocrlf false
65 git checkout "$REV"
66 rm -rf .git
67 cd ..
69 archive "$NAME"
71 SNAME="$NAME-lite"
72 mkdir "$SNAME"
73 cp -R "$NAME/library" "$SNAME"
74 copy_meta_files
75 archive "$SNAME"
76 rm -R "$SNAME"
78 SNAME="$NAME-standalone"
79 mkdir "$SNAME"
80 export PHP_IS_CLI=1
81 php "$NAME/maintenance/merge-library.php"
82 mv "$NAME/library/HTMLPurifier.standalone.php" "$SNAME"
83 mv "$NAME/library/standalone" "$SNAME"
84 rm -Rf "$NAME/tests/blanks/*"
85 archive "$SNAME"
86 rm -R "$SNAME"
88 rm -R "$NAME"
90 git config core.autocrlf "$CRLF"