-
Notifications
You must be signed in to change notification settings - Fork 44
/
gen.package
126 lines (110 loc) · 4.86 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
119
120
121
122
123
124
125
126
##
## Copyright (C) 2012 - 2018 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)"
eval LC_ALL=C $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)"
eval $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
cp DEBIAN/control-dbg ../content-dbg/DEBIAN/control
if [ -e DEBIAN/$package-dbg/ ]; then
mv DEBIAN/$package-dbg/* ../content-dbg && rmdir DEBIAN/$package-dbg
else
mkdir -p ../content-dbg/usr/lib
mv DEBIAN/$package/usr/lib/debug ../content-dbg/usr/lib/ && rmdir DEBIAN/$package/usr/lib/ && rmdir DEBIAN/$package/usr/ &>/dev/null || :
fi
echo "... dbg package done"
}
prepare_debhelper_tree() {
case "$1" in
start)
rmsrc=no
echo $config_dpkg_deb_compat > DEBIAN/compat
if ! grep -q 'Source\:' DEBIAN/{control,control-dbg} 2>/dev/null; then
rmsrc=yes
cp -a DEBIAN/control DEBIAN/control.o
sed -i "s/Package:/Source: $package\n\nPackage:/" DEBIAN/control 2>/dev/null
fi
sarch=$(grep -m1 'Architecture\:' DEBIAN/control | awk -F':' '{print $2}' | 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 ] && mv DEBIAN/control.o 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}' | cut -d ':' -f 2-)
# calculate size dynamically. remove first any entry, then add the actual
rm_size
cd content
if grep -q '${shlibs:Depends}' DEBIAN/control || [ -e DEBIAN/control-dbg ]; then
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
elif [ -z "$sarch" -a "$config_dpkg_deb_addarch" = yes ]; then
sarch=$(grep -m1 'Architecture\:' DEBIAN/control | awk -F':' '{print $2}' | tr -d ' ')
fi
cd ..
for c in content content-dbg; do
[ -e ./$c/DEBIAN/control ] || 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
)
[ "$config_dpkg_deb_addarch" = yes ] && arch="$config_dpkg_deb_separator$sarch" || arch=''
fakeroot dpkg-deb $config_dpkg_deb_opts -b ./$c "${package}"$config_dpkg_deb_separator"${version}"$arch.deb
# remove the size again, because on different filesystems du will return different size
rm_size $c
done
sync