Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/.gitlab/ci/build-inside-vm.sh
blob: 8e433b19e68801ecbc8de69a51fdefa3455a1bcb (plain)
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
#!/usr/bin/env bash
#
# This script is run within a virtual environment to build the available archiso profiles and create checksum files for
# the resulting images.
# The script needs to be run as root and assumes $PWD to be the root of the repository.

readonly orig_pwd="${PWD}"
readonly output="${orig_pwd}/output"
tmpdir=""
tmpdir="$(mktemp --dry-run --directory --tmpdir="${orig_pwd}/tmp")"

cleanup() {
  # clean up temporary directories
  if [ -n "${tmpdir:-}" ]; then
    rm -rf "${tmpdir}"
  fi
}

create_checksums() {
  # create checksums for a file
  # $1: a file
  sha256sum "${1}" >"${1}.sha256"
  sha512sum "${1}" >"${1}.sha512"
  b2sum "${1}" >"${1}.b2"
  if [[ -n "${SUDO_UID:-}" ]] && [[ -n "${SUDO_GID:-}" ]]; then
    chown "${SUDO_UID}:${SUDO_GID}" "${1}"{,.b2,.sha{256,512}}
  fi
}

create_zsync_delta() {
  # create a zsync control file for a file
  # $1: a file
  zsyncmake -C -u "${1##*/}" -o "${1}".zsync "${1}"
  if [[ -n "${SUDO_UID:-}" ]] && [[ -n "${SUDO_GID:-}" ]]; then
    chown "${SUDO_UID}:${SUDO_GID}" "${1}".zsync
  fi
}

run_mkarchiso() {
  # run mkarchiso
  # $1: template name
  mkdir -p "${output}/${1}" "${tmpdir}/${1}"
  ./archiso/mkarchiso -o "${output}/${1}" -w "${tmpdir}/${1}" -v "configs/${1}"
  create_checksums "${output}/${1}/"*.iso
  create_zsync_delta "${output}/${1}/"*.iso
}

trap cleanup EXIT

run_mkarchiso "${1}"