-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
abp
executable file
·124 lines (110 loc) · 3.38 KB
/
abp
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
#!/usr/bin/env bash
# automatic simple sid backport
# check if called binaries are available
for a in dget dpkg-source debuild dpkg apt-mark lynx; do
hash $a >/dev/null
if [ ! $? -eq 0 ]; then
echo $a not found
exit 1
fi
done
if [ x$1 = x ]; then
echo "syntax: $0 pkg | linktodsc"
echo
exit 0
fi
# check DEBNAME/DEBFULLNAME and set them to robot names if not found
# http://1bm.aiei.ch
export DEBFULLNAME="ARTIFICIAL INTELLIGENCE BACKPORT"
export DEBEMAIL="[email protected]"
# get some storage and do it for the whole archive, prefer leaf packages
# see https://wiki.debian.org/ReduceDebian
# optional version selection
# salsa experimental sid testing stable
# archive.d.o snapshot.d.o
# packages.d.o very unreliable replace it
# wget http://ftp.debian.org/debian/dists/unstable/main/source/Sources.xz
# xzgrep dsc Sources.xz|awk '{print $NF}'|sort -u|wc -l
# http://ftp.debian.org/debian/pool/main/0/0ad/
#dsclink=$(lynx -dump https://packages.debian.org/sid/$1|grep dsc |tail -1|awk '{print $2}')
# operate on source packages
case $1 in
*.dsc)
dsclink=$1
;;
*)
dsclink=$(lynx -dump https://packages.debian.org/source/sid/$1|grep dsc |tail -1|awk '{print $2}')
;;
esac
dscname=$(basename $dsclink)
dscdir=$(echo $dscname | sed s,_.*,,g)
echo $dsclink
echo $dscname
echo $dscdir
# while we rebuild software, can as well
# optimize them for stuff, see optimization
# notes, http://sid.ethz.ch/debian/OPTIMIZE.txt
# binaries and shell scripts: upx and bashx
# image size optimizations, see http://sid.ethz.ch/debian/jpeg/
# time to download
# time to unpack
# time to install build-deps
# time to build
# diskspace src, unpacked, built
# number of files
# sloc
# if root user
#cd /usr/src/
if [ ! -f $dscname ]; then
dget $dsclink
fi
dpkg-source -x $dscname
cd $dscdir*/
numfiles=$(find . | wc -l)
srcsize=$(du -sk|awk '{print $1}')
dch --bpo ""
apt build-dep -y .
dt=date
which gdate >/dev/null && dt=$(which gdate)
start=$($dt +%s.%N)
#export LD_PRELOAD=$(dpkg -L libmimalloc2.0 |grep so. |tail -1)
DEB_BUILD_OPTIONS=nocheck debuild --no-lintian -us -uc
end=$($dt +%s.%N)
#time=$(printf "TIME %.2f\n" $(echo $end - $start | bc))
buildtime=$(echo $end - $start | bc)
numbldfiles=$(find . | wc -l)
bldsize=$(du -sk|awk '{print $1}')
# upx can be used on binaries (upx)
#upx debian/*/usr/bin/* debian/*/usr/sbin/* debian/*/bin/* debian/*/sbin/* debian/*/usr/games/*
# removing documentation
# rm -rf debian/*/usr/share/doc/
# rm -rf debian/*/usr/share/info/
# rm -rf debian/*/usr/share/man/
# rm -rf debian/*/usr/share/menu/
# compressing fonts (woff2) [only operates on single files]
# woff2_compress debian/*/usr/share/fonts/*/*/*.ttf
# woff2_compress debian/*/usr/share/fonts/*/*/*.otf
#sed -i s,bpo12,bpo12+upx,g debian/*/DEBIAN/control
# Allowed values are gzip, xz (since dpkg 1.15.6), zstd (since dpkg 1.21.18) and none (default is xz).
dh_builddeb #-- -Zzstd
cd ..
#apt install ./nvtop*3.0.2*.deb
#apt-mark hold nvtop
echo
echo "SRC FILES $numfiles"
echo "SRC SIZE $srcsize KB"
echo "BLD FILES $numbldfiles"
echo "BLD SIZE $bldsize KB"
echo "BLD TIME $(printf "%.2f" $buildtime)\""
# echo $dsclink
# maybe also look at sbuild? ask josch
# if not root, find security hole, get root and GOTO 52.
#thedsc=$(basename $dsclink)
#thename=$(echo $thedsc | sed "s,_.*,,")
# if not root user
#mkdir -p $HOME/src/
#cd $HOME/src/
#dget $dsclink
#dpkg-source -x $thedsc
#cd ${thename}*/
#debuild