-
Notifications
You must be signed in to change notification settings - Fork 2
/
rebuild-unstable
executable file
·113 lines (88 loc) · 2.82 KB
/
rebuild-unstable
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=SC2155
readonly THISDIR=$(dirname "$0")
readonly TIMETAG="$(date +%Y%m%d%H%M)"
readonly PACKAGES=(moulinette SSOwat yunohost yunohost-admin yunohost-portal)
readonly DISTRIBS=(trixie)
readonly FORCE="false"
source "$THISDIR/config/config"
mkdir -p "$LAST_BUILDS_CACHE"
function main()
{
for PACKAGE in "${PACKAGES[@]}"; do
for DISTRIB in "${DISTRIBS[@]}"; do
echo "-------------------------------------"
echo "Looking for update in ${PACKAGE} for ${DISTRIB}... "
build_if_needed "$PACKAGE" "$DISTRIB"
done
done
echo "-------------------------------------"
}
function build_if_needed()
{
local PACKAGE=$1
local DISTRIB=$2
local LAST_BUILD_FOR_THIS_PACKAGE=$LAST_BUILDS_CACHE/${DISTRIB}_${PACKAGE}
[[ $DISTRIB == "bookworm" ]] && BRANCH_NIGHTLY="dev"
[[ $DISTRIB == "trixie" ]] && BRANCH_NIGHTLY="trixie"
cd "$GIT_REPOS/$PACKAGE" || exit 1
git fetch origin >/dev/null 2>/dev/null
git checkout "$BRANCH_NIGHTLY" >/dev/null 2>/dev/null
git pull origin "$BRANCH_NIGHTLY" >/dev/null 2>/dev/null
git reset --hard "origin/$BRANCH_NIGHTLY"
# Check if build is needed
if [ -e "$LAST_BUILD_FOR_THIS_PACKAGE" ]
then
TIMESTAMP_LASTBUILD=$(stat -c %Y "$LAST_BUILD_FOR_THIS_PACKAGE")
else
TIMESTAMP_LASTBUILD=0
fi
TIMESTAMP_HEAD=$(git show -s --format=%ct HEAD)
if [ "$TIMESTAMP_HEAD" -lt "$TIMESTAMP_LASTBUILD" ]
then
if ! "$FORCE";
then
echo "Sources up-to-date, nothing to build."
return
else
echo "Sources up-to-date but forcing build anyway."
fi
fi
VERSION=$(dpkg-parsechangelog -S Version 2>/dev/null)
VERSION_NIGHTLY="${VERSION}+${TIMETAG}"
# Tweak the changelog temporarily
echo "> Setting version in changelog to ${VERSION_NIGHTLY}"
rm -f debian/changelog.dch
cp debian/changelog debian/changelog.old
dch --package "${PACKAGE}" \
--force-bad-version \
-v "${VERSION_NIGHTLY}" \
-D "unstable" \
--force-distribution \
"Daily build." \
> /dev/null 2>&1
head -n 5 debian/changelog
# Launch the build using build_deb script
build
touch "$LAST_BUILD_FOR_THIS_PACKAGE"
# Restore changelog
echo "> Restoring previous changelog"
cd "$GIT_REPOS/$PACKAGE" || exit 1
cp debian/changelog.old debian/changelog
rm debian/changelog.old
}
function build()
{
# Create temporary folder
TMP_FOLDER=$(mktemp -d)
# Move files to a tmp folder
echo "> Exporting in $TMP_FOLDER ... "
git ls-files | xargs tar -czf archive.tar.gz
tar xzf archive.tar.gz -C "$TMP_FOLDER"
rm archive.tar.gz
# Build Debian package
echo "> Starting build ..."
cd "$TMP_FOLDER" || exit 1
$BUILD_DEB "$DISTRIB" "unstable" .
}
main