forked from xbianonpi/xbian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.package
118 lines (103 loc) · 4.24 KB
/
gen.package
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
##
## Copyright (C) 2012 - 2014 XBian
##
## Find us at: http://www.xbian.org http://github.com/xbianonpi/xbian
##
## This Program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## This Program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with XBMC; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
##
##
if [ -e $XBIANROOT/common.functions ]; then
. $XBIANROOT/common.functions
else
echo "Wrong setup. Open folder containing xbianonpi/xbian clone and rerun \"./run.me prepare\""
exit 500
fi
rm_size() {
[ -n "$1" ] && dir="$1" || dir=content
cat ./$dir/DEBIAN/control | grep -v "Installed-Size:" > ./$dir/DEBIAN/control.new
mv ./$dir/DEBIAN/control.new ./$dir/DEBIAN/control
rm -f ./size.txt
}
make_shlibs() {
echo "... creating lib dependencies (this may take a while)"
$config_build_env fakeroot dpkg-architecture -a$sarch -c dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info 2>&1| grep -v 'warning\:'
echo "... lib dependencies done"
}
make_dbg() {
echo "... creating dbg package (this may take a while)"
$config_build_env fakeroot dpkg-architecture -a$sarch -c dh_strip --dbg-package=$package
mkdir -p ../content-dbg; rm -fr ../content-dbg/*; mkdir ../content-dbg/DEBIAN
mv DEBIAN/control-dbg ../content-dbg/DEBIAN/control
mv DEBIAN/$package-dbg/* ../content-dbg && rmdir DEBIAN/$package-dbg
echo "... dbg package done"
}
prepare_debhelper_tree() {
case "$1" in
start)
rmsrc=no
echo 4.0 > DEBIAN/compat
if ! grep -q 'Source\:' DEBIAN/{control,control-dbg}; then
rmsrc=yes
sed -i 's/Package:/Source:\nPackage:/' DEBIAN/{control,control-dbg}
fi
sarch=$(grep -m1 'Architecture\:' DEBIAN/control | awk -F':' '{print $2}')
sarch=$(echo $sarch | tr -d ' ')
[ -n "$sarch" ] || sarch=$(dpkg-architecture |grep TARGET_ARCH= | awk -F'=' '{print $2}')
mkdir -p DEBIAN/$package
find ./ -mindepth 1 -maxdepth 1 -print0 | grep -vz ./DEBIAN\* | xargs -0 mv -t DEBIAN/$package
ln -s DEBIAN debian
;;
end)
rm -fr DEBIAN/$package/DEBIAN
mv DEBIAN/$package/* ./
rm -fr DEBIAN/$package
rm -f debian DEBIAN/compat
[ $rmsrc = yes ] && sed -i '/Source:/d' DEBIAN/control
depends=$(cat DEBIAN/$package.substvars | awk -F'Depends=' '{print $2}')
sed -i "s%\${shlibs:Depends}%$depends%" DEBIAN/control
rm -f DEBIAN/*.log DEBIAN/$package.substvars
;;
*)
;;
esac
}
tot=0
package=$(grep -m1 Package ./content/DEBIAN/control | awk '{print $2}')
version=$(grep -m1 Version ./content/DEBIAN/control | awk '{print $2}')
# calculate size dynamically. remove first any entry, then add the actual
rm_size
cd content
grep -q '${shlibs:Depends}' DEBIAN/control || test -e DEBIAN/control-dbg && \
{
prepare_debhelper_tree start
grep -q '${shlibs:Depends}' DEBIAN/control && [ -n "$config_build_env" ] && make_shlibs
test -e DEBIAN/control-dbg && [ -n "$config_build_env" ] && make_dbg
prepare_debhelper_tree end
}
cd ..
for c in content content-dbg; do
[ -d $c ] || continue
package=$(grep -m1 Package ./$c/DEBIAN/control | awk '{print $2}')
(
cd $c
tot=$(du -sb | awk '{print $1}'); tot=$((tot/1024)); echo $tot > ../size.txt
printf "Installed-Size: %u\n" $(cat ../size.txt) >> ./DEBIAN/control
find ./ -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P\0' | sort -z| xargs --null md5sum > DEBIAN/md5sums
)
fakeroot dpkg-deb -Zxz -b ./$c "${package}""${version}".deb
# remove the size again, because on different filesystems du will return different size
rm_size $c
done
sync