-
Notifications
You must be signed in to change notification settings - Fork 44
/
build.preloader
executable file
·113 lines (86 loc) · 2.87 KB
/
build.preloader
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
###set -x
recover_config() {
[ -e ${XBIANROOT}/config.bak ] && mv ${XBIANROOT}/config.bak ${XBIANROOT}/config
}
cd $XBIANROOT
recover_config
[ -e ${XBIANROOT}/config ] || { echo "ERROR: Missing file ${XBIANROOT}/config"; exit 1; }
. ${XBIANROOT}/config
cp -a ${XBIANROOT}/config ${XBIANROOT}/config.bak
if [ -n "$2" ]; then
BRANCH="$2"
fi
if [ -n "$BRANCH" ]; then
export GIT_BRANCH=$BRANCH
fi
GIT_BRANCH=${GIT_BRANCH##*/}
DEST_DEB="/opt/debs"
mkdir -p ${DEST_DEB}
trap "{ recover_config; rm -f ${DEST_DEB}/*.deb; }" EXIT INT ERR
[ -d $1 ] || git clone https://github.com/xbianonpi/$1
cd $1
git fetch --all
git merge origin/master
grep -vE '^\s*$|^#' .autobuild | \
while read B REPOX ARCHX; do
[ "$B" = "$GIT_BRANCH" -o "$GIT_BRANCH" = master ] || continue
BUILD_ONCE='no'
for OS_VERSION in $config_os_versions; do
sed -i -e "s/config_os_version=.*/config_os_version=$OS_VERSION/g" ${XBIANROOT}/config
. ${XBIANROOT}/config
eval REPO="$REPOX"
eval ARCH="$ARCHX"
echo "$ARCHX" | grep -qE '[$]config_os_version|[$]{config_os_version}' && OS_SUPPORT='yes' || OS_SUPPORT='no'
if [ -d "build/$B" ]; then
if [ "$BUILD_ONCE" == 'no' ]; then
rm -f ${DEST_DEB}/*.deb
echo "Running on $(pwd) \$xbiangit --arch $B (config_os_version=$config_os_version)"
$xbiangit --arch $B || exit $?
if ! grep -q "config_build_env=schroot" "build/$B/config" || grep -q "config_build_targets=.*Image.*modules" build/$B/config*; then
BUILD_ONCE='yes'
echo "+++++ BUILD_ONCE +++++"
fi
fi
elif [ -e gen.package.sh ]; then
rm -f ${DEST_DEB}/*.deb
echo "Running on $(pwd) ./gen.package.sh"
./gen.package.sh || exit $?
fi
find . -maxdepth 3 -name \*.deb -exec mv "{}" ${DEST_DEB}/ \;
if [ $(ls -1 ${DEST_DEB} | wc -l) -gt 0 ]; then
if [ "$REPO" = detect ]; then
for lf in $(ls ${DEST_DEB}/*.deb); do
if basename $lf | grep -qi "~rc[0-9]"; then
REPO=staging
elif basename $lf | grep -qiE "~alpha[0-9]|beta[0-9]"; then
REPO=devel
break
else
[ "$REPO" = staging ] || REPO=stable
fi
done
fi
for lf in $(ls ${DEST_DEB}/*.deb); do
lf=$(basename $lf)
echo $lf | grep -q -E '*-[0-9]{10}\.deb' || continue
fbase=${lf%-*.deb}
ftoday="$fbase-$(date --date='today 00:00' +%s).deb"
files=$(echo "ls .incoming.$REPO/$ARCH/${fbase}-*.deb" | sudo sftp -q apt:/web/.upload 2>/dev/null | grep ^\.incoming)
for rf in $files; do
dorm=no
if [ "$REPO" = staging -o "$REPO" = devel ]; then
dorm=yes
elif [[ "$rf" > ".incoming.$REPO/$ARCH/$ftoday" ]]; then
dorm=yes
fi
[ "$dorm" = yes ] || continue
echo "rm $rf" | sudo sftp -q apt:/web/.upload
done
done
${XBIANROOT}/build.upload-apt.sh $REPO $ARCH | sudo sftp apt:/web/.upload
[ "$BUILD_ONCE" == 'no' ] && rm -f ${DEST_DEB}/*.deb || :
fi
[ "$OS_SUPPORT" == 'yes' ] || break
done
done