forked from learningequality/kolibri-installer-debian
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·146 lines (126 loc) · 4.1 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·146 lines (126 loc) · 4.1 KB
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
#! /usr/bin/env bash
set -eo pipefail
# set -euxo pipefail
# removed -u because it was causing an error when reading VIRTUAL_ENV from the environment
# When this script is run with -S, it builds a source package only.
# It will ask to sign the package if the $DEBMAIL gpg key is installed in the system
signfile () {
local file="$1"
if [[ "$GPG_PASSPHRASE" != "" ]]
then
UNSIGNED_FILE=../"$(basename "$file")"
ASCII_SIGNED_FILE="${UNSIGNED_FILE}.asc"
gpg --utf8-strings --clearsign --armor --textmode --batch --pinentry loopback --passphrase "$GPG_PASSPHRASE" --weak-digest SHA1 --weak-digest RIPEMD160 --output "$ASCII_SIGNED_FILE" "$UNSIGNED_FILE"
mv -f "$ASCII_SIGNED_FILE" "$UNSIGNED_FILE"
fi
}
signfiles(){
local file=../"$1"
signfile "$file".dsc
fixup_buildinfo "$file".dsc "$file"_source.buildinfo
signfile "$file"_source.buildinfo
fixup_changes dsc "$file".dsc "$file"_source.changes
fixup_changes buildinfo "$file"_source.buildinfo "$file"_source.changes
signfile "$file"_source.changes
}
fixup_control() {
# This code has been copied from the debsign utility included in the devscripts package
local filter_out="$1"
local childtype="$2"
local parenttype="$3"
local child="$4"
local parent="$5"
test -r "$child" || {
echo "$PROGNAME: Can't read .$childtype file $child!" >&2
return 1
}
local md5=$(md5sum "$child" | cut -d' ' -f1)
local sha1=$(sha1sum "$child" | cut -d' ' -f1)
local sha256=$(sha256sum "$child" | cut -d' ' -f1)
perl -i -pe 'BEGIN {
'" \$file='$child'; \$md5='$md5'; "'
'" \$sha1='$sha1'; \$sha256='$sha256'; "'
$size=(-s $file); ($base=$file) =~ s|.*/||;
$infiles=0; $inmd5=0; $insha1=0; $insha256=0; $format="";
}
if(/^Format:\s+(.*)/) {
$format=$1;
die "Unrecognised .$parenttype format: $format\n"
unless $format =~ /^\d+(\.\d+)*$/;
($major, $minor) = split(/\./, $format);
$major+=0;$minor+=0;
die "Unsupported .$parenttype format: $format\n"
if('"$filter_out"');
}
/^Files:/i && ($infiles=1,$inmd5=0,$insha1=0,$insha256=0);
if(/^Checksums-Sha1:/i) {$insha1=1;$infiles=0;$inmd5=0;$insha256=0;}
elsif(/^Checksums-Sha256:/i) {
$insha256=1;$infiles=0;$inmd5=0;$insha1=0;
} elsif(/^Checksums-Md5:/i) {
$inmd5=1;$infiles=0;$insha1=0;$insha256=0;
} elsif(/^Checksums-.*?:/i) {
die "Unknown checksum format: $_\n";
}
/^\s*$/ && ($infiles=0,$inmd5=0,$insha1=0,$insha256=0);
if ($infiles &&
/^ (\S+) (\d+) (\S+) (\S+) \Q$base\E\s*$/) {
$_ = " $md5 $size $3 $4 $base\n";
$infiles=0;
}
if ($inmd5 &&
/^ (\S+) (\d+) \Q$base\E\s*$/) {
$_ = " $md5 $size $base\n";
$inmd5=0;
}
if ($insha1 &&
/^ (\S+) (\d+) \Q$base\E\s*$/) {
$_ = " $sha1 $size $base\n";
$insha1=0;
}
if ($insha256 &&
/^ (\S+) (\d+) \Q$base\E\s*$/) {
$_ = " $sha256 $size $base\n";
$insha256=0;
}' "$parent"
}
fixup_buildinfo() {
fixup_control '($major != 0 or $minor > 2) and ($major != 1 or $minor > 0)' dsc buildinfo "$@"
}
fixup_changes() {
local childtype="$1"
shift
fixup_control '$major!=1 or $minor > 8 or $minor < 7' $childtype changes "$@"
}
BUILD_BINARY=1
while getopts "S" FLAG; do
case $FLAG in
S)
BUILD_BINARY=0
;;
esac
done
cd dist
tar xf *orig.tar.gz
# SOURCE_DIR=`tar --exclude="*/*" -tf *.orig.tar.gz|head -1`
SOURCE_DIR=`ls -d kolibri*/`
cp -r ../debian $SOURCE_DIR
DEB_VERSION=`cat VERSION | sed -s 's/^\+\.\+\.\+\([abc]\|\.dev\)/\~\0/g'`
cd $SOURCE_DIR
python3 ../../build_tools/generate_changelog.py \
--debian-changelog debian/changelog \
--version-file ../VERSION \
--packaging-changelog ../../CHANGELOG
# package can't be run from a virtualenv
if [[ "$VIRTUAL_ENV" != "" ]]
then
export PATH=`echo $PATH | tr ":" "\n" | grep -v $VIRTUAL_ENV | tr "\n" ":"`
unset VIRTUAL_ENV
fi
if [[ "$BUILD_BINARY" -eq "0" ]]; then
# build source package only
dpkg-buildpackage -S --no-sign
signfiles kolibri-source_$DEB_VERSION-0ubuntu1
else
# build with unsigned source, changes and gzip compression
dpkg-buildpackage -A -Zgzip -z3 -us -uc
fi