Skip to content

Commit 434f405

Browse files
author
Digital-Larry
authored
[CTD-271]-made several changes to the build script. (#5)
* CTD-271-made several changes to the build script. a) Removed the step for lintian checking when building a tar file b) Fixed routine to clean up daemon binaries prior to doing build c) Moved android target code closer to the beginning for quicker debugging. d) Fixed a few things associated with new output folder "./build" e) Lintian errors print inline rather than in "less" - still need to catch lintian errors and make them cause CI to fail. * CTD-271 updated extract-scripts to include lib folder when making a tar build * CTD-271 removing commented code per Dana's request
1 parent 292a41a commit 434f405

File tree

2 files changed

+58
-63
lines changed

2 files changed

+58
-63
lines changed

scripts/build.sh

Lines changed: 55 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,25 @@ setEnvironment()
2727
sed -i "/Architecture:/c\Architecture: $1" "$controlFile"
2828

2929
setOption "options" "Architecture" "$1"
30-
if [ -e "$pkgFolder"/usr/bin/connectd.* ]; then
31-
rm "$pkgFolder"/usr/bin/connectd.*
32-
fi
33-
if [ -e "$pkgFolder"/usr/bin/connectd_schannel.* ]; then
34-
rm "$pkgFolder"/usr/bin/connectd_schannel.*
35-
fi
30+
31+
for i in $(find "$pkgFolder"/usr/bin/ -type f -name "connectd.*")
32+
do
33+
rm "$i"
34+
done
35+
36+
for i in $(find "$pkgFolder"/usr/bin/ -type f -name "connectd_schannel.*")
37+
do
38+
rm "$i"
39+
done
40+
3641
sudo cp ./assets/connectd."$2" "$pkgFolder"/usr/bin
37-
if [ $? = 1 ]; then
42+
if [ $? -eq 1 ]; then
3843
echo "Error, missing file: connectd.$2"
3944
exit 1
4045
fi
4146
sudo chmod +x "$pkgFolder"/usr/bin/connectd."$2"
4247
sudo cp ./assets/schannel."$2" "$pkgFolder"/usr/bin/connectd_schannel."$2"
43-
if [ $? = 1 ]; then
48+
if [ $? -eq 1 ]; then
4449
echo "Error, missing file: schannel.$2"
4550
exit 1
4651
fi
@@ -57,9 +62,16 @@ setEnvironment()
5762
buildDebianFile()
5863
{
5964
# build reference DEB file
65+
ret=0
6066
sudo chown -R root:root "$1"
61-
dpkg-deb --build "$1"
62-
ret=$(runLintian "$1".deb)
67+
if [ "$buildDeb" -eq 1 ]; then
68+
dpkg-deb --build "$1"
69+
# only run lintian if we are really making a Debian package
70+
ret=$(runLintian "$1".deb)
71+
else
72+
dpkg-deb --build "$1"
73+
ret=$?
74+
fi
6375
return $ret
6476
}
6577

@@ -68,21 +80,17 @@ runLintian()
6880
{
6981
ret_val=0
7082
# scan debian file for errors and warnings
71-
lintian -EviIL +pedantic "$1" > lintian-result.txt
83+
lintian -vi --show-overrides "$1" > lintian-result.txt
7284
grep E: lintian-result.txt > lintian-E.txt
7385
grep W: lintian-result.txt > lintian-W.txt
7486
grep I: lintian-result.txt > lintian-I.txt
7587
grep X: lintian-result.txt > lintian-X.txt
76-
rm lintian-result.txt
7788
if [ -s lintian-E.txt ]; then
7889
ret_val=1
7990
fi
8091
return $ret_val
8192
}
8293

83-
# copy build tree to /tmp to do actual build
84-
# commented out, temporarily disabling this method
85-
# cp -R "$pkg" "$pkgFolder"
8694
gzip -9 "$pkgFolder"/usr/share/doc/$pkg/*.man
8795

8896
# change owner of all files to current user for manipulations
@@ -95,14 +103,9 @@ cwd="$(pwd)/build"
95103
mkdir -p $cwd
96104

97105
build() {
98-
if [ $buildDeb -eq 1 ]; then
99-
echo "Building Debian package..."
100-
else
101-
echo "Building tar package..."
102-
fi
106+
echo
107+
echo "========================================"
103108

104-
echo "PLATFORM=$PLATFORM"
105-
echo "arch=$arch"
106109
echo
107110

108111
setEnvironment "$arch" "$PLATFORM"
@@ -112,18 +115,16 @@ build() {
112115
# clean up and recreate md5sums file
113116
cd "$pkgFolder"
114117
sudo chmod 777 DEBIAN
115-
# ls -l
116118
sudo find -type f ! -regex '.*?DEBIAN.*' -exec md5sum "{}" + | grep -v md5sums > md5sums
117119
sudo chmod 775 DEBIAN
118120
sudo mv md5sums DEBIAN
119121
sudo chmod 644 DEBIAN/md5sums
120-
# cd "$cwd"
121122
cd ..
122-
echo "Current directory: $cwd"
123123

124-
if [ "$buildDeb" = 1 ]; then
124+
if [ "$buildDeb" -eq 1 ]; then
125125

126126
echo "Building Debian package for architecture: $arch"
127+
echo "PLATFORM=$PLATFORM"
127128

128129
#--------------------------------------------------------
129130
# for Deb pkg build, remove builddate.txt file
@@ -136,41 +137,48 @@ build() {
136137
#--------------------------------------------------------
137138
buildDebianFile "$pkgFolder"
138139

139-
if [ $? == 0 ];then
140-
version=$(grep -i version "$controlFile" | awk '{ print $2 }')
141-
filename="${pkg}_${version}_$arch".deb
142-
mv "$pkgFolder".deb "$cwd/$filename"
143-
else
140+
if [ $? -eq 1 ];then
144141
echo "Errors encountered during build."
145-
echo "Press Enter to review errors."
146-
read anykey
147-
less lintian-E.txt
142+
cat lintian-E.txt
148143
fi
149144

145+
version=$(grep -i version "$controlFile" | awk '{ print $2 }')
146+
filename="${pkg}_${version}_$arch".deb
147+
mv "$pkgFolder".deb "$cwd/$filename"
150148
else
149+
echo "Building tar package for PLATFORM: $PLATFORM"
151150
# we are making a tar file, but first we make a Debian file
152-
# use lintian to check for errors
153151
# then extract the /usr, /etc and /lib folders.
154152
buildDebianFile "$pkgFolder"
155153

156-
if [ $? == 0 ];then
157-
version=$(grep -i version "$controlFile" | awk '{ print $2 }')
158-
159-
echo "Extracting contents to tar file"
160-
./scripts/extract-scripts.sh "$pkgFolder".deb
161-
filename="${pkg}_${version}_$PLATFORM"
162-
mv "$pkgFolder".deb.tar "$cwd/$filename".tar
163-
else
154+
if [ $? == 1 ];then
164155
echo "Errors encountered during build."
165-
echo "Press Enter to review errors."
166-
read anykey
167-
less lintian-E.txt
168156
fi
169157

158+
version=$(grep -i version "$controlFile" | awk '{ print $2 }')
159+
echo "Extracting contents to tar file"
160+
./scripts/extract-scripts.sh "$pkgFolder".deb
161+
filename="${pkg}_${version}_$PLATFORM".tar
162+
mv "$pkgFolder".deb.tar "$cwd/$filename"
163+
170164
fi
171165

172166
}
173167

168+
buildDeb=0
169+
arch="armhf"
170+
PLATFORM=arm-android
171+
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
172+
setOption options "PSFLAGS" "ax"
173+
build
174+
175+
buildDeb=0
176+
arch="armhf"
177+
PLATFORM=arm-android_static
178+
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
179+
setOption options "PSFLAGS" "ax"
180+
build
181+
174182
buildDeb=1
175183
setOption options "PSFLAGS" "ax"
176184
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
@@ -189,7 +197,6 @@ build
189197

190198
buildDeb=0
191199
setOption options "PSFLAGS" "ax"
192-
# setOption "mac" '$(ip addr | grep ether | tail -n 1 | awk "{ print $2 }")'
193200
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
194201
arch="i386"
195202
PLATFORM=x86-etch
@@ -204,20 +211,6 @@ setOption options "BASEDIR" ""
204211
setOption options "PSFLAGS" "ax"
205212
build
206213

207-
buildDeb=0
208-
arch="armhf"
209-
PLATFORM=arm-android
210-
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
211-
setOption options "PSFLAGS" "ax"
212-
build
213-
214-
buildDeb=0
215-
arch="armhf"
216-
PLATFORM=arm-android_static
217-
setOption options "mac" '$'"(ip addr | grep ether | tail -n 1 | awk" "'{ print" '$2' "}')"
218-
setOption options "PSFLAGS" "ax"
219-
build
220-
221214
buildDeb=0
222215
arch="armhf"
223216
PLATFORM=arm-linaro-pi
@@ -240,4 +233,4 @@ setOption options "BASEDIR" ""
240233
setOption options "PSFLAGS" "ax"
241234
build
242235

243-
ls -l "${pkg}"*.*
236+
ls -l "build/${pkg}"*.*

scripts/extract-scripts.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ fi
1616
FILELOG=etc/connectd/builddate.txt
1717
echo "Build date: $(date)" > "$FILELOG"
1818
ls -lR usr >> "$FILELOG"
19+
ls -lR lib >> "$FILELOG"
1920
ls -lR etc >> "$FILELOG"
20-
tar cf $1.tar usr etc
21+
tar cf $1.tar usr etc lib
2122
rm -r usr
23+
rm -r lib
2224
rm -r etc
2325

0 commit comments

Comments
 (0)