forked from LDAPAccountManager/lam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildPackages
executable file
·265 lines (233 loc) · 8.59 KB
/
buildPackages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/bash
#
# Builds LDAP Account Manager packages.
if [ $# -lt 1 ]
then
echo -e "Usage: buildPackage <tag>, buildPackage develop, buildPackage -b branch"
exit
fi
set -e
if [ "$1" = "develop" ]
then
export REPO_BRANCH="develop"
elif [ "$1" = "-b" ]
then
export REPO_BRANCH="$2"
else
export REPO_BRANCH="$1"
fi
# minifies the JavaScript files
function minify {
local dir="$1"
echo "Minify JS files in $dir"
local outFile=$dir/100_lam.${VERSION}.min.js
local files=`ls $dir/*.js`
local jsFiles=""
for file in $files; do
jsFiles="$jsFiles $file"
done
uglifyjs -o $outFile $jsFiles
rm $files
# add final new line to supress Debian warnings
echo "" >> $outFile
}
# minifies the CSS files
function minifyCSS {
local dir="$1"
echo "Minify CSS files in $dir"
local outFile=$dir/100_lam.${VERSION}.min.css
local files=`ls $dir/*.css`
extraOptions=''
cleancss --help | grep -e '--skip-rebase' > /dev/null
if [ $? -eq 0 ]; then
extraOptions='--skip-rebase'
fi
cat $files | cleancss $extraOptions -o $outFile
rm $files
# add final new line to supress Debian warnings
echo "" >> $outFile
}
echo "Getting files..."
git clone --depth 1 -b $REPO_BRANCH --single-branch [email protected]:LDAPAccountManager/lam.git github
cd github
mv lam ../
mv lam-packaging ../
cd ..
rm -rf github
git clone --depth 1 -b $REPO_BRANCH --single-branch [email protected]:LDAPAccountManager/lamPro.git lamPro
cd lamPro
rm -rf .git
rm -rf docker
cd ..
cp lam-packaging/getVersion ./
export VERSION=`./getVersion`
# remove files which are not in the final release
rm -r lam/po
rm -r lam/tests
rm -f lam/lib/3rdParty/tcpdf/fonts/*.ttf
rm -r lam/templates/lib/extra/ckeditor/plugins/*/dev
rm -r lam/lib/3rdParty/composer/nesbot/carbon/bin
rm lam/composer*
find . -name .svnignore -exec rm {} \;
find . -name .gitignore -exec rm {} \;
find lam/lib/3rdParty -name LICENSE -exec rm {} \;
find lam/lib/3rdParty -name README.md -exec rm {} \;
find lam/lib/3rdParty -name CHANGELOG.md -exec rm {} \;
find lam/lib/3rdParty -name CHANGELOG.txt -exec rm {} \;
find lam/lib/3rdParty -name .github | xargs rm -r
find lam/lib/3rdParty -name .gitattributes | xargs rm -r
mv lam ldap-account-manager-$VERSION
# create LAM manual
cd ldap-account-manager-$VERSION/docs/manual-sources
./make.sh
cd ../../..
rm -r ldap-account-manager-$VERSION/docs/manual-sources
# create LAM Pro build directory
mkdir LAMPro
cp -a ldap-account-manager-$VERSION LAMPro/ldap-account-manager-$VERSION
cp -a lamPro/* LAMPro/ldap-account-manager-$VERSION
rm -r lamPro
# create Debian build dirs
mkdir Debian
mkdir LAMPro/Debian
rm ldap-account-manager-$VERSION/phpdoc.sh
rm LAMPro/ldap-account-manager-$VERSION/phpdoc.sh
# tar.bz2
cp lam-packaging/autoconf/configure.ac ldap-account-manager-$VERSION/
cp lam-packaging/autoconf/Makefile.in ldap-account-manager-$VERSION/
cd ldap-account-manager-$VERSION
touch install.sh
perl -pi -e "s/\\@\\@VERSION\\@\\@/$VERSION/g" configure.ac
autoconf
rm -r autom4te.cache
cd ..
# Debian gets orig.tar.bz2 with original JS files
tar cfj ldap-account-manager-$VERSION.tar.bz2 --owner=root --group=root --mtime=now ldap-account-manager-$VERSION
mv ldap-account-manager-$VERSION.tar.bz2 Debian/ldap-account-manager_$VERSION.orig.tar.bz2
cp -ar ldap-account-manager-$VERSION Debian/
# build other packages with minified JS files
minify ldap-account-manager-$VERSION/templates/lib
minifyCSS ldap-account-manager-$VERSION/style
tar cfj ldap-account-manager-$VERSION.tar.bz2 --owner=root --group=root --mtime=now ldap-account-manager-$VERSION
rm -r ldap-account-manager-$VERSION
# tar.bz2 of LAM Pro
cd LAMPro
cp ../lam-packaging/autoconf/configure.ac ldap-account-manager-$VERSION/
cp ../lam-packaging/autoconf/Makefile.in ldap-account-manager-$VERSION/
cd ldap-account-manager-$VERSION
touch install.sh
perl -pi -e "s/\\@\\@VERSION\\@\\@/$VERSION/g" configure.ac
autoconf
rm -r autom4te.cache
cd ..
# Debian gets orig.tar.bz2 with original JS files
tar cfj ldap-account-manager-$VERSION.tar.bz2 --owner=root --group=root --mtime=now ldap-account-manager-$VERSION
mv ldap-account-manager-$VERSION.tar.bz2 Debian/ldap-account-manager_$VERSION.orig.tar.bz2
cp -ar ldap-account-manager-$VERSION Debian/
# build other packages with minified JS files
minify ldap-account-manager-$VERSION/templates/lib
minifyCSS ldap-account-manager-$VERSION/style
tar cfj ldap-account-manager-$VERSION.tar.bz2 --owner=root --group=root --mtime=now ldap-account-manager-$VERSION
rm -r ldap-account-manager-$VERSION
cd ..
# Debian
cp -r lam-packaging/debian Debian/ldap-account-manager-$VERSION/
cd Debian/ldap-account-manager-$VERSION
pdebuild --debsign-k 478730308FBD512ADF09D38E7F3D136B2BCD7990
mv /var/cache/pbuilder/result/* ../
cd ..
rm -r ldap-account-manager-$VERSION
cd ..
mkdir Debian-Upload
cp Debian/*.dsc Debian/*.orig.tar.bz2 Debian/*source.changes Debian/*.debian.tar.xz Debian-Upload
# Debian for LAM Pro
cd LAMPro
cp -r ../lam-packaging/debian Debian/ldap-account-manager-$VERSION/
cd Debian/ldap-account-manager-$VERSION
pdebuild --debsign-k 478730308FBD512ADF09D38E7F3D136B2BCD7990
mv /var/cache/pbuilder/result/* ../
cd ..
rm -r ldap-account-manager-$VERSION
cd ..
cd ..
# RPM
perl -pi -e "s/\\@\\@VERSION\\@\\@/$VERSION/g" lam-packaging/RPM/ldap-account-manager.spec
cp lam-packaging/RPM/ldap-account-manager.spec lam-packaging/RPM/ldap-account-manager-fedora.spec
perl -pi -e "s/\\@\\@DISTRIBUTION\\@\\@/fedora/g" lam-packaging/RPM/ldap-account-manager-fedora.spec
perl -pi -e "s/\\@\\@USER\\@\\@/apache/g" lam-packaging/RPM/ldap-account-manager-fedora.spec
perl -pi -e "s/\\@\\@GROUP\\@\\@/apache/g" lam-packaging/RPM/ldap-account-manager-fedora.spec
perl -pi -e "s/\\@\\@HTTP_CONF_DIR\\@\\@/\\/etc\\/httpd\\/conf.d/g" lam-packaging/RPM/ldap-account-manager-fedora.spec
cp lam-packaging/RPM/ldap-account-manager.spec lam-packaging/RPM/ldap-account-manager-suse.spec
perl -pi -e "s/\\@\\@DISTRIBUTION\\@\\@/suse/g" lam-packaging/RPM/ldap-account-manager-suse.spec
perl -pi -e "s/\\@\\@USER\\@\\@/wwwrun/g" lam-packaging/RPM/ldap-account-manager-suse.spec
perl -pi -e "s/\\@\\@GROUP\\@\\@/www/g" lam-packaging/RPM/ldap-account-manager-suse.spec
perl -pi -e "s/\\@\\@HTTP_CONF_DIR\\@\\@/\\/etc\\/apache2\\/conf.d/g" lam-packaging/RPM/ldap-account-manager-suse.spec
mkdir RPM
mkdir LAMPro/RPM
# Fedora RPM
cp ldap-account-manager-$VERSION.tar.bz2 ~/rpmbuild/SOURCES
cp lam-packaging/RPM/lam.apache.conf ~/rpmbuild/SOURCES
cp lam-packaging/RPM/lam.nginx.conf ~/rpmbuild/SOURCES
rpmbuild --clean --rmsource -bb lam-packaging/RPM/ldap-account-manager-fedora.spec
mv ~/rpmbuild/RPMS/noarch/ldap-account-manager*-$VERSION-*1.noarch.rpm RPM/
# Fedora RPM for LAM Pro
cd LAMPro
cp ldap-account-manager-$VERSION.tar.bz2 ~/rpmbuild/SOURCES/ldap-account-manager-$VERSION.tar.bz2
cp ../lam-packaging/RPM/lam.apache.conf ~/rpmbuild/SOURCES
cp ../lam-packaging/RPM/lam.nginx.conf ~/rpmbuild/SOURCES
rpmbuild --clean --rmsource -bb ../lam-packaging/RPM/ldap-account-manager-fedora.spec
mv ~/rpmbuild/RPMS/noarch/ldap-account-manager*-$VERSION-*1.noarch.rpm RPM/
cd ..
# Suse RPM
cp ldap-account-manager-$VERSION.tar.bz2 ~/rpmbuild/SOURCES
cp lam-packaging/RPM/lam.apache.conf ~/rpmbuild/SOURCES
cp lam-packaging/RPM/lam.nginx.conf ~/rpmbuild/SOURCES
rpmbuild --clean --rmsource -bb lam-packaging/RPM/ldap-account-manager-suse.spec
mv ~/rpmbuild/RPMS/noarch/ldap-account-manager*-$VERSION-*1.noarch.rpm RPM/
# Suse RPM for LAM Pro
cd LAMPro
cp ldap-account-manager-$VERSION.tar.bz2 ~/rpmbuild/SOURCES/ldap-account-manager-$VERSION.tar.bz2
cp ../lam-packaging/RPM/lam.apache.conf ~/rpmbuild/SOURCES
cp ../lam-packaging/RPM/lam.nginx.conf ~/rpmbuild/SOURCES
rpmbuild --clean --rmsource -bb ../lam-packaging/RPM/ldap-account-manager-suse.spec
mv ~/rpmbuild/RPMS/noarch/ldap-account-manager*-$VERSION-*1.noarch.rpm RPM/
cd ..
rpmsign --addsign RPM/*.rpm LAMPro/RPM/*.rpm
# generate checksum files
sha256sum *.tar.bz2 >> checksums.txt
cd RPM
sha256sum *.rpm >> ../checksums.txt
cd ../Debian
sha256sum *.deb >> ../checksums.txt
cd ..
# generate checksum files for LAM Pro
cd LAMPro
sha256sum *.tar.bz2 >> checksums.txt
cd RPM
sha256sum *.rpm >> ../checksums.txt
cd ../Debian
sha256sum *.deb >> ../checksums.txt
cd ../..
# create result folders
mkdir LAM-packages
mkdir LAM-packages/logs
mv Debian/*.deb LAM-packages/
mv Debian/* LAM-packages/logs/
mv Debian-Upload LAM-packages/
mv RPM/*.rpm LAM-packages/
mv checksums.txt LAM-packages/
mv *.tar.bz2 LAM-packages/
mkdir LAMPro-packages
mkdir LAMPro-packages/logs
mv LAMPro/Debian/*.deb LAMPro-packages/
mv LAMPro/Debian/* LAMPro-packages/logs/
mv LAMPro/RPM/*.rpm LAMPro-packages/
mv LAMPro/checksums.txt LAMPro-packages/
mv LAMPro/*.tar.bz2 LAMPro-packages/
# clean up
rm -r lam-packaging
rm getVersion
rm -f *.log
rm -r LAMPro
rm -r Debian
rm -r RPM