More monkeying around with bash scripts.
[htmlpurifier-web.git] / releases / build.sh
blob2585accbf94cfbc17a7d4ba47b191036e6c3a144
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 source $HOME/.bashrc
12 FORMAT="$1"
13 VERSION="$2"
14 REPO="$3"
15 NAME="htmlpurifier-$VERSION"
17 copy_meta_files() {
18 cp "$NAME/LICENSE" "$SNAME"
19 cp "$NAME/NEWS" "$SNAME"
20 cp "$NAME/INSTALL" "$SNAME"
21 cp "$NAME/CREDITS" "$SNAME"
24 archive() {
25 if [ "$FORMAT" = "zip" ]
26 then
27 zip -q -r "$1.zip" "$1"
28 else
29 tar -cf - "$1" | gzip -c > "$1.tar.gz"
33 if [ "$FORMAT" = "" ]
34 then
35 echo "Format of tar or zip must be specified in first param"
36 exit
39 if [ "$VERSION" = "" ]
40 then
41 echo "Version must be specified in second param"
42 exit
45 if [ "$REPO" = "" ]
46 then
47 REPO="git://repo.or.cz/htmlpurifier.git"
50 if [ "$VERSION" = "trunk" ]
51 then
52 REV="master"
53 else
54 REV="v$VERSION"
57 git clone -n "$REPO" "$NAME"
58 cd "$NAME"
60 CRLF=`git config core.autocrlf`
61 if [ "$FORMAT" = "zip" ]
62 then
63 git config core.autocrlf true
64 else
65 git config core.autocrlf false
67 git checkout "$REV"
68 rm -rf .git
69 cd ..
71 archive "$NAME"
73 SNAME="$NAME-lite"
74 mkdir "$SNAME"
75 cp -R "$NAME/library" "$SNAME"
76 copy_meta_files
77 archive "$SNAME"
78 rm -R "$SNAME"
80 SNAME="$NAME-standalone"
81 mkdir "$SNAME"
82 export PHP_IS_CLI=1
83 php "$NAME/maintenance/generate-standalone.php"
84 mv "$NAME/library/HTMLPurifier.standalone.php" "$SNAME"
85 mv "$NAME/library/standalone" "$SNAME"
86 rm -Rf "$NAME/tests/blanks/*"
87 archive "$SNAME"
88 rm -R "$SNAME"
90 rm -R "$NAME"
92 git config core.autocrlf "$CRLF"