forked from GenPi64/Build.Dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
235 lines (222 loc) · 7.64 KB
/
Jenkinsfile
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
pipeline
{
options
{
timestamps()
}
agent { node {
label 'aarch64'
} }
stages { stage('Build') { matrix
{
agent any
axes
{
axis
{
name 'INIT_SYSTEM'
values 'OpenRC', 'Systemd'
}
axis
{
name 'LIBC'
values 'GlibC'
}
axis
{
name 'ARCH'
values 'aarch64'
}
axis
{
name 'LINK_TIME_OPTIMIZATION'
values 'No'
}
axis
{
name 'GENTOO_HARDENED'
values 'No'
}
}
environment
{
PROJECT="GenPi64${INIT_SYSTEM}"
CCACHE_DIR="${HOME}/shared/ccache"
BINPKGS_DIR="${HOME}/shared/binpkgs"
DISTFILES_DIR="${HOME}/shared/distfiles"
OVERLAYS_CACHE_DIR="${HOME}/shared/overlays-cache"
BINARY_ASSETS="${HOME}/shared/binary_assets"
NO_PARALLEL="yes"
def BUILDVERSION = sh(script: "echo `date +%d-%m-%y`", returnStdout: true).trim()
}
stages
{
stage('Clean Up') { steps
{
// Clear out anything from the previous build...
sh "cat /proc/mounts"
sh "for var in ./build/*/image/*; do sudo umount -lfd \$var || sudo umount -ld \$var || sudo umount -l \$var || echo \"\$var not a mount point\"; done"
sh "for var in ./build/*/*; do sudo umount -lfd \$var || sudo umount -ld \$var || sudo umount -l \$var || echo \"\$var not a mount point\"; done"
sh "sudo losetup -all --list --output NAME,BACK-FILE"
sh "for var in \$(sudo losetup -all --list --output NAME,BACK-FILE | grep deleted | cut -f1 -d' '); do losetup -d \$var || echo \"\$(sudo losetup -all --list --output NAME,BACK-FILE | grep \$var) cant be detached\"; done"
sh "sudo losetup -D"
sh "sudo rm -rf ./*"
sh "git checkout ."
}}
stage('Setup') { steps
{
sh "sudo mkdir -p $CCACHE_DIR $BINPKGS_DIR $DISTFILES_DIR $BINARY_ASSETS $OVERLAYS_CACHE_DIR"
}}
stage('Print Environment') { steps
{
// Clear out anything from the previous build...
sh "env"
sh "ls -lah $CCACHE_DIR"
sh "ls -lahR $BINPKGS_DIR"
sh "ls -lahR $DISTFILES_DIR"
sh "ls -lahR $BINARY_ASSETS"
// Will kill the build if doesn't exist otherwise..
sh "ls -lah $OVERLAYS_CACHE_DIR"
}}
stage('Build Lite') { steps
{
// Here we want to only build the gentoo-base.json "subtarget"
// but with the config for the selected init system, libc, and so on
// since that has a big influence on the packages.
sh "sudo --preserve-env ./build.sh"
}}
// matrix blocks cannot be nested inside other matrix blocks...
//matrix
//{
// agent any
// axes
// {
// axis
// {
// name 'PARTITION_TABLE'
// values 'msdos', 'hybrid', 'gpt'
// }
// axis
// {
// name 'BOOT_LOADER'
// values 'raspberrypi', 'grub', 'uefi', 'systemd-boot'
// }
// axis
// {
// name 'INITRAMFS'
// values 'None', 'dracut', 'raspberrypi-initramfs'
// }
// }
// stages
// {
stage('Package Lite') { steps
{
// Here we resume from the end of gentoo-base.json
// and want to launch one job per partition table scheme
// since the on-disk format will be different for each scheme
// we want to use btrfs subvolume snapshotting to give each
// partition type it's own build workspace.
// there *should* be a way to make jenkins dynamically schedule
// a single dimensional matrix of jobs to accomplish this
// so that the runner is fully occupied.
echo "Package Lite"
}}
stage('Upload Lite') { steps
{
sh "ls -lah *"
sh "ls -lah build/*"
sh "sudo --preserve-env ./.ci/scripts/check-filename-is-renamed.sh"
echo "minio(bucket:\"images\", includes:\"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst")
echo "minio(bucket:\"images\", includes:\"bbuild/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum")
echo "minio(bucket:\"images\", includes:\"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.tar.zst\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.tar.zst")
echo "minio(bucket:\"images\", includes:\"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum")
}}
//}
//}
stage('Build Desktop')
{
environment
{
PROJECT="GenPi64${INIT_SYSTEM}Desktop"
}
steps
{
// Here we need to spawn a matrix of jobs that starts from
// the gentoo-base.json for the current init system, libc, and so on
// and produces an image for each desktop varient we offer.
// E.g. xfce, lxqt, so on.
sh "sudo --preserve-env ./build.sh"
}
}
stage('Package Desktop')
{
environment
{
PROJECT="GenPi64${INIT_SYSTEM}Desktop"
}
steps
{
// here we resume from the end of the desktop job and produce an image
// file for each desktop job for each partition type. Ultimately
// producing a matrix of a matrix of a matrix of images.
// we have 5 matrix diminsions for the base image(arch, libc, init, lto, hardened)
// then some number of desktop environments (xfce, lxqt, gnome, kde, so on)
// then 3 potential partition schemes (msdos, hybrid, gpt)
// then 4 potential bootloaders (raspi native (excluded from x86), uefi "native", grub, systemd-boot)
// ultimately culminating in an 8 dimensional matrix of images that we can produce.
// though of course there are big holes in the matrix, and we would only produce images
// that someone is willing to put work into.
echo "Package Desktop"
}
}
stage('Upload Desktop')
{
environment
{
PROJECT="GenPi64${INIT_SYSTEM}Desktop"
}
steps
{
sh "ls -lah *"
sh "ls -lah build/*"
sh "sudo --preserve-env ./.ci/scripts/check-filename-is-renamed.sh"
echo "minio(bucket:\"images\", includes:\"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst")
echo "minio(bucket:\"images\", includes:\"bbuild/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum")
echo "minio(bucket:\"images\", includes:\"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.tar.zst\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.tar.zst")
echo "minio(bucket:\"images\", includes:\"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum\")"
minio(bucket:"images", includes:"build/${PROJECT}/${PROJECT}-${BUILDVERSION}.img.zst.sum")
}
}
stage('Upload binary packages')
{
environment
{
BINPKGS_DIR="${HOME}/shared/binpkgs"
}
steps
{
sh "ls -lah ${BINPKGS_DIR}"
minio(bucket:"binpkgs", includes:"${BINPKGS_DIR}/**")
}
}
}
post { always
{
// Clear out anything from the previous build...
sh "cat /proc/mounts"
sh "for var in ./build/*/image/*; do sudo umount -lfd \$var || sudo umount -ld \$var || sudo umount -l \$var || echo \"\$var not a mount point\"; done"
sh "for var in ./build/*/*; do sudo umount -lfd \$var || sudo umount -ld \$var || sudo umount -l \$var || echo \"\$var not a mount point\"; done"
sh "for var in ./build/*/chroot/var/log/emerge.log; do sudo cat \$var; done"
sh "sudo losetup -all --list --output NAME,BACK-FILE"
sh "for var in \$(sudo losetup -all --list --output NAME,BACK-FILE | grep deleted | cut -f1 -d' '); do losetup -d \$var || echo \"\$(sudo losetup -all --list --output NAME,BACK-FILE | grep \$var) cant be detached\"; done"
sh "sudo losetup -D"
}}
}}}
}