File: build_packages.sh

package info (click to toggle)
fbreader 0.12.10dfsg-8
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 12,768 kB
  • sloc: cpp: 78,853; xml: 15,548; makefile: 857; sh: 302
file content (155 lines) | stat: -rwxr-xr-x 4,159 bytes parent folder | download | duplicates (7)
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
#! /bin/bash

version=`cat fbreader/VERSION`
tmpdir=fbreader-$version

if [ "$1" == "-non-GPL" ]; then
	distdir=distributions-nonGPL
	pkgdir=packages-nonGPL
	prepare_nonGPL=true
	shift;
else
	distdir=distributions
	pkgdir=packages
	prepare_nonGPL=false
fi

if [ $# -lt 1 ]; then
	echo "usage:"
	echo "  $0 [-non-GPL] <architecture>"
	echo "or"
	echo "  $0 [-non-GPL] all"
	echo "or"
	echo "  $0 [-non-GPL] supported"
	echo ""
	echo "available architectures are:"
	for pkgtype in $distdir/*; do
		for archtype in $pkgtype/*; do
			echo "  `basename $archtype`-`basename $pkgtype`";
		done;
	done;
	exit 1;
fi

create_tmpdir() {
	mkdir $tmpdir
	cp -r Makefile build_packages.sh zlibrary fbreader makefiles README.build CHANGES* distributions distributions-nonGPL ChangeLog $tmpdir
	rm -rf `find $tmpdir -name ".svn"`
	make -C $tmpdir distclean 1> /dev/null 2>&1

	if [ "$prepare_nonGPL" == "true" ]; then
		pushd $tmpdir > /dev/null;
		echo -en "Removing Arabic localization... ";
		rm -rf fbreader/data/resources/ar.xml zlibrary/core/data/resources/ar.xml fbreader/data/help/MiniHelp.*.ar.fb2;
		echo OK;
		echo -en "Removing Finnish localization... ";
		rm -rf fbreader/data/resources/fi.xml zlibrary/core/data/resources/fi.xml fbreader/data/help/MiniHelp.*.fi.fb2;
		echo OK;
		echo -en "Removing Swedish localization... ";
		rm -rf fbreader/data/resources/sv.xml zlibrary/core/data/resources/sv.xml fbreader/data/help/MiniHelp.*.sv.fb2;
		echo OK;
		echo -en "Removing German localization... ";
		rm -rf fbreader/data/resources/de.xml zlibrary/core/data/resources/de.xml fbreader/data/help/MiniHelp.*.de.fb2;
		echo OK;
		echo -en "Removing Czech hyphenation patterns... ";
		zip -dq zlibrary/text/data/hyphenationPatterns.zip cs.pattern;
		echo OK;
		echo -en "Removing Indonesian hyphenation patterns... ";
		zip -dq zlibrary/text/data/hyphenationPatterns.zip id.pattern;
		echo OK;
		echo -en "Removing Qt-based interface... ";
		rm -rf zlibrary/ui/src/opie zlibrary/ui/src/qtopia zlibrary/ui/src/qt zlibrary/ui/src/qt4
		echo OK;
		popd > /dev/null;
	fi;
}

remove_tmpdir() {
	rm -rf $tmpdir
}

build_package() {
	make_package="make -f makefiles/packaging.mk -C $tmpdir DIST_DIR=$distdir"

	case "$2" in
		debian)
			case "$1" in
				maemo)
					/scratchbox/login sb-conf se SDK_ARM
					/scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
					;;
				maemo2|maemo3)
					/scratchbox/login sb-conf se SDK_ARMEL
					/scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
					;;
				maemo4)
					/scratchbox/login sb-conf se CHINOOK_ARMEL
					/scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
					;;
				maemo5)
					/scratchbox/login sb-conf se FREMANTLE_ARMEL
					/scratchbox/login -d `pwd` $make_package ARCHITECTURE=$1 $2
					;;
				*)
					$make_package ARCHITECTURE=$1 $2
					;;
			esac;
			mkdir -p $pkgdir/$1
			mv -f $tmpdir/*.deb $tmpdir/*.dsc $tmpdir/*.changes $tmpdir/*.tar.gz $pkgdir/$1
			;;
		ipk|debipk)
			$make_package ARCHITECTURE=$1 $2
			mkdir -p $pkgdir/$1
			mv -f $tmpdir/*.ipk $pkgdir/$1
			;;
		motopkg)
			$make_package ARCHITECTURE=$1 $2
			mkdir -p $pkgdir/$1
			mv -f $tmpdir/*.pkg $pkgdir/$1
			;;
		tarball)
			$make_package ARCHITECTURE=$1 $2
			mkdir -p $pkgdir/$1
			mv -f $tmpdir/*.tgz $pkgdir/$1
			;;
		nsi)
			$make_package ARCHITECTURE=$1 $2
			mkdir -p $pkgdir/$1
			mv -f $tmpdir/*.exe $pkgdir/$1
			;;
		*)
			echo no rule is defined for package type ''$2'';
			;;
	esac;
}

if [ $1 == all ]; then
	create_tmpdir
	for pkgtype in $distdir/*; do
		for archtype in $pkgtype/*; do
			build_package `basename $archtype` `basename $pkgtype`;
		done;
	done;
	remove_tmpdir
elif [ $1 == supported ]; then
	create_tmpdir
	build_package desktop debian
	build_package win32 nsi
	build_package source tarball
	remove_tmpdir
else
	while [ $# -gt 0 ] ; do
		archtype=`echo $1 | cut -d "-" -f 1`;
		pkgtype=`echo $1 | cut -d "-" -f 2`;
		extra=`echo $1 | cut -d "-" -f 3`;

		if [ "$pkgtype" != "" -a "$extra" == "" -a -d $distdir/$pkgtype/$archtype ]; then
			create_tmpdir
			build_package $archtype $pkgtype
			remove_tmpdir
		else 
			echo "unknown architecture: $1"
		fi;
		shift;
	done;
fi;