1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 gitUpdater,
6 makeWrapper,
7 pkg-config,
8 file,
9 scdoc,
10 openssl,
11 zlib,
12 busybox,
13 apk-tools,
14 perl,
15 findutils,
16}:
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "abuild";
20 version = "3.15.0";
21
22 src = fetchFromGitLab {
23 domain = "gitlab.alpinelinux.org";
24 owner = "alpine";
25 repo = "abuild";
26 tag = finalAttrs.version;
27 hash = "sha256-vHRh36igfb6WZ8JdtxW8OOqgiVBAXreTy+QOOKaWEwA=";
28 };
29
30 buildInputs = [
31 openssl
32 zlib
33 busybox
34 # for $out/bin/apkbuild-cpan and $out/bin/apkbuild-pypi
35 (perl.withPackages (
36 ps: with ps; [
37 LWP
38 JSON
39 ModuleBuildTiny
40 LWPProtocolHttps
41 IPCSystemSimple
42 ]
43 ))
44 ];
45
46 nativeBuildInputs = [
47 pkg-config
48 scdoc
49 makeWrapper
50 file
51 findutils
52 ];
53
54 patchPhase = ''
55 substituteInPlace ./Makefile \
56 --replace 'chmod 4555' '#chmod 4555' \
57 --replace 'pkg-config' "$PKG_CONFIG"
58 '';
59
60 makeFlags = [
61 "prefix=${placeholder "out"}"
62 "CFLAGS=-Wno-error"
63 ];
64
65 installFlags = [
66 "sysconfdir=${placeholder "out"}/etc"
67 ];
68
69 postInstall = ''
70 # this script requires unpackaged 'augeas' rubygem, no reason
71 # to ship it if we can't provide the dependencies for it
72 rm -f ${placeholder "out"}/bin/apkbuild-gem-resolver
73
74 # Find all executables that are not compiled binaries and wrap
75 # them, make `apk-tools` available in their PATH and also the
76 # $out directory since many of the binaries provided call into
77 # other binaries
78 for prog in \
79 $(find ${placeholder "out"}/bin -type f -exec ${file}/bin/file -i '{}' + \
80 | grep -v x-executable | cut -d : -f1); do
81 wrapProgram $prog \
82 --prefix PATH : "${lib.makeBinPath [ apk-tools ]}" \
83 --prefix PATH : "${placeholder "out"}/bin"
84 done
85 '';
86
87 passthru.updateScript = gitUpdater { };
88
89 meta = {
90 description = "Alpine Linux build tools";
91 homepage = "https://gitlab.alpinelinux.org/alpine/abuild";
92 license = lib.licenses.gpl2Plus;
93 maintainers = with lib.maintainers; [ onny ];
94 platforms = lib.platforms.unix;
95 };
96})