This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartbuild-holo
executable file
·133 lines (122 loc) · 4.57 KB
/
startbuild-holo
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
#!/bin/bash
BRANCH=""
VERSION=""
ISODIR=""
RCLONEDIR=""
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--branch)
BRANCH="$2"
shift # past argument
shift # past value
;;
--version)
VERSION="$2"
shift # past argument
shift # past value
;;
--isodir)
ISODIR="$2"
shift # past argument
shift # past value
;;
--copy)
RCLONEDIR="$2"
shift # past argument
shift # past value
;;
--debug)
OPTIONS="$2"
shift # past argument
shift # past value
;;
*) # unknown option
echo "Unknown option: $1"
exit 1
;;
esac
done
if [ -z "$ISODIR" ]
then
echo "No profile directory specified. Please provide profile directory using --isodir %dir% option."
exit 1
fi
genvariables(){
git pull && \
sudo umount -fl ~/buildwork/x86_64/airootfs/var/cache/pacman/pkg && \
sudo umount -fl ~/buildwork/x86_64/airootfs/* || /bin/true && \
sudo rm -rf ~/buildwork && \
sudo rm -rf /tmp/archiso* && \
hash=$(echo $RANDOM | md5sum | head -c 10; echo;) && \
hash_build=$(echo $RANDOM | md5sum | head -c 5; echo;) && \
repo_branch=$(git rev-parse --abbrev-ref HEAD) && \
echo "$repo_branch" > /tmp/repobranch_holoiso && \
sudo rm -rf /tmp/*_holoiso && \
echo "$hash" > /tmp/buildhash_holoiso && \
echo "$hash_build" > /tmp/imagehash_holoiso && \
echo "$VERSION" > /tmp/versioninfo_holoiso && \
echo "$BRANCH" > /tmp/buildbranch_holoiso &&
PROJECTNAME=$(cat $ISODIR/profiledef.sh | grep iso_application | cut -d '=' -f 2 | sed 's/\"//g') && \
echo "$PROJECTNAME" > /tmp/build_projectname && \
echo "${PROJECTNAME}_${VERSION}_${repo_branch}-$(date +%Y%m%d)_${hash}_${BRANCH}" > /tmp/isobuildname
rm -rf efiboot/loader/entries/*
echo "Generating boot entries for: $(cat kernel_list.bootstrap)"
bash gen_entries.sh $ISODIR
sleep 5
}
checkupload(){
if [ -z "$RCLONEDIR" ]
then
echo "Note: copy directory wasn't specified. This build will be located in /tmp/archiso-out-$hash after finishing."
exit 1
fi
}
if [ -z "$BRANCH" ] || [ -z "$VERSION" ]
then
echo "Both branch name and version are required. Please provide branch name using --branch %branch% and version using --version %version% options."
exit 1
fi
notifytg_trigger(){
if [[ $(command -v telemsg) ]]; then
if [[ "$OPTIONS" == "print" ]]; then
telemsg "<b>Build has been triggered for:</b> <code>holoiso-$(git rev-parse --abbrev-ref HEAD)_$BRANCH</code>\n\nBranch: <code>$(git rev-parse --abbrev-ref HEAD)</code> \n\n<b>Following was added since 'debug' build was requested.</b> \n\nBuild hash: $(echo -e "#$hash") \n\n<b>Hash:</b> <code>$hash</code> \n<b>Image hash:</b> <code>HOLO_$hash_build</code> \n<b>Version:</b> <code>$VERSION</code> \n<b>Build branch:</b> <code>$BRANCH</code> \n<b>Project name:</b> <code>$PROJECTNAME</code> \n<b>Image filename:</b> <code>$(cat /tmp/isobuildname)-1-x86_64.iso</code>"
else
telemsg "<b>Build has been triggered for:</b> <code>holoiso-$(git rev-parse --abbrev-ref HEAD)_$BRANCH</code> \n\nBranch: <code>$(git rev-parse --abbrev-ref HEAD)</code> \n\nBuild hash: $(echo -e "#$hash")"
fi
else
echo "No CI reporting"
fi
}
notifytg_starting(){
if [[ $(command -v telemsg) ]]; then
telemsg "<b>Starting build for $(echo -e "#$hash") on $(nproc) threads</b> \n\nBuild: <code>holoiso-$(git rev-parse --abbrev-ref HEAD)</code> \n\nImage version: <code>$(date +%Y%m%d)_$(cat /tmp/buildhash_holoiso)$(cat /tmp/buildbranch_holoiso)</code> \n\nExpected image filename: <code>$(cat /tmp/isobuildname)-1-x86_64.iso</code>"
else
echo "No CI reporting"
fi
}
notifytg_finish(){
if [[ $(command -v telemsg) ]]; then
telemsg "<b>Build finished for $(echo -e "#$hash")</b> \nFilename: <code>$(ls /tmp/archiso-out-$hash)</code> \n\nCopying ISO image..."
else
echo "No CI reporting"
fi
}
notifytg_upload(){
if [[ $(command -v telemsg) ]]; then
mcli cp $(find /tmp/archiso-out-$hash | tail -n +2) holoiso/holoiso/$RCLONEDIR && \
telemsg "<b>$(ls /tmp/archiso-out-$hash)</b> \n\nBuild target: $(echo -e "#$hash") \n\nLink: https://cdn.holoiso.ru.eu.org/$RCLONEDIR/$(ls /tmp/archiso-out-$hash)"
else
echo "No CI reporting and build uploading."
fi
}
# Actual build progress itself
cd $ISODIR && \
genvariables && \
checkupload && \
notifytg_trigger && \
notifytg_starting && \
sudo mkarchiso-holoiso -v -w ~/buildwork -o /tmp/archiso-out-$hash $ISODIR && \
notifytg_finish && \
notifytg_upload && rm -rf efiboot/loader/entries/* && cd -