blob: 8454d2f443f6b51fbe5c0f716368b770f3af01f8 (
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
|
{
description = "Native Arch Linux test runner for the jfsh AUR package";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
testPackage = pkgs.writeShellApplication {
name = "test-jfsh-aur";
runtimeInputs = [ pkgs.podman ];
text = ''
if [[ ! -f PKGBUILD || ! -f .SRCINFO ]]; then
echo "Run this command from the jfsh AUR repository root." >&2
exit 1
fi
exec podman run \
--signature-policy ${pkgs.writeText "policy.json" ''
{
"default": [
{
"type": "insecureAcceptAnything"
}
]
}
''} \
--rm \
--pull=always \
--mount "type=bind,source=$PWD,target=/pkg,readonly" \
--mount "type=volume,source=jfsh-aur-pacman-cache,target=/var/cache/pacman/pkg" \
docker.io/library/archlinux:base-devel \
bash -euxo pipefail -c '
useradd --create-home builder
install -d -o builder -g builder /build
cp -a /pkg/. /build/
chown -R builder:builder /build
source /build/PKGBUILD
pacman -Syu --noconfirm --needed \
devtools \
namcap \
shellcheck \
"''${depends[@]}" \
"''${makedepends[@]}"
runuser -u builder -- bash -c \
"cd /build && pkgctl license check"
runuser -u builder -- bash -c \
"cd /build && shellcheck --shell=bash --exclude=SC2034,SC2154,SC2164 PKGBUILD"
diff -u /build/.SRCINFO \
<(runuser -u builder -- bash -c "cd /build && makepkg --printsrcinfo")
find /build -maxdepth 1 -type f -name "*.pkg.tar.*" -delete
export SOURCE_DATE_EPOCH=946684800
runuser -u builder -- bash -c \
"cd /build && makepkg --cleanbuild --clean"
first_packages="$(mktemp -d)"
cp /build/*.pkg.tar.zst "$first_packages/"
runuser -u builder -- bash -c \
"cd /build && makepkg --cleanbuild --clean --force"
for package in /build/*.pkg.tar.zst; do
cmp "$package" "$first_packages/$(basename "$package")"
done
# namcap cannot resolve cross-package symlinks in split debug packages.
namcap /build/PKGBUILD /build/"$pkgname"-[0-9]*.pkg.tar.zst \
| tee /tmp/namcap.log
if grep -q " E: " /tmp/namcap.log; then
exit 1
fi
pacman -U --noconfirm /build/*.pkg.tar.zst
expected_version="$(
runuser -u builder -- bash -c \
"cd /build && source PKGBUILD && printf %s \"\$pkgver\""
)"
jfsh --version 2>&1 | grep -F "version $expected_version"
'
'';
};
in
{
packages.${system}.test = testPackage;
apps.${system} = rec {
default = test;
test = {
type = "app";
program = "${self.packages.${system}.test}/bin/test-jfsh-aur";
meta.description = "Test the jfsh package in a disposable Arch Linux container";
};
};
devShells.${system}.default = pkgs.mkShell {
packages = [
pkgs.podman
testPackage
];
};
};
}
|