Set executable bit on build.sh, and update documentation.
[htmlpurifier-web.git] / releases / build.sh
blob2b0d72060c3b9077dad0d0b86c96dfdcf61ae808
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"
57 if [ "$FORMAT" = "zip" ]
58 then
59 git config core.autocrlf true
60 else
61 git config core.autocrlf false
63 git checkout "$REV"
64 rm -rf .git
65 cd ..
67 archive "$NAME"
69 SNAME="$NAME-lite"
70 mkdir "$SNAME"
71 cp -R "$NAME/library" "$SNAME"
72 copy_meta_files
73 archive "$SNAME"
74 rm -R "$SNAME"
76 SNAME="$NAME-standalone"
77 mkdir "$SNAME"
78 export PHP_IS_CLI=1
79 php "$NAME/maintenance/merge-library.php"
80 mv "$NAME/library/HTMLPurifier.standalone.php" "$SNAME"
81 mv "$NAME/library/standalone" "$SNAME"
82 rm -Rf "$NAME/tests/blanks/*"
83 archive "$SNAME"
84 rm -R "$SNAME"
86 rm -R "$NAME"