blob: 126f9cc75a81dc5095e10866bf668f32fbe9cefe (
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
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
|
PkgBase := "ceph"
ChrootPath := env_var("HOME") / "chroot"
ChrootBase := ChrootPath / "root"
ChrootActive := ChrootPath / PkgVer + "_" + PkgRel
Scripts := justfile_directory() / "scripts"
Color := env_var_or_default("USE_COLOR", "1")
Chroot := env_var_or_default("USE_CHROOT", "1")
# Default to listing recipes
_default:
@just --list --list-prefix ' > '
# Build the package in a clean chroot
build:
@$Say Building @{{PkgBuild}} via chroot
makechrootpkg -c -r {{ChrootPath}} -d "/tmp:/tmp" -C -n -l {{PkgVer}}_{{PkgRel}}
# Repackage without rebuilding
repackage:
@$Say Repackaging @{{PkgBuild}} via chroot
makechrootpkg -r {{ChrootPath}} -l {{PkgVer}}_{{PkgRel}} -- --skipint --noprepare --noextract --nocheck --repackage --force
# Run a command in the chroot environment
cexec +args: (_cexec "." args)
# Run ctest in the chroot environment
ctest *args: (_cexec "build" "ctest" args)
# Create and update the base chroot
chroot: (_update_chroot ChrootBase)
# Initialize the base chroot for building packages
mkchroot: (_mkchroot ChrootBase)
# Install required dependencies
deps:
pacman -S base-devel util-linux sudo devtools ripgrep --needed --noconfirm
# Clean one or more of: chroot|deps|artifacts|logs
clean +what="chroot":
#!/usr/bin/env bash
set -euo pipefail
$Say "cleaning directive(s): {{what}}"
for item in {{what}}; do
case $item in
chroot|c)
(set -x; rm -rf {{ChrootActive}})
;;
deps|d)
(set -x; pacman -Rsc devtools --needed --noconfirm)
;;
artifacts|a)
(set -x; rm -vf *tar.*)
;;
logs|l)
(set -x; rm -vf *.log)
;;
*)
$Say unknown clean directive $item, ignoring
;;
esac
done
# Upload built artifacts to Github, using the associated release
upload pkg="@all": (_upload pkg)
# Initialize the chroot
@_mkchroot $cbase:
{{ if path_exists(cbase) == "true" { ":" } else { "$Say Initializing chroot @$cbase" } }}
{{ if path_exists(cbase) == "true" { ":" } else { "mkarchroot $cbase base-devel" } }}
# Update dependencies in the base chroot
@_update_chroot $cbase: (_mkchroot cbase)
$Say Updating chroot packages @$cbase
arch-nspawn $cbase pacman -Syu
# Exec into the chroot to a path relative to the workdir, and run the given args
_cexec path +args:
arch-nspawn {{ChrootActive}} --chdir /build/{{PkgBase}}/src/{{PkgBase}}-{{PkgVer}}/{{path}} sh -c {{quote(trim(args))}}
# Script to upload a comma separated list of packages to the active Github release
_upload $pkgstring:
#!/usr/bin/env bash
set -euo pipefail
[[ -v GITHUB_TOKEN ]] || { $Say "Error: GITHUB_TOKEN must be set" && exit 4; }
IFS=', ' read -r -a PKGS <<<"$pkgstring"
if printf '%s\0' "${PKGS[@]}" | grep -zxqF -- '@all'; then
$Say Expanding '@all' to package set
PKGS=($(rg -P --only-matching --replace '$1' '^package_(.+)\(\) {' {{PkgBuild}} | sort | xargs))
fi
$Say "Uploading ${#PKGS[@]} package(s) to {{GithubRepo}}/releases/v{{PkgVer}}-{{PkgRel}}"
printf ' > %s %s %s %s %s\n' "${PKGS[@]}" | column -t
declare -A FILES
for pkg in "${PKGS[@]}"; do
fname="$pkg-{{PkgVer}}-{{PkgRel}}-{{PkgArch}}.pkg.tar.zst"
[[ -f "$fname" ]] || { $Say "Error: unable to locate artifact '$fname' for '$pkg' upload" && exit 7; }
FILES[$pkg]=$fname
done
for pkg in "${!FILES[@]}"; do
src=${FILES[$pkg]}
mime="$(file -b --mime-type $src)"
dst="${pkg//-/_}_linux_{{PkgArch}}.tar.$(basename $mime)"
$Say "uploading '$src' as '$dst'"
{{Scripts}}.gh-upload-artifact.sh \
${DryRun:+--dry-run} \
--repo {{GithubRepo}} \
--tag v{{PkgVer}}-{{PkgRel}} \
--file "$src:$dst"
done
# ~~~ Global shell variables ~~~
export Say := "echo " + C_RED + "==> " + C_RESET + BuildId
export DryRun := None
export Debug := None
# Nicer name for empty strings
None := ""
# ~~~ Contextual information ~~~
PkgBuild := justfile_directory() / "PKGBUILD"
PkgVer := `awk -F= '/pkgver=/ {print $2}' PKGBUILD`
PkgRel := `awk -F= '/pkgrel=/ {print $2}' PKGBUILD`
PkgArch := 'x86_64'
GitCommitish := if `git tag --points-at HEAD` != None {
`git tag --points-at HEAD`
} else if `git branch --show-current` != None {
`git branch --show-current`
} else {
`git rev-parse --short HEAD`
}
BuildId := "[" + C_YELLOW + PkgBase + C_RESET + "/" + C_GREEN + PkgVer + ":" + PkgRel + C_RESET + "@" + C_CYAN + GitCommitish + C_RESET + "]"
BuildTriple := PkgVer + "-" + PkgRel + "-" + "x86_64"
GithubRepo := "bazaah/aur-ceph"
# ~~~ Color Codes ~~~
C_ENABLED := if Color =~ '(?i)^auto|yes|1$' { "1" } else { None }
C_RESET := if C_ENABLED == "1" { `echo -e "\033[0m"` } else { None }
C_BLACK := if C_ENABLED == "1" { `echo -e "\033[0;30m"` } else { None }
C_RED := if C_ENABLED == "1" { `echo -e "\033[0;31m"` } else { None }
C_GREEN := if C_ENABLED == "1" { `echo -e "\033[0;32m"` } else { None }
C_YELLOW := if C_ENABLED == "1" { `echo -e "\033[0;33m"` } else { None }
C_BLUE := if C_ENABLED == "1" { `echo -e "\033[0;34m"` } else { None }
C_MAGENTA := if C_ENABLED == "1" { `echo -e "\033[0;35m"` } else { None }
C_CYAN := if C_ENABLED == "1" { `echo -e "\033[0;36m"` } else { None }
C_WHITE := if C_ENABLED == "1" { `echo -e "\033[0;37m"` } else { None }
|