-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-deb.sh
executable file
·113 lines (95 loc) · 2.93 KB
/
build-deb.sh
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
#!/bin/bash
# shellcheck disable=2086,2103,2164,2317
cd "$(dirname "$0")"
# avoid command failure
exit_check() { [ "$1" = 0 ] || exit "$1"; }
trap 'exit_check $?' EXIT
rawurlencode() {
local string=$1
local strlen=${#string}
local encoded pos c o
for ((pos = 0; pos < strlen; pos++)); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9]) o="${c}" ;;
*) printf -v o '%%%02x' "'$c" ;;
esac
encoded+="${o}"
done
echo "${encoded}"
}
_gitlab_upstream=https://salsa.debian.org
wget_dl() { wget "${_gitlab_upstream}/${1}" -o /dev/null -O -; }
curl_dl() { curl "${_gitlab_upstream}/${1}" 2>/dev/null; }
if command -v wget >/dev/null; then
DOWNLOAD=wget_dl
else
DOWNLOAD=curl_dl
fi
pkgname=busybox
_latest_tag=$($DOWNLOAD "api/v4/projects/installer-team%2Fbusybox/repository/tags" | grep '"name":' | head -1 | awk -F '"' '{print $4}')
_branch=${_latest_tag%%/*}
_full_ver=${_latest_tag##*/}
_encoded_ver=$(rawurlencode "$_full_ver")
_ver=${_full_ver//1%/}
pkgver=${_ver%%/*}
pkgrel=${_ver##*/}
# Fetch source package
$DOWNLOAD "installer-team/busybox/-/archive/${_branch}/${_encoded_ver}/busybox-${_branch}-${_encoded_ver}.tar.gz" | tar -xzf -
cp -rn busybox-${_branch}-${_full_ver}/* .
rm -rf busybox-${_branch}-${_full_ver}
# Modify control file
control=debian/control.tmp
touch $control
IFS=$'\n'
while read -r line; do
echo -e "$line" >>$control
[ "$line" ] || break
done <${control%.tmp}
unset IFS
cat <<'EOF' >>$control
Package: busybox-aaropa
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}
Conflicts:
Replaces:
Description: Tiny utilities for small and embedded systems
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for the most common
utilities you would usually find on your desktop system (i.e., ls, cp, mv,
mount, tar, etc.). The utilities in BusyBox generally have fewer options than
their full-featured GNU cousins; however, the options that are included
provide the expected functionality and behave very much like their GNU
counterparts.
.
This package installs the BusyBox binary but does not install
symlinks for any of the supported utilities. Some of the utilities
can be used in the system by installing the busybox-syslogd,
udhcpc or udhcpd packages.
.
This variant of busybox is only used in BlissOS initrd.img.
EOF
cp -f $control ${control%.tmp}
# Modify build rules
rules=debian/rules.tmp
touch $rules
IFS=$'\n'
while read -r line; do
case "$line" in
flavours\ =\ *) echo 'flavours = blissos' >>$rules ;;
*test-deb*) echo -e "${line//test-deb/test-blissos}" >>$rules ;;
execute_*) break ;;
*) echo -e "$line" >>$rules ;;
esac
done <${rules%.tmp}
unset IFS
cp -f $rules ${rules%.tmp}
# Create .orig tarball
tar -cJf ../${pkgname}_${pkgver}.orig.tar.xz .
dpkg-buildpackage -b --no-sign
# export metadata
cat <<EOF >../metadata.yml
Name: ${pkgname}
Version: ${_ver}
Variants: aaropa aaropa-dbgsym
EOF