-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsbuild-loop.sh
executable file
·98 lines (81 loc) · 3.04 KB
/
sbuild-loop.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
#!/bin/bash
#
# sbuild-loop.sh: Script for run sbuild and summary result
# Copyright (C) 2017 Toshiba Corporation
#
# 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 of the License, 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 this program. If not, see
# <http://www.gnu.org/licenses/>.
#
#######################################################################
trap "exit" INT
function schroot_cmd {
schroot -c chroot:unstable-amd64-sbuild -d / -u root -- $@
}
JOBS=8
# Get the number of cpus
if [ -d /sys/devices/system/cpu ]; then
JOBS=$(ls -d /sys/devices/system/cpu/cpu[[:digit:]]* | wc -w)
fi
SCHROOT="unstable-amd64-sbuild"
build_profile="${PWD}/build-profile"
disable_parallel_list="${PWD}/disable-parallel"
sbuild_result="${PWD}/sbuild-result"
repo_logfile="${PWD}/repo/logs/logfile"
repo_last_update_date=$(awk '{print $1}' $repo_logfile | tail -1)
last_update_pkgs=$(grep $repo_last_update_date $repo_logfile | awk '{print $8}')
touch $build_profile
touch $sbuild_result
for pkg in $last_update_pkgs; do
dir=`find repo/pool/ -name $pkg`
if [ "$dir" = "" ]; then continue; fi
cd $dir
# Get the latest version of *.dsc
dsc_file=$(find -name "${pkg}_*.dsc" | tail -1)
if [ "$dsc_file" = "" ]; then cd -; continue; fi
ver=`cat $dsc_file | grep "^Version:" | head -1 | cut -d' ' -f2 | sed -e "s/.*://"`
# Get build profile option
profile=`grep "^$pkg " $build_profile | cut -d' ' -f2`
profile_option=""
if [ "$profile" != "" ]; then
profile_option="--profiles=$profile"
fi
# Get parallel option
if grep "^\s*$pkg\s*$" $disable_parallel_list; then
job_option=""
else
job_option="--jobs=$JOBS"
fi
# Clean old files from the previous build
rm -rf *.build *.buildinfo *.udeb *.deb *.changes
# Currently, we're getting error that libgvc6:armhf cannot be remove.
# This makes other packages fail to build. Trick it to be removed by install native package
if schroot_cmd "dpkg -s libgvc6:armhf" 2> /dev/null | grep -q "Status:.*install"; then
schroot_cmd "apt-get install -y libgvc6 libgvc6-plugins-gtk"
schroot_cmd "apt-get remove -y libgvc6 libgvc6-plugins-gtk"
schroot_cmd "apt-get autoremove -y"
fi
# Build
sbuild $job_option $profile_option --host=armhf -d $SCHROOT $dsc_file
# Summary result to file sbuild-result
buildlog=${pkg}_${ver}_armhf.build
output="$pkg $ver $(grep "^Status:" $buildlog | cut -d' ' -f2) $(grep "Finished at" $buildlog|tail -1|sed -e "s/Finished at //")"
cd -
if grep "^$pkg " $sbuild_result; then
sed -i -e "s@^$pkg .*@$output@" $sbuild_result
else
echo $output >> $sbuild_result
fi
done
sort $sbuild_result > ./tmpstatus
mv ./tmpstatus $sbuild_result