Updated build system to respect repo arch settings
parent
7eab7afa98
commit
8ecac2ff28
|
@ -4,11 +4,14 @@ import docker
|
||||||
import encoding.base64
|
import encoding.base64
|
||||||
import time
|
import time
|
||||||
import git
|
import git
|
||||||
|
import os
|
||||||
|
|
||||||
const container_build_dir = '/build'
|
const container_build_dir = '/build'
|
||||||
|
|
||||||
const build_image_repo = 'vieter-build'
|
const build_image_repo = 'vieter-build'
|
||||||
|
|
||||||
|
const base_image = 'archlinux:latest'
|
||||||
|
|
||||||
fn create_build_image() ?string {
|
fn create_build_image() ?string {
|
||||||
commands := [
|
commands := [
|
||||||
// Update repos & install required packages
|
// Update repos & install required packages
|
||||||
|
@ -26,7 +29,7 @@ fn create_build_image() ?string {
|
||||||
cmds_str := base64.encode_str(commands.join('\n'))
|
cmds_str := base64.encode_str(commands.join('\n'))
|
||||||
|
|
||||||
c := docker.NewContainer{
|
c := docker.NewContainer{
|
||||||
image: 'archlinux:latest'
|
image: base_image
|
||||||
env: ['BUILD_SCRIPT=$cmds_str']
|
env: ['BUILD_SCRIPT=$cmds_str']
|
||||||
entrypoint: ['/bin/sh', '-c']
|
entrypoint: ['/bin/sh', '-c']
|
||||||
cmd: ['echo \$BUILD_SCRIPT | base64 -d | /bin/sh -e']
|
cmd: ['echo \$BUILD_SCRIPT | base64 -d | /bin/sh -e']
|
||||||
|
@ -60,27 +63,34 @@ fn create_build_image() ?string {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(conf Config) ? {
|
fn build(conf Config) ? {
|
||||||
// We get the repos list from the Vieter instance
|
build_arch := os.uname().machine
|
||||||
repos := git.get_repos(conf.address, conf.api_key) ?
|
|
||||||
|
// We get the repos map from the Vieter instance
|
||||||
|
repos_map := git.get_repos(conf.address, conf.api_key) ?
|
||||||
|
|
||||||
|
// We filter out any repos that aren't allowed to be built on this
|
||||||
|
// architecture
|
||||||
|
filtered_repos := repos_map.keys().map(repos_map[it]).filter(it.arch.contains(build_arch))
|
||||||
|
|
||||||
// No point in doing work if there's no repos present
|
// No point in doing work if there's no repos present
|
||||||
if repos.len == 0 {
|
if filtered_repos.len == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, we create a base image which has updated repos n stuff
|
// First, we create a base image which has updated repos n stuff
|
||||||
image_id := create_build_image() ?
|
image_id := create_build_image() ?
|
||||||
|
|
||||||
for _, repo in repos {
|
for repo in filtered_repos {
|
||||||
// TODO what to do with PKGBUILDs that build multiple packages?
|
// TODO what to do with PKGBUILDs that build multiple packages?
|
||||||
commands := [
|
commands := [
|
||||||
'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo',
|
'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo',
|
||||||
'cd repo',
|
'cd repo',
|
||||||
'makepkg --nobuild --nodeps',
|
'makepkg --nobuild --nodeps',
|
||||||
'source PKGBUILD',
|
'source PKGBUILD',
|
||||||
// The build container checks whether the package is already present on the server
|
// The build container checks whether the package is already
|
||||||
'curl --head --fail $conf.address/\$pkgname-\$pkgver-\$pkgrel-\$(uname -m).pkg.tar.zst && exit 0',
|
// present on the server
|
||||||
'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/publish; done',
|
'curl --head --fail $conf.address/$repo.repo/$build_arch/\$pkgname-\$pkgver-\$pkgrel-${build_arch}.pkg.tar.zst && exit 0',
|
||||||
|
'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/$repo.repo/publish; done',
|
||||||
]
|
]
|
||||||
|
|
||||||
// We convert the list of commands into a base64 string, which then gets
|
// We convert the list of commands into a base64 string, which then gets
|
||||||
|
|
Loading…
Reference in New Issue