Compare commits

...

227 Commits

Author SHA1 Message Date
Sertonix b274749838 abuild: fix --xattrs and --{owner,group}-map not passed to tar
Fixes <45a8c0dd79c> abuild: deduplicate reproducible tarball creation
2024-10-24 16:44:05 +02:00
Natanael Copa 8c47dfcfb1 ==== release 3.14.1 ==== 2024-10-22 16:39:08 +02:00
Natanael Copa 5fcf74eafe Reapply "tests: remove 'test package' comment"
This reverts commit 96d53109ac.
2024-10-18 11:34:15 +02:00
Natanael Copa 443b976f44 Revert "Prefer maintainer field instead of Maintainer comment"
This reverts commit 34ef9de98f.
2024-10-18 11:30:30 +02:00
Natanael Copa 96d53109ac Revert "tests: remove 'test package' comment"
This reverts commit 35b6b30134.
2024-10-18 11:30:28 +02:00
Natanael Copa 4e2c190257 ==== release 3.14.0 ==== 2024-10-15 14:35:53 +02:00
Sertonix 6e5cb0cfc1 abuild: fix go not creating GOTMPDIR on it's own
Fixes #10156
2024-10-14 06:04:18 +00:00
Kaarle Ritvanen 706067d09a fix rootbld by adding a missing backslash
This fixes a regression in commit a7e7587758.
2024-10-13 18:20:11 +03:00
Kaarle Ritvanen a1c8cae8da add mailmap 2024-10-13 18:14:39 +03:00
Natanael Copa 74cfbbbcf4 test: add test for -libs subpackage 2024-10-10 19:36:14 +02:00
Sertonix 47ca28b3c9 abuild: fix default_libs 2024-10-10 19:25:34 +02:00
Natanael Copa ce2ba1b169 ==== release 3.14.0_rc2 ==== 2024-10-10 16:35:58 +02:00
Sertonix 2733e40c62 test: increase default timeout
The CI started to fail cause of test timeout sometimes.
2024-10-10 14:35:04 +00:00
Natanael Copa 6ebe375a3e abuild: validate versioned dependencies 2024-10-10 13:41:18 +00:00
Natanael Copa ca9a11e492 tests: add test for validating depends 2024-10-10 13:41:18 +00:00
Sertonix d5591e6ccf samples: modernize and improve 2024-10-10 13:13:26 +00:00
fossdd a732ae00a1 abuild: run apk add/del with --no-interactive 2024-10-10 13:11:51 +00:00
Sertonix 1d9568b669 abuild: fix eval argument splitting and simplify
A newline starts a new command in shell scripts and eval uses the shell
grammar. Use a space instead to fix multiline repo templates.

Also avoid one subshell.
2024-10-10 14:48:33 +02:00
Pablo Correa Gómez 9c4abc561e
abuild: don't set the error on throwing a warning
Fixes da9269ba62
2024-10-10 14:20:47 +02:00
Natanael Copa fd7fa8a124 ==== release 3.14.0_rc1 ==== 2024-10-10 14:03:25 +02:00
Sertonix 186edf62a8 abuild: fix usrmerge warning with symlinks
Fixes <da9269ba62b> abuild: warn when files are installed to non-usr locations
2024-10-09 14:11:16 +00:00
Sertonix 35b6b30134 tests: remove 'test package' comment
These comments don't have any purpose. They just take up space.
2024-10-09 14:09:09 +00:00
Sertonix 34ef9de98f Prefer maintainer field instead of Maintainer comment
Fixes #10147
2024-10-09 14:09:09 +00:00
Sertonix cb4c8e40fb default.conf: move commented out options to abuild.conf 2024-10-09 14:09:09 +00:00
Sertonix 5a5df023cb abuild: remove .dummy file from empty packages 2024-10-09 12:42:10 +02:00
Sertonix 45a8c0dd79 abuild: deduplicate reproducible tarball creation 2024-10-09 12:42:10 +02:00
Sertonix 43ca11764a abuild: avoid shell splitting when packing metafiles 2024-10-09 12:39:52 +02:00
Sertonix 3fa9fda05b avoid masking exit code of shell commands
When a variables is declared (with 'local' or 'export') a failing
command is ignored[0]. Changing that so abuild should now error out
properly in more cases.

Also remove 1 pipe that could have prevented an issue recently[1] where
the 'du' command core dumped but abuild didn't error.

The other pipes were not changed for now since it may be better to use
'set -o pipefail' instead. That may require some changes with commands
like grep which use a non-zero exit code to indicate if a match was
found or similar[2].

[0]: https://www.shellcheck.net/wiki/SC2155
[1]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16005#note_395899
[2]: https://github.com/koalaman/shellcheck/issues/665
2024-10-09 10:00:07 +00:00
Sertonix b3b659a9f4 test: fix BSD-4-Clause license name 2024-10-09 09:58:53 +00:00
Sertonix d7208fa0c2 test: simplify usermerge test APKBUILD 2024-10-09 09:58:53 +00:00
Sertonix 78ae5e9386 abuild: remove origsubpackages
boost1.82 which used this variable has been removed
2024-10-08 11:30:19 +00:00
Natanael Copa cd78cd5da2 Rename sanitycheck -> validate
The term validate/validation is better than sanity/sane.
2024-10-08 11:56:47 +02:00
Bart Ribbers da9269ba62 abuild: warn when files are installed to non-usr locations
As agreed upon by the TSC:
https://gitlab.alpinelinux.org/alpine/tsc/-/blob/master/minutes/2024-08-15.md?ref_type=heads#implement-usr-merge-73
Should be changed to an error once some core packages are adjusted.
2024-10-07 20:58:53 +00:00
Sertonix 06695133c9 abuild: preserve attributes without setfattr/getfattr
The setfattr/getfattr commands were not guaranteed to be available and
abuild wouldn't properly error when they are not. That may cause some
hidden issues.

Changing the code to not need setfattr/getfattr like it is done in
default_dbg ([3ad93d9a83]) and pacman mkpkg ([pacman@88d054093c1]).

The code works by first writing the stripped output into a temporary file
and then replace the contents of the already existing file without changing
any file metadata.

[3ad93d9a83]: 3ad93d9a83
[pacman@88d054093c1]: 88d054093c
2024-10-07 20:56:49 +00:00
Hugo Osvaldo Barrera b3b42ae177 Link to buildrepo(1) in APKBUILD(5) and abuild(1)
Add a reference in the SEE ALSO section. Improves discoverability of
this tool for newcomers.

See: https://gitlab.alpinelinux.org/alpine/lua-aports/-/merge_requests/16
2024-10-07 20:53:44 +00:00
Sertonix e36e92c6f2 abuild: calculate size only based on st_size of normal files
Fixes [#10134]

[#10134]: https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10134
2024-10-07 20:53:10 +00:00
Sertonix ae059fd558 abuild: drop support for md5 and sha1 checksums 2024-10-07 20:52:19 +00:00
Sertonix bf66ab6312 abuild: drop special linguas variable 2024-10-07 20:51:19 +00:00
Sertonix 18340ddd42 default.conf: reduce duplication through default.conf
By setting some environmental variables in default.conf we can reduce the
amount of duplicated code needed in APKBUILDs.
2024-10-07 20:31:45 +00:00
Tyler Amick 75a6e8e14c make: add depends for abuild-tar.static 2024-10-07 20:27:42 +00:00
Sertonix c1c233a45a abuild-tar: drop legacy checksum mechanism
This mechanism was an optional speed optimization for apk-tools which has
been replaced with a better one **before the 2.0 full release** of apk-tools.

This in combination with the fact that the code is endian dependant and
therefor is incompatible with reproducible builds seems enough reason to
remove the code.
2024-10-07 20:27:00 +00:00
Sertonix a7e7587758 abuild: use static srcdir/pkgbasedir/tmpdir in rootbld
This fixes 'abuild rootbld' failing to mount when srcdir is moved
outside of $HOME (eg. in /run). This also has the advantage of building
more reproducible even when the build path leaks into the packges (which
happens in most -dbg packages).
2024-10-07 20:10:16 +00:00
Sertonix 1131a46699 abuild: remove default CC and CXX
These variables are already set by functions.sh.
2024-10-07 20:09:13 +00:00
Dominique Martinet d9f3f05b50 checkapk: fix size difference output when multiple info matches
I rebuilt networkmanager locally and was greeted with this:
>>> Size difference for networkmanager: 16 MiB -> 2772 KiB

It turns out networkmanager-elogind provides networkmanager so apk info
will list both, and the former is much bigger so it looked like the
rebuilt package was much smaller when there was almost no difference (as
expected)

Fix by matching on exact package name for both lines; this is already
what we were doing with the local package anyway and the apk fetch
correctly picks the correct package in this case
2024-10-07 20:07:31 +00:00
Sertonix d235d5c5a4 newapkbuild: fix meson setup argument order
according to the meson documentation the arguments are
'meson setup <builddir> <srcdir>'. meson is very relaxed and allows the
wrong order but this behavior should not be endorsed by a template.
2024-10-07 20:04:40 +00:00
Sertonix dd66d17b49 abuild: fix object files detected as shared libs
dmd installs an object file that matches *.so.* so we need to check for
*.o explicitly.
2024-10-07 20:03:13 +00:00
Sertonix ac45be0c71 abuild: strip leading v from pkgconfig versions 2024-10-07 20:03:13 +00:00
Sertonix d85ea24eca abuild: remove host uid/gid from pkg
Closes https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10127
2024-10-07 20:02:01 +00:00
Sertonix 0a91a31e47 abuild: kill all childs when bwrap exits
--unshare-pid is needed for --die-with-parent to work correctly.

Ref https://github.com/containers/bubblewrap/issues/529
2024-10-07 20:00:04 +00:00
Hugo Osvaldo Barrera 8eaa065f3a Add a man page for abuild.conf
For those familiar with abuild all this content is obvious. For
newcomers, the only way to figure this out is by reading abuild's
source code.
2024-10-07 19:58:50 +00:00
Hugo Osvaldo Barrera 5cae4119f9 Document some environment variables for abuild 2024-10-07 19:58:50 +00:00
Sertonix c8fb8965fc newapkbuild: add instructions when there is no check/build command 2024-10-07 19:55:23 +00:00
Willow Barraco ca9bc0a9e9 abuild: add default_nftrules helper
As proposed here:

https://gitlab.alpinelinux.org/alpine/aports/-/issues/16177
2024-10-07 19:52:15 +00:00
Dmitry Klochkov 15b9496135 abuild-fetch: try to work around an ESTALE error which occurs on NFS
This is because of the following race condition case:

  A                               B
                                |
  lockfd = open(lockfile, ...)  |
                                | unlink(lockfile)
  lockf(lockfd, F_LOCK, 0)      |

According to [1], to recover from an ESTALE error, an application must
close the file or directory where the error occurred, and reopen it so
the NFS client can resolve the pathname again and retrieve the new file
handle.

[1] https://nfs.sourceforge.net/#faq_a10
2024-10-07 19:50:19 +00:00
Sertonix 2fbfb5e700 tests: fix with changed ABUILD_USERDIR
The test suite expects ABUILD_USERDIR to be "$HOME"/.abuild but that
could be overwritten in ABUILD_CONF. So use the fixed value instead of
relying on the default.
2024-10-07 19:43:12 +00:00
Sertonix 59be83ca19 functions.sh: overwrite ABUILD_USERDIR from env
To be consistent with other variables ABUILD_USERDIR set from the
environment should be prefered over ABUILD_USERDIR set by the
ABUILD_CONF file.
2024-10-07 19:43:12 +00:00
Sertonix f8d9a6f1b5 abuild: simplify 'Entering fakeroot' message 2024-10-07 19:41:56 +00:00
Sertonix 18eeb336a2 abuild: remove CBUILDROOT check for cross_*
CBUILDROOT is guaranteed to be set by functions.sh when
CHOST != CTARGET or CBUILD != CHOST.
2024-10-07 19:41:00 +00:00
Sertonix 88fab9f624 abuild: detect precompiled lua files
Precompiled lua files aren't portable between word sizes and byte order.
2024-10-07 19:37:16 +00:00
Sertonix 2ea6d3c734 abuild: remove empty check before for loop
When the variable is empty the body of the for loop will never be run.
So the behaviour is the same without the extra check if the variable is
empty.
2024-10-07 19:35:31 +00:00
Hugo Osvaldo Barrera c3f021f2b4 abuild: add missing params flags in docs 2024-10-07 19:32:31 +00:00
Sertonix a417fd27fc abuild: update -r doc 2024-10-07 19:25:19 +00:00
Sertonix 87e8792b8c abuild: clean unused and global variables 2024-10-07 19:24:49 +00:00
Sertonix 8b1304f343 abuild: improve and test shell_escape 2024-10-07 19:22:28 +00:00
Sertonix 1b253a9210 Makefile: simplify install and fix exec permissions 2024-10-07 19:20:11 +00:00
Sertonix e236b4b854 abuild: use amove more often 2024-10-07 19:17:35 +00:00
Sertonix 98dd63bf11 abuild: improve amove
- fix multiple trailing and leading /
- continue moving after error
2024-10-07 19:17:35 +00:00
Sertonix f12f4dde1a abuild: simplify shell completion checks 2024-10-07 19:13:54 +00:00
Sertonix 76e82bfb52 abuild: add cmd:* providers for symlinks 2024-10-07 19:10:26 +00:00
Hugo Osvaldo Barrera 520641dea7 abuild: document the default command, "all"
Document the expansion of the default command. This is mostly useful for
someone wanting to run _most_ commands while omitting specific ones.
2024-10-07 19:08:33 +00:00
Dimitri John Ledkov 97feb61bee
abuild-sign: rename type variable to sigtype for clarity 2024-04-29 12:22:23 +01:00
Dimitri John Ledkov b10f1c5394
abuild: remove unused variable sign 2024-04-29 12:18:05 +01:00
Dimitri John Ledkov f4ea93f5f2
abuild-sign: add support for RSA256 signatures
Supported by apk-tools since v2.7.0 (2017).
2024-04-29 12:03:08 +01:00
Piraty a45d12d4c3
abuild-rootbld: copy SRCDEST value from host to chroot
Otherwise the default hardcoded in abuild-fetch (var/cache/distfiles) is
used.

(in the same vein as 6864df03aa)

Fixes: 1582617 ("abuild-rootbld: clear environment for bwrap container")
2024-04-26 00:24:09 +02:00
Natanael Copa 68d6aa65f4 abuild: skip /var/run in fhs check
We have many package containing directories under /var/run. Allow those
for now.

Partially reverts commit 08d2d81587 (abuild: extend fhs check)
2024-04-21 10:37:44 +02:00
Natanael Copa c48f8498e7 abuild: allow packages to install under run
I have some vauge memory that it is conveinent for Docker users that the
state dir under /run exists.

Allow this for alpine 3.20 and revisit later.
2024-04-20 08:20:18 +02:00
Natanael Copa eeca95d195 abuild: pass APORTS_BOOTSTRAP to bubblewrap 2024-04-19 23:41:45 +02:00
Natanael Copa 5023838d60 ==== release 3.13.0 ==== 2024-04-17 08:45:34 +02:00
Natanael Copa 7e7b0a5ba3 tests: increase timeout for abuild-fetch to call curl
The CI may be under load.
2024-04-17 08:40:47 +02:00
Natanael Copa 645c3c07a7 abuild: exclude provides for commans with @
the '@' characted serves as a repository separator (eg. pkg@repo) so we
should not add a cmd: provides for binaries having this character.

This avoids conflicts with for example `who` from coreutils and `who@`
from ucspi-tpc6.

fixes https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10074
2024-04-17 08:35:27 +02:00
Natanael Copa e4896c01b8 test: inline bin-in-path APKBUILD
Improves readability. No functional changes
2024-04-17 08:21:40 +02:00
Sertonix 54fd3e4117 abump: preserve in-line comments after pkgver/pkgrel
Fixes [#10133]

[#10133]: https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10133
2024-04-12 11:59:56 +00:00
Sertonix 855992822d abuild: update cachedir logic for rootbld
Closes [#10111]

[#10111]: https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10111
2024-04-12 11:59:04 +00:00
Sertonix 7276042237 abuild: always use $APK instead of apk 2024-04-12 11:59:04 +00:00
Sertonix 6aa8fcc012 abuild: remove libc specific logic
Last use of the '!libc_*' option has been removed in [61cb57cda98].
libpthread special casing only triggers on uclibc.

[61cb57cda98]: https://git.alpinelinux.org/aports/commit/?id=61cb57cda98923032f7ff15f7a0f057bb35aae6d
2024-04-12 11:56:05 +00:00
Sertonix 20b1f47c63 abuild: fix ~ splitting pkgname and pkgver 2024-04-12 11:51:48 +00:00
Sertonix 0e325a2354 abuild: fix python3 depending on python3 2024-04-03 14:09:03 +02:00
Natanael Copa 22e17446f7 Revert "checkapk: Check how many packages depend on a previous soname"
The implementation is difficult to get right. Keep checkapk simple.
Fixes https://gitlab.alpinelinux.org/alpine/abuild/-/merge_requests/229

This reverts commit acfa7d6732.
2024-03-29 12:19:20 +01:00
Sertonix 141da52d19 abuild: warn on go packages without net option 2024-03-29 11:15:43 +00:00
Sertonix 21b5a2298d abuild: fix help message 2024-03-29 11:14:35 +00:00
Sertonix 20c0a15856 functions.sh: fix ABUILD_USERDIR overwrite in ABUILD_CONF 2024-03-29 11:14:35 +00:00
Sertonix 1804361f61 abuild: error on digit+letter+digit version format 2024-03-29 11:12:51 +00:00
Sertonix f0051d2658 doc: document replaces_priority 2024-03-28 22:43:42 +00:00
Hugo Osvaldo Barrera d65a054bc5 Add a man page for abump 2024-03-28 22:42:43 +00:00
Sertonix 17648366cc abuild: invalidate pkgver ending with -r# 2024-03-28 22:41:30 +00:00
Sertonix 2e27c5b202 abuild: sanitycheck pkgver regardless of -d flag 2024-03-28 22:41:30 +00:00
Sertonix a9053617db abuild: stricter pkgname check 2024-03-28 22:40:14 +00:00
Sertonix 73cc75b3e0 abuild: amove: allow spaces in pattern 2024-03-28 18:40:25 +00:00
Sertonix 08d2d81587 abuild: extend fhs check 2024-03-27 14:53:58 +01:00
Timo Teräs ec11f495cd abuild: add an option to keep all directories
This is mainly needed for alpine-baselayout which creates all
directories, and most of them are empty. The code in question
would remove directories we explicitly want alpine-baselayout
to create and own.
2024-03-22 21:56:14 +02:00
Sertonix 8588378efa checkapk: new arch can cause old apk missing 2024-03-13 11:14:34 +00:00
Hugo Osvaldo Barrera 2e987e10ff Remove deprecated option from abuild man page
Using this flag yields:

  >>> ERROR: : Use newapkbuild to create new aports
2024-03-13 11:12:15 +00:00
Natanael Copa 8da2501613 abuild: warn for more version suffixes
give a warning when version suffix a<digit>/b<digit> probably should be
_alpha<digit>/_beta<digit>.

ref: https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10972#note_380899
2024-03-13 11:57:50 +01:00
Sertonix 648529aa35 abuild: remove duplicate SOURCE_DATE_EPOCH from .PKGINFO 2024-03-06 13:05:10 +00:00
Sertonix f63c117df6 abuild: avoid variables in sed pattern 2024-03-05 11:59:10 +00:00
Jingyun Hua e3ba1238d3 abuild.in: update autoconf test for loongarch64 2024-03-05 11:56:33 +00:00
Hugo Osvaldo Barrera 1861b23f0c Remove --recursive from abump --help
This flag does not exist.
2024-03-05 11:27:52 +00:00
Hugo Osvaldo Barrera 06ee1d3cfb .editorconfig: add yml rules
While editing .gitlab-ci.yml, my editor kept indenting to tabs due to
the override for [*]. This retains the existing style.
2024-03-05 11:03:27 +00:00
Celeste 19bebd8497 apkbuild-cpan.in: use distribution name cached in %distfiles
instead of sending a duplicate query to metacpan

follow up from what was done in
e448c9a452
2024-03-05 11:01:27 +00:00
Timothy Legge 5710eefb63 apkbuild-cpan.in: remove perl-dev package wherever it occurs
if the package does not have any xs files and the old APKBUILD data is used

The regex to get perl-dev wherever it might occur was breaking my head
2024-03-05 11:01:27 +00:00
Timothy Legge b0fb5c7038 apkbuild-cpan.in: don't add perl-dev if its not needed on recreate 2024-03-05 11:01:27 +00:00
Sertonix 4ae1b39910 abuild: fix quote handling in check_license 2024-02-12 12:39:17 +01:00
Celeste 39c2b44c63 apkbuild-pypi.in: add option to use project homepage as url=
instead of pypi.org page
2024-02-02 02:51:27 +00:00
Celeste 9e336571e1 apkbuild-pypi.in: fixes #10129 move _pkgreal and comment
this makes it easier to see the maintainer line in
an unexpanded diff that shows a three-line context
2024-02-02 02:51:27 +00:00
Celeste 49983f5af5 apkbuild-pypi.in: fix a number of uninitialized value warnings 2024-02-02 02:51:27 +00:00
Celeste fb262fad5e apkbuild-pypi.in: redefine builddir if not based on $_pkgreal 2024-02-02 02:51:27 +00:00
Celeste db578302aa apkbuild-pypi.in: clean up read_assignments_from_file
also, keep the comment associated with provides & replaces, and
return early to avoid running APKBUILD-specific regex matches
2024-02-02 02:51:27 +00:00
Celeste bc4efd7f0c apkbuild-pypi.in: keep options and patches (copied from apkbuild-cpan)
thanks @timlegge for working out how to make this work in apkbuild-cpan
2024-02-02 02:51:27 +00:00
Celeste 9b513da2f4 apkbuild-pypi.in: keep old dependencies during recreate
unless py3-gpep517 or py3-pytest is missing, then
add that in as the template generated uses it.

To force dependencies to be recalculated, use
`recreate deps`.
2024-02-02 02:51:27 +00:00
Celeste a9e956dc16 apkbuild-pypi.in: move requires_dist parsing code to its own function
also, use regex from https://peps.python.org/pep-0508/#names
to parse valid pypi package names in requires_dist
2024-02-02 02:51:26 +00:00
Celeste 9e416f782a apkbuild-pypi.in: keep old license, url, pkgname/desc during recreate 2024-02-02 02:51:26 +00:00
Celeste d05bc1a4af apkbuild-pypi.in: change position of replaces/provides in template
Most Python aports put replaces/provides
between `builddir` and `build()`.

Follow this convention, so they don't change
position when running `apkbuild-pypi recreate`.
2024-02-02 02:51:26 +00:00
Celeste fc863565f1 apkbuild-pypi.in: update url generated in template 2024-02-02 02:51:26 +00:00
Celeste 32c0815828 apkbuild-pypi.in: switch to pypi.org
pypi.python.org now redirects to it
2024-02-02 02:51:26 +00:00
Celeste 81fb95d31a apkbuild-pypi.in: format depends and checkdepends
with `format_depends` function
taken from `apkbuild-cpan.in`
2024-02-02 02:51:26 +00:00
Celeste 250412d18c apkbuild-pypi.in: use pypi json in get_deps
the old method of calling
`python3 ./setup.py --requires`
doesn't seem to be working anymore
2024-02-02 02:51:26 +00:00
Celeste 54550dc597 apkbuild-pypi.in: use $pkgver in source
regex taken from `apkbuild-cpan.in`
2024-02-02 02:51:26 +00:00
Celeste 11c96f25d6 apkbuild-pypi.in: add -pyc subpackage to template 2024-02-02 02:51:26 +00:00
Celeste ad9324fd52 apkbuild-pypi.in: use gpep517 in template
copied from `newapkbuild.in`, should work
even without a `pyproject.toml` due to the
`setuptools.build_meta:__legacy__` backend
2024-02-02 02:51:26 +00:00
Celeste 4a55e30881 apkbuild-pypi.in: remove depends="python3" from template
it is automatically traced since 6806a0d39b
2024-02-02 02:51:26 +00:00
Celeste 157e390ffa apkbuild-pypi.in: create pretty urls in get_source 2024-02-02 02:51:26 +00:00
Timothy Legge 60c00a4d39 apkbuild-cpan.in: Remmove unnecessary/unused code
Should have been removed in:
27c430cc64
2024-02-01 22:08:23 -04:00
Timothy Legge 99cda3db69 apkbuild-cpan.in: fix uninitialized value when running with no parameters
by applying Celeste's suggested fix
2024-02-01 22:08:23 -04:00
Timothy Legge 1dd67c1beb apkbuild-cpan.in: remove unnecessary pragmas 2024-02-01 22:08:17 -04:00
Timothy Legge 9cde1ad278 apkbuild-cpan.in: Standardize the source and patches output 2024-02-01 07:35:23 -04:00
Celeste 0ad7489969 apkbuild-cpan.in: move code that queries metacpan into its own function
this piece of code was repeated in multiple places, so factor it out
2024-01-31 19:29:56 -04:00
Timothy Legge 726e37920c apkbuild-cpan.in: fix read_assignments_from_file
remove unnecessary regex in functions

Return early if not processing an APKBUILD file

and fix undefined variable of there are no patches
2024-01-30 23:05:45 -04:00
Celeste 1c017bb5d5 apkbuild-cpan.in: add newline after inserting *depends=
Upon `apkbuild-cpan upgrade`, an aport without any
checkdepends would get a line like this inserted:
`checkdepends=""subpackages="$pkgname-doc"`

which would then be deleted by the substitution
that removes empty variables, so the net result
is an APKBUILD with the subpackages field removed.

Inserting a newline results in `checkdepends=""`
being a line all by itself, which then gets
correctly removed by the empty variables regex.
2024-01-28 02:50:25 +00:00
Timothy Legge b0f60ee85a apkbuild-cpan.in: fixes #10129 move _pkgreal and comment 2024-01-27 12:10:06 -04:00
Celeste 28edb26d5b apkbuild-cpan.in: fix empty lines in recreated depends variables
this is a preliminary attempt at fixing #10126, however, i think
the whole logic around recreating depends should be reviewed and
improved, as we may want to carry over all the depends from the
old APKBUILD, and not just the non-perl libs, as the old depends
may be compensating for something not declared in the META file.
2024-01-26 22:33:02 -04:00
Celeste b48c12ea86 apkbuild-cpan.in: do not increase number of spaces in options_comment
the regex used to match options_comment in read_assignments_from_file
starts matching immediately after the closing double quote (it does
not remove the prefixing space), so without this change, a new space
is inserted by the template upon each `recreate`.
2024-01-26 21:37:18 -04:00
Celeste 6a8a61f9d8 apkbuild-cpan.in: find Build.PL using glob() in update_functions sub
this is more consistent with the method we use to
find Build.PL / Makefile.PL in the do_depends sub
2024-01-26 21:37:18 -04:00
Celeste 1c771b0d6a apkbuild-cpan.in: keep arch of old APKBUILD
also, prevent removal of `arch=""` line,
which is sometimes used for disabled aports
2024-01-26 21:37:18 -04:00
Celeste ef6aef38b1 apkbuild-cpan.in: sort & de-duplicate dependencies 2024-01-26 21:37:18 -04:00
Celeste 41a36bca95 apkbuild-cpan.in: move .pod files to the -doc subpackage
this `doc()` function is copied from main/perl/APKBUILD
2024-01-26 21:37:18 -04:00
Celeste 3336955a4a apkbuild-cpan.in: update $package_mappings 2024-01-26 21:37:18 -04:00
Celeste fe072f9866 apkbuild-cpan.in: fix empty directories
by not installing .packlist and perllocal.pod.

The call to find -delete has been removed as
the modifications to build() have covered
almost all cases, so deleting .packlist and
perllocal.pod manually is no longer necessary.

Also, increment template version from 3
to 4 to allow easy identification of
aports that have this change applied.
2024-01-26 21:37:18 -04:00
Celeste 7101d6164a apkbuild-cpan.in: also attempt to generate MYMETA from running Build.PL 2024-01-26 21:37:18 -04:00
Celeste 1753907af0 apkbuild-cpan.in: fix use of uninitialized value $1 2024-01-26 21:37:18 -04:00
Timothy Legge c704644b3c Initial attempt to keep the options and patches 2024-01-26 21:37:18 -04:00
Celeste 37e99da359 apkbuild-cpan.in: tidy up abstract before using it as pkgdesc 2024-01-26 21:37:18 -04:00
Celeste 0bb1482c3a New way of calculating builddir & metaprefix
apkbuild-cpan.in: attempt to get a metaprefix if no metafiles exist

apkbuild-cpan.in: try harder to find a metaprefix

apkbuild-cpan.in: redefine builddir if not based on $_pkgreal
2024-01-26 21:37:18 -04:00
Timothy Legge 505a64bfa7 Improve handling of missing meta files and detection of perl-dev requirment 2024-01-26 21:37:18 -04:00
Sertonix cd32e245e2 abuild: fix subpackage setting arch to all explicitly 2024-01-12 18:28:09 +01:00
Natanael Copa 84e29d94f9 ==== release 3.12.0 ==== 2023-10-18 12:32:17 +02:00
Sören Tempel acfa7d6732 checkapk: Check how many packages depend on a previous soname
Since the changeset committed by psykose a while ago in commit
26118d4997 we now extract the
previous soname. We can pass this previous soname to `apk search -R`
to figure out how many packages are linked against this old soname.

I believe this to be useful for reviewing MRs since the checkapk
output will directly tell us if a contributor has missed rebuilds.
It will also inform us when no rebuilds are necessary, e.g. if the
SONAME was changed but no packages is linked against the library.

Example output for `main/libsodium`:

```
>>> Size difference for libsodium: 336 KiB -> 340 KiB
--- filelist-libsodium-old      2023-09-22 11:24:54.799204225 +0200
+++ filelist-libsodium-new      2023-09-22 11:24:54.799204225 +0200
@@ -1,5 +1,5 @@
 .PKGINFO
 usr/
 usr/lib/
-usr/lib/libsodium.so.23
-usr/lib/libsodium.so.23.3.0
+usr/lib/libsodium.so.26
+usr/lib/libsodium.so.26.1.0
SODIFF:
-usr/lib/libsodium.so.23.3.0:    SONAME               libsodium.so.23
+usr/lib/libsodium.so.26.1.0:    SONAME               libsodium.so.26
REBUILDS:
*** 36 packages linked against 'libsodium.so.23' need to be rebuild!
```
2023-10-18 09:39:12 +00:00
Natanael Copa fab41364f7 checkapk: dont require abuild.conf if we have default conf
also add tests
2023-10-18 11:22:47 +02:00
Natanael Copa 643637dd5d checkapk: add test, fix usage
print --help output to stdout and errors to stderr.
2023-10-18 11:07:24 +02:00
Natanael Copa 3a7fdeaaf0 tests: speed up abuild cleanoldpkg test
skip various steps when buliding the package.
2023-10-18 08:46:09 +02:00
Natanael Copa 08126de5f2 tests: add another test for abuild deps
Test that passing only `CHOST=... abuild deps` works as expected
2023-10-17 22:30:00 +02:00
Natanael Copa c73b8f4ca7 tests: test checkdepends
verify that checkdepends is pulled in when it should and not installed
when it shouldn't.
2023-10-17 22:04:56 +02:00
Natanael Copa 852bb238f3 tests: add test for abuild dep
verify that makedepends_build and makedepends_host works as expected.
2023-10-17 19:51:35 +00:00
Natanael Copa 9ed6a92107 make: run tests in parallel 2023-10-17 19:51:35 +00:00
Natanael Copa c63cae3b15 abuild-tar: fix warnings from scan-build
ref: https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10102
2023-10-17 16:33:15 +00:00
Natanael Copa fcdfd871af abuild-sudo: handle errors from setuid/setgid
ref https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10102
2023-10-17 16:33:15 +00:00
Natanael Copa 1332d5b171 abuild-rmtemp: fix build with clang 2023-10-17 16:33:15 +00:00
Natanael Copa 4128fa6392 ci: build with clang and scan-build
ref: https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10102
2023-10-17 16:33:15 +00:00
Natanael Copa a6a95ad633 abuild: set filetype sh for abuild.in 2023-10-17 16:33:15 +00:00
ptrcnull f688130443 abuild: simplify finding repo_template
related to #10069, this keeps the original behaviour when
running in aports and allows for using rootbld in other package repositories
2023-10-12 15:39:09 +00:00
jvoisin dd67240f01 Actually set values for libcpp hardening macros
Otherwise, it wouldn't do much…
2023-09-04 01:56:15 +02:00
sudotac 9fe0d14d7e apkbuild-pypi.in: replace given/when with if/elsif
smartmatch is deprecated in Perl 5.37.10
2023-08-30 05:50:04 +00:00
sudotac 00aa9aab12 apkbuild-pypi.in: use $() instead of backticks 2023-08-30 05:50:04 +00:00
jvoisin 65b5d578b2 Enable more hardening for libcpp
- _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS: This macro is used to enable -Wthread-safety annotations on libc++’s std::mutex and std::lock_guard.
- _LIBCPP_ENABLE_HARDENED_MODE to enable the hardened mode.
2023-08-21 13:37:35 +02:00
psykose 28b97249fa ==== release 3.11.21 ==== 2023-07-17 06:28:54 +02:00
psykose 6c20db871b checkapk: fix a mistaken grep warning
grep: warning: stray \ before -
it matches without \ anyway
2023-07-17 06:12:56 +02:00
psykose cc17a1cc79 checkapk: exit on trap signal
otherwise it cleans up but the loop keeps going and just fails until end,
just spamming the output
2023-07-11 15:38:09 +02:00
Iztok Fister Jr 617df473b0 apkbuild-cpan: fix typo 2023-07-07 22:48:12 +02:00
psykose d4b2415fb1 apkbuild-cpan: run perltidy over the source
it was a mismatch of mixed indents
2023-07-03 23:52:43 +02:00
psykose 0e555d58a7 apkbuild-cpan: port given/when to if/else
the former is deprecated syntax
2023-07-03 23:49:52 +02:00
psykose fc575e8361 abuild: fix a mistake in 0e333003df
the prefix was dropped from the check so it always says it's unregistered
no actual breakage happened as this just prints a warning
2023-07-03 04:45:13 +02:00
psykose cbca6d4f48 ==== release 3.11.20 ==== 2023-06-29 06:02:28 +02:00
psykose 21faeb7f47 checkapk: use grep instead of awk for size checking
the previous implementation had a bug that + chars needed escaping
(which was fixed), and now has another discovered but that pkgnames
could start with a number, so the /^pkg/ match matches the pkgname again
and a size comparison gives you:

>>> Size difference for 7zip: 7zip-22.01-r5 installed size: -> 7zip-23.01-r0 installed size:

using grep -F avoids any magic character expansion and works correctly
in all cases.
2023-06-29 06:00:22 +02:00
psykose 446b68359f tests: make sure move_caches tests don't fail with envs set 2023-06-26 10:33:40 +02:00
psykose 873a4b6654 ==== release 3.11.19 ==== 2023-06-26 10:31:15 +02:00
psykose df31829660 checkapk: don't objdump invalid elfs
cleans up the output a bit for things that have .so in the name
2023-06-26 10:30:49 +02:00
psykose 535afd9544 checkapk: do simple parallel
this is quite trivial and should be safe
2023-06-26 07:52:28 +02:00
psykose 5c25099d4f ==== release 3.11.18 ==== 2023-06-26 07:41:07 +02:00
psykose 9855e304c7 checkapk: ignore missing apk error
prior to the recent reworks, this error handling path was never
triggered, because the script is ran without pipefail, and it was at
the end of a | pipe | line | sort, so all it did was be ignored for 'new
apks', when the old one would fail to fetch and be missing.

since we now do hit this path on fetch failure however, it aborts the
script when a new subpackage/package is added (since the 'old apk' won't
exist), and doesn't output a diff. since before we always ignored this,
ignore the 'old apk' perhaps not existing, which gives the currently
intended behaviour.
2023-06-26 07:41:07 +02:00
psykose d451522e53 ==== release 3.11.17 ==== 2023-06-26 04:25:43 +02:00
psykose 256a249feb checkapk: but actually skip symlinks
boolean logic gets confusing..
2023-06-26 04:25:08 +02:00
psykose d51cf9c2bb ==== release 3.11.16 ==== 2023-06-26 04:23:08 +02:00
psykose fd5ec6b4fa checkapk: skip symlinks
this affected the old version too- duplicate sodiffs on symlinks are useless
2023-06-26 04:22:26 +02:00
psykose 64f2b3af4e ==== release 3.11.15 ==== 2023-06-26 04:15:06 +02:00
psykose 9af4012177 checkapk: also make sure only sofiles objdumped 2023-06-26 04:14:15 +02:00
psykose 3e5501c9fa ==== release 3.11.14 ==== 2023-06-26 03:27:35 +02:00
psykose 26118d4997 checkapk: refactor to show previous soname and decompress once and use unified context
closes #10070

previously:
>>> Size difference for gegl: 7480 KiB -> 7956 KiB
--- filelist-gegl-old	2023-06-26 02:28:40.176085274 +0200
+++ filelist-gegl	2023-06-26 02:28:40.202085952 +0200
@@ -47,12 +47,13 @@
 usr/lib/gegl-0.4/tiff-load.so
 usr/lib/gegl-0.4/tiff-save.so
 usr/lib/gegl-0.4/transformops.so
+usr/lib/gegl-0.4/vector-fill.so
 usr/lib/gegl-0.4/vector-stroke.so
 usr/lib/gegl-0.4/webp-load.so
 usr/lib/gegl-0.4/webp-save.so
 usr/lib/girepository-1.0/
 usr/lib/girepository-1.0/Gegl-0.4.typelib
 usr/lib/libgegl-0.4.so.0
-usr/lib/libgegl-0.4.so.0.443.1
+usr/lib/libgegl-0.4.so.0.445.1
 usr/lib/libgegl-npd-0.4.so
 usr/lib/libgegl-sc-0.4.so
usr/lib/gegl-0.4/vector-fill.so:    SONAME               vector-fill.so
usr/lib/libgegl-0.4.so.0.445.1:    SONAME               libgegl-0.4.so.0

now:
>>> Size difference for gegl: 7480 KiB -> 7956 KiB
--- filelist-gegl-old
+++ filelist-gegl-new
@@ -47,12 +47,13 @@
 usr/lib/gegl-0.4/tiff-load.so
 usr/lib/gegl-0.4/tiff-save.so
 usr/lib/gegl-0.4/transformops.so
+usr/lib/gegl-0.4/vector-fill.so
 usr/lib/gegl-0.4/vector-stroke.so
 usr/lib/gegl-0.4/webp-load.so
 usr/lib/gegl-0.4/webp-save.so
 usr/lib/girepository-1.0/
 usr/lib/girepository-1.0/Gegl-0.4.typelib
 usr/lib/libgegl-0.4.so.0
-usr/lib/libgegl-0.4.so.0.443.1
+usr/lib/libgegl-0.4.so.0.445.1
 usr/lib/libgegl-npd-0.4.so
 usr/lib/libgegl-sc-0.4.so
SODIFF:
+usr/lib/gegl-0.4/vector-fill.so:    SONAME               vector-fill.so
-usr/lib/libgegl-0.4.so.0.443.1:    SONAME               libgegl-0.4.so.0
+usr/lib/libgegl-0.4.so.0.445.1:    SONAME               libgegl-0.4.so.0

it also no longer relies on diffutils default output, utilising diff -U0 for comparison

there is also a slight optimisation wrt apk handling, previously it
would get decompressed twice for soname diff. now the intermediate is
stored
2023-06-26 03:17:31 +02:00
psykose 7c85598b7f ==== release 3.11.13 ==== 2023-06-22 22:41:17 +02:00
psykose 8e25f6d14a checkapk: undo broken parallel thing
this doesn't work for setting lvalues and *size= is never populated

todo: write tests.., or just port this to lua
2023-06-22 22:40:38 +02:00
psykose e3777a7259 checkapk: silence old-pkg gzip/tar errors
when apk fetch fails (a new package is added) these just say 'gzip invalid magic' or similar, as there is no old apk to compare to.

the || die is also never triggered, as it only triggers when the sort fails, since it won't trigger on earlier pipeline steps

this needs more cleaning up, but i'll leave that for the future when i write some tests.
2023-06-22 22:29:34 +02:00
psykose 1eb4ca5369 ==== release 3.11.12 ==== 2023-06-22 20:04:04 +02:00
psykose 3e5cbbee13 abuild: unset default_lang depends unless set
for consistency with every default split
2023-06-22 20:03:32 +02:00
psykose 9987e57a20 ==== release 3.11.11 ==== 2023-06-22 17:56:52 +02:00
Sören Tempel c9b4146aaa Revert "rootbld: run mkusers inside the chroot and don't affect host users"
We can't run mkusers inside the chroot because of bwrap peculiarities.
Presently, rootbld does therefore not work at all for APKBUILDs which
use $pkggroups/$pkguser. While not polluting the host is a noble goal
it isn't really useful if it causes rootbld to be incapable of building
certain packages (i.e. those using $pkggroups/$pkguser with groups
not existent on the host).

This commit therefore restores the original behavior for now. While at
it, I also added a comment to the mkusers invocation.

See: https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10094

This reverts commit 84d7b7693d.
2023-06-22 21:53:46 +02:00
Cowington Post 7e82b6a34b
newapkbuild: do not expand $CTARGET 2023-06-22 07:13:25 -07:00
psykose fdbd71d816 checkapk: use pigz when available and run newsize/oldsize in parallel 2023-06-22 13:40:37 +02:00
psykose e995b9ec5b ==== release 3.11.10 ==== 2023-06-22 06:23:09 +02:00
Rodrigo Lourenço 1679651370 newapkbuild: fix generating wrong URL with new github urls
When giving GitHub URLs like

https://github.com/USER/REPO/archive/refs/tags/TAG.tar.gz

Strip away the /refs/tags part so a valid URL is generated.
Fixes #10034.
2023-06-22 06:10:54 +02:00
Jakub Panek c26043748e abuild: fix completions to vendor dir, warn on incorrect dir
Signed-off-by: Jakub Panek <me@panekj.dev>
2023-06-22 04:08:05 +00:00
psykose 38e84f9016 abuild: simplify et_dyn/et_exec check 2023-06-22 03:37:06 +00:00
Dimitry Andric 76ff15a7b1 abuild: unset option variables to prevent environment leaking in
In abuild's getopts loop, option variables such as "keep", "verbose",
etc are only set if the corresponding option is found. If such an option
is *not* found, any environment variable with the same name will leak
in, instead. Prevent this by explicitly unsetting almost all of them.
2023-06-22 03:35:46 +00:00
ptrcnull d27b635768 abuild: set cache directories to a temporary directory if MOVE_CACHES is set
this allows for isolating cache directories per package
2023-06-22 05:33:59 +02:00
Jakub Jirutka 8efe527ff3 sample.*: improve sample init script 2023-06-21 15:34:27 +02:00
psykose 6ef31d9e99 ==== release 3.11.9 ==== 2023-06-15 14:54:45 +02:00
psykose 8d11e9f410 abuild: refactor duplicate python detection to not use find(1)
the previous implementation used -regex, which is subtly different between busybox and findutils

[0-9]\+ matches on busybox, but doesn't match with gnu findutils
[0-9]+ matches with findutils, but doesn't match on busybox

this means python deps were subtly broken when findutils was installed
(sometimes pulled via makedeps) vs not
2023-06-15 12:54:00 +00:00
psykose 8f41a924e3 abuild: fix cmd: provides to not provide directory names
/usr/bin/somedirectory/ was providing cmd:somedirectory, because dirs
have +x.
2023-06-15 14:37:24 +02:00
psykose 5d4e763459 ==== release 3.11.8 ==== 2023-06-15 12:59:59 +02:00
Sören Tempel 4a2a0337d0 abuild: Scan for binaries with extra setcap(8) capabilities
Similar to suid binaries, abuild will now error out if the package
includes binaries with setcap(8) capabilities but doesn't have `setcap`
in `$options`. This eases identifying package which ship binaries
with extra capabilities.

Furthermore, if these binaries are executable by others a warning is
emitted. This warning could be changed to an error in the future.
The recommendation is to make such binaries only executable by owner
and group, thereby requiring the system administrator to explicitly
add users to a specific group in order to give them accesses to these
capabilities.

See: https://gitlab.alpinelinux.org/alpine/tsc/-/issues/45

Discussion: This change requires abuild to depend on the `libcap`
package for the `getcap` binary. It does not seem to be possible
at the moment to use scanelf(1) to identify these binaries.
2022-07-03 14:30:15 +02:00
Timo Teräs 8d6fb8b45f abuild-sudo: fix determining number of groups
Musl _SC_NGROUPS_MAX is fixed at 32. The kernel can support more.
Query the kernel for number of groups needed.
2023-06-07 12:42:00 +03:00
psykose 69d15d3225 ==== release 3.11.7 ==== 2023-06-07 07:30:58 +02:00
psykose 49ebbd94e9 newapkbuild: update gpep517 template for new style 2023-06-07 07:30:38 +02:00
Haelwenn (lanodan) Monnier 446a2a66e3 abuild. Use date -u instead of date --utc 2023-06-04 20:10:22 +02:00
psykose 64b3901777 ==== release 3.11.6 ==== 2023-06-03 19:51:50 +02:00
psykose 4f7a2aff7b default.conf: define -fstack-clash-protection by default
see https://gitlab.alpinelinux.org/alpine/tsc/-/issues/64 discussion
2023-06-03 19:48:09 +02:00
psykose 4e4e005530 ==== release 3.11.5 ==== 2023-06-03 12:56:21 +02:00
Sören Tempel e2ab6219d3 abuild: Warn if -doc subpackage exceeds a certain threshold
In the warning, suggest splitting the -doc subpackage into additional
smaller packages (which are not pulled in by the `docs` meta package).

Fixes https://gitlab.alpinelinux.org/alpine/tsc/-/issues/16
2023-06-03 10:55:12 +00:00
psykose a787a9c9c1 ==== release 3.11.4 ==== 2023-06-01 09:32:00 +02:00
psykose 0e333003df abuild: downgrade binfmt-registration error to a warning
strictly speaking, it is possible for an x86_64 cpu to run 32-bit
userspace binaries without qemu emulation. it is also possible for an
aarch64 cpu to run armhf/armv7 binaries (as long as the cpu implements
it, most do). rather than check for every possible combination of when
this is allowed (host cpu + emulated target, does cpu support it, ...),
just downgrade this case to a warning, to permit non-emulated use.

ref https://gitlab.alpinelinux.org/alpine/abuild/-/merge_requests/117#note_255174
2023-06-01 09:29:59 +02:00
41 changed files with 2557 additions and 1199 deletions

View File

@ -20,3 +20,7 @@ indent_style = space
[Makefile]
indent_size = 8
indent_style = tab
[*.yml]
indent_size = 2
indent_style = space

View File

@ -5,7 +5,27 @@ tests:
image:
name: alpinelinux/abuild-ci
stage: verify
script: [pwd]
script:
- make
- make check
tags:
- docker-alpine
- x86_64
build-clang:
image:
name: alpinelinux/abuild-ci
stage: verify
script: [CC=clang make]
tags:
- docker-alpine
- x86_64
build-scan:
image:
name: alpinelinux/abuild-ci
stage: verify
script: [scan-build --status-bugs make]
tags:
- docker-alpine
- x86_64

1
.mailmap Normal file
View File

@ -0,0 +1 @@
Kaarle Ritvanen <kunkku@alpinelinux.org> <kaarle.ritvanen@datakunkku.fi>

View File

@ -168,6 +168,12 @@ file.
Specifies packages that the package replaces. This is typically
used for packages renamed by upstream.
*replaces_priority*
Specifies the numeric value that is used by apk(8) when multiple
packages with *replaces* include the same file. It is also used
to decide which package should define the permissions of a directory
even without *replaces* set.
*subpackages*
Specifies subpackages or split packages built with this
package. Typically, this will include _$pkgname-dev_ for development
@ -215,6 +221,11 @@ file.
packages containing firmware, and should typically never
be needed.
*bigdocs*
Specifies that this packages intentionally has a large -doc subpackage.
Thereby suppressing a warning to be emitted if the -doc subpackage
exceeds a certain package size threshold (currently 2 MiB).
*charset.alias*
Specifies that the package ships a _/usr/lib/charset.alias_
file and that it should be installed on the user's
@ -273,6 +284,12 @@ file.
to use capabilities or process separation instead of set-uid
where available.
*setcap*
Specifies that binaries in the package may be installed
with extra setcap(8) capabilities. If this option is enabled,
it is highly recommended to only make these binaries executable
by root and users of a specific group, not by others.
*textrels*
Specifies that the package's binaries are known to contain
relocations against text segments. By default, abuild(1)
@ -446,7 +463,7 @@ preferred /bin/sh, which is typically bash(1).
# SEE ALSO
SPDX license reference (on the Web at <https://spdx.org/licenses/>),
abuild(1), newapkbuild(1), apk(8).
abuild(1), newapkbuild(1), apk(8), buildrepo(1).
# HISTORY

View File

@ -1,5 +1,5 @@
PACKAGE := abuild
VERSION := 3.11.3
VERSION := 3.14.1
prefix ?= /usr
bindir ?= $(prefix)/bin
@ -11,8 +11,8 @@ SCRIPTS := abuild abuild-keygen abuild-sign newapkbuild \
abump apkgrel buildlab apkbuild-cpan apkbuild-pypi checkapk \
apkbuild-gem-resolver
USR_BIN_FILES := $(SCRIPTS) abuild-tar abuild-gzsplit abuild-sudo abuild-fetch abuild-rmtemp
MAN_1_PAGES := newapkbuild.1 abuild.1
MAN_5_PAGES := APKBUILD.5
MAN_1_PAGES := newapkbuild.1 abuild.1 abump.1
MAN_5_PAGES := APKBUILD.5 abuild.conf.5
SAMPLES := sample.APKBUILD sample.initd sample.confd \
sample.pre-install sample.post-install
MAN_PAGES := $(MAN_1_PAGES) $(MAN_5_PAGES)
@ -58,7 +58,7 @@ LDFLAGS-abuild-gzsplit = $(ZLIB_LIBS)
OBJS-abuild-sudo = abuild-sudo.o
OBJS-abuild-fetch = abuild-fetch.o
TEST_TIMEOUT = 15
TEST_TIMEOUT = 30
.SUFFIXES: .conf.in .sh.in .in
%.conf: %.conf.in
@ -127,35 +127,25 @@ Kyuafile: tests/Kyuafile
echo "include('tests/Kyuafile')" >> $@
check: $(SCRIPTS) $(USR_BIN_FILES) functions.sh tests/Kyuafile Kyuafile tests/testdata/abuild.key.pub
kyua test || (kyua report --verbose && exit 1)
kyua --variable parallelism=$(shell nproc) test || (kyua report --verbose && exit 1)
install: $(USR_BIN_FILES) $(SAMPLES) $(MAN_PAGES) default.conf abuild.conf functions.sh
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
$(DESTDIR)/$(sharedir) $(DESTDIR)/$(mandir)/man1 \
$(DESTDIR)/$(mandir)/man5
for i in $(USR_BIN_FILES); do\
install -m 755 $$i $(DESTDIR)/$(bindir)/$$i;\
done
chmod 4555 $(DESTDIR)/$(prefix)/bin/abuild-sudo
install: $(USR_BIN_FILES) $(SAMPLES) $(MAN_PAGES) $(AUTOTOOLS_TOOLCHAIN_FILES) default.conf abuild.conf functions.sh
install -D -m 755 -t $(DESTDIR)/$(bindir)/ $(USR_BIN_FILES);\
chmod 4555 $(DESTDIR)/$(bindir)/abuild-sudo
for i in adduser addgroup apk; do \
ln -fs abuild-sudo $(DESTDIR)/$(bindir)/abuild-$$i; \
done
for i in $(MAN_1_PAGES); do\
install -m 644 $$i $(DESTDIR)/$(mandir)/man1/$$i;\
done
for i in $(MAN_5_PAGES); do\
install -m 644 $$i $(DESTDIR)/$(mandir)/man5/$$i;\
done
install -D -m 644 -t $(DESTDIR)/$(mandir)/man1/ $(MAN_1_PAGES);\
install -D -m 644 -t $(DESTDIR)/$(mandir)/man5/ $(MAN_5_PAGES);\
if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
install -t $(DESTDIR)/$(sysconfdir)/ abuild.conf; \
install -D -m 644 -t $(DESTDIR)/$(sysconfdir)/ abuild.conf; \
fi
install -t $(DESTDIR)/$(prefix)/share/abuild/ $(SAMPLES)
install -t $(DESTDIR)/$(prefix)/share/abuild/ $(AUTOTOOLS_TOOLCHAIN_FILES)
install -t $(DESTDIR)/$(sharedir)/ functions.sh default.conf
install -D -t $(DESTDIR)/$(sharedir)/ $(AUTOTOOLS_TOOLCHAIN_FILES)
install -D -m 644 -t $(DESTDIR)/$(sharedir)/ functions.sh default.conf $(SAMPLES)
depends depend:
sudo apk --no-cache -U --virtual .abuild-depends add openssl-dev zlib-dev
sudo apk --no-cache -U --virtual .abuild-depends add openssl-dev openssl-libs-static zlib-dev
.gitignore: Makefile
echo "*.tar.bz2" > $@

View File

@ -81,11 +81,22 @@ int fork_exec(char *argv[], int showerr)
static int acquire_lock(const char *lockfile)
{
int lockfd = open(lockfile, O_WRONLY|O_CREAT, 0660);
if (lockfd < 0)
err(1, "%s", lockfile);
int lockfd, i, r;
if (lockf(lockfd, F_LOCK, 0) == -1)
/* try to work around an ESTALE error which occurs on NFS */
for (i = 0; i < 10; i++, sleep(1)) {
lockfd = open(lockfile, O_WRONLY|O_CREAT, 0660);
if (lockfd < 0)
err(1, "%s", lockfile);
r = lockf(lockfd, F_LOCK, 0);
if (r == 0 || errno != ESTALE)
break;
close(lockfd);
}
if (r != 0)
err(1, "failed to acquire lock: %s", lockfile);
return lockfd;

View File

@ -18,7 +18,7 @@
#define PREFIX "/var/tmp/abuild."
static void fail() {
static void fail(void) {
errx(1, "%s", strerror(errno));
}

View File

@ -18,8 +18,8 @@ fi
gzip=$(command -v pigz || echo gzip)
do_sign() {
local f i keyname repo
local openssl=$(command -v openssl || echo libressl)
local f i keyname repo openssl
openssl=$(command -v openssl || echo libressl)
# we are actually only interested in the name, not the file itself
keyname=${pubkey##*/}
@ -31,8 +31,8 @@ do_sign() {
trap 'die "failed to sign $i"' EXIT
set -e
cd "$repo"
sig=".SIGN.RSA.$keyname"
$openssl dgst -sha1 -sign "$privkey" -out "$sig" "$i"
sig=".SIGN.$sigtype.$keyname"
$openssl dgst $dgstargs -sign "$privkey" -out "$sig" "$i"
if [ -n "$SOURCE_DATE_EPOCH" ]; then
touch -h -d "@$SOURCE_DATE_EPOCH" "$sig"
@ -61,6 +61,7 @@ usage() {
-k, --private KEY The private key to use for signing
-p, --public KEY The name of public key. apk add will look for
/etc/apk/keys/KEY
-t, --type TYPE The signature type RSA or RSA256
-q, --quiet
-h, --help Show this help
@ -72,7 +73,7 @@ privkey="$PACKAGER_PRIVKEY"
pubkey=
quiet=
args=$(getopt -o ek:p:qh --long installed,private:,public:,quiet,help -n "$program" -- "$@")
args=$(getopt -o ek:p:t:qh --long installed,private:,public:,type:,quiet,help -n "$program" -- "$@")
if [ $? -ne 0 ]; then
usage >&2
exit 2
@ -83,6 +84,7 @@ while true; do
-e|--installed) check_installed=true;;
-k|--private) privkey=$2; shift;;
-p|--public) pubkey=$2; shift;;
-t|--type) sigtype=$2; shift;;
-q|--quiet) quiet=1;; # suppresses msg
-h|--help) usage; exit;;
--) shift; break;;
@ -112,6 +114,18 @@ if [ -z "$pubkey" ]; then
pubkey=${PACKAGER_PUBKEY:-"${privkey}.pub"}
fi
if [ -z "$sigtype" ]; then
sigtype=RSA
fi
case $sigtype in
RSA) dgstargs="-sha1";;
RSA256) dgstargs="-sha256";;
*)
echo "$program: supported types are RSA and RSA256" >&2
exit 1
;;
esac
if $check_installed; then
if ! [ -e "$privkey" ]; then
echo "$program: $privkey: File not found" >&2

View File

@ -62,7 +62,7 @@ void check_option(const char *opt)
int is_in_group(gid_t group)
{
int ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
int ngroups_max = getgroups(0, 0);
gid_t *buf = malloc(ngroups_max * sizeof(gid_t));
int ngroups;
int i;
@ -125,9 +125,11 @@ int main(int argc, const char *argv[])
argv[0] = path;
/* set our uid to root so bbsuid --install works */
setuid(0);
if (setuid(0) < 0)
err(1, "setuid(0) failed");
/* set our gid to root so apk commit hooks run with the same gid as for "sudo apk add ..." */
setgid(0);
if (setgid(0) < 0)
err(1, "setgid(0) failed");
execv(path, (char * const*)argv);
perror(path);
return 1;

View File

@ -221,7 +221,8 @@ static int buf_padto(struct buf *b, size_t alignment)
newsize = (oldsize + alignment - 1) & -alignment;
if (buf_resize(b, newsize)) return -ENOMEM;
b->size = newsize;
memset(b->ptr + oldsize, 0, newsize - oldsize);
if (b->ptr)
memset(b->ptr + oldsize, 0, newsize - oldsize);
return 0;
}
@ -260,6 +261,8 @@ static int buf_add_ext_header_hexdump(struct buf *b, const char *hdr, const unsi
for (i = len; i > 9; i /= 10) len++;
if (buf_resize(b, b->size + len)) return -ENOMEM;
if (b->ptr == NULL)
return 0;
b->size += snprintf(&b->ptr[b->size], len, "%u %s=", len, hdr);
for (i = 0; i < valuelen; i++)
b->size += snprintf(&b->ptr[b->size], 3, "%02x", (int)value[i]);
@ -268,22 +271,6 @@ static int buf_add_ext_header_hexdump(struct buf *b, const char *hdr, const unsi
return 0;
}
static void add_legacy_checksum(struct tar_header *hdr, const EVP_MD *md, const unsigned char *digest)
{
struct {
char id[4];
uint16_t nid;
uint16_t size;
} mdinfo;
memcpy(mdinfo.id, "APK2", 4);
mdinfo.nid = EVP_MD_nid(md);
mdinfo.size = EVP_MD_size(md);
memcpy(&hdr->linkname[3], &mdinfo, sizeof(mdinfo));
memcpy(&hdr->linkname[3+sizeof(mdinfo)], digest, mdinfo.size);
tarhdr_checksum(hdr);
}
static int do_it(const EVP_MD *md, int cut)
{
char checksumhdr[32];
@ -320,7 +307,6 @@ static int do_it(const EVP_MD *md, int cut)
if (hdr.typeflag != '2') {
EVP_Digest(data.ptr, size, digest, NULL, md, NULL);
add_legacy_checksum(&hdr, md, digest);
} else {
name_len = strnlen(hdr.linkname, sizeof(hdr.linkname));
EVP_Digest(hdr.linkname, name_len, digest, NULL, md, NULL);

View File

@ -6,8 +6,7 @@ abuild(1)
# SYNOPSIS
*abuild* [options] [-P _REPODEST_] [-s _SRCDEST_] [-D _DESCRIPTION_] [cmd] ...++
*abuild* [-c] -n _PKGNAME_[-_PKGVER_]
*abuild* [options] [-P _REPODEST_] [-s _SRCDEST_] [-D _DESCRIPTION_] [cmd] ...
# DESCRIPTION
@ -25,11 +24,11 @@ other related operations.
*-d*
Disable dependency checking
*-D*
*-D DESCRIPTION*
Set APKINDEX description (default: *$repo $(git describe)*)
*-f*
Force specified cmd (skip checks: apk up to date, arch, libc)
Force specified cmd (skip checks: apk up to date, arch)
*-F*
Force run as root
@ -46,23 +45,28 @@ other related operations.
*-m*
Disable colors (monochrome)
*-P*
*-P REPODEST*
Set REPODEST as the repository location for created packages
*-q*
Quiet
*-r*
Install missing dependencies from system repository (using sudo)
Install missing dependencies from system repository
*-s*
Set source package destination directory
*-s SRCDEST*
Set source package destination directory to SRCDEST
*-v*
Verbose: show every command as it is run (very noisy)
# COMMANDS
*all*
Runs the entire build process. This is the default when no other command is
specified, and is roughly an alias for *validate builddeps clean fetch
unpack prepare mkusers build check rootpkg*.
*build*
Compile and install package into *$pkgdir*.
@ -108,8 +112,8 @@ other related operations.
*rootpkg*
Run 'package', the split functions and create apks as fakeroot
*sanitycheck*
Basic sanity check of APKBUILD
*validate*
Basic validation of APKBUILD
*snapshot*
Create a *$giturl* snapshot and upload to *$disturl*
@ -132,6 +136,54 @@ other related operations.
*verify*
Verify checksums
# ENVIRONMENT
*APKBUILD*
Override path to *APKBUILD* file.
*BOOTSTRAP*
Used when bootstrapping with no existing packages by minimising build
dependencies. This flag only has an effect on a few select packages.
A value of _nocc_ omits any compilation (e.g.: include only source headers).
A value of _nolibc_ assumes that no _libc_ is available.
This list of values is not exhaustive.
*CHOST*
Generate packages for given arch or hostspec.
*CTARGET*
Generate compiler for given arch or hostspec.
*MOVE_CACHES*
Don't use global cache directories for Go and Cargo.
*PACKAGER*
Name and email of the packages in RFC5322 format.
E.g.: *John Doe <john@example.com>*.
*PACKAGER_PRIVKEY*
Path to a private key used to sign packages.
*REPODEST*
Packages shall be stored in _$REPODEST/$repo/$pkgname-$pkgver-r$pkgrel.apk_,
where *$repo* is the base name of the parent directory of *$startdir*.
*SOURCE_DATE_EPOCH*
Use this timestamp as a reference for reproducible builds.
See *https://reproducible-builds.org/docs/source-date-epoch/*
*SUDO_APK*
Command to use to run apk as root. Defaults to *abuild-apk*.
*USE_CCACHE*
If set to a non-empty value, enables *ccache* support.
*USE_COLORS*
If set to a non-empty value, print coloured output using ANSI escape
sequences.
# FILES
/etc/abuild.conf
@ -157,7 +209,7 @@ abuild -rc
# SEE ALSO
SPDX license reference (on the Web at <https://spdx.org/licenses/>),
newapkbuild(1), apk(8), APKBUILD(5).
newapkbuild(1), apk(8), APKBUILD(5), abuild.conf(5), buildrepo(1).
# AUTHORS

29
abuild.conf.5.scd Normal file
View File

@ -0,0 +1,29 @@
abuild.conf(5)
# NAME
*abuild.conf* - configuration file for abuild
# DESCRIPTION
*abuild.conf* is the configuration for the *abuild(1)* program.
# FORMAT
The configuration file is parsed as a shell script; variables are defined as
regular shell variables.
For a list of supported variables, see the ENVIRONMENT section of the
*abuild(1)* manual page.
# EXAMPLE
```
PACKAGER_PRIVKEY="/home/jane/.abuild/jane@example.com-87ac18ca.rsa"
PACKAGER="Jane Doe <jane@example.com>"
USE_COLORS=1
```
# SEE ALSO
abuild(1)

View File

@ -24,3 +24,6 @@
# what to cleanup after a failed build
#ERROR_CLEANUP="bldroot deps"
# uncomment to prevent using global cache directories for Go and Cargo
#MOVE_CACHES=1

804
abuild.in Executable file → Normal file

File diff suppressed because it is too large Load Diff

53
abump.1.scd Normal file
View File

@ -0,0 +1,53 @@
abump(1)
# NAME
*abump* - bump pkgver in an APKBUILD file
# SYNOPSIS
*abump* [-s _CVE-1_,...] [-f _ISSUE_] [-k|--keep] _PKGNAME-1.2.3_
# DESCRIPTION
*abump* updates the *pkgver* in an APKBUILD file, updates its checksums,
rebuilds it, and finally creates a new commit commit with the changes resulting.
*abump* operates looks for the specified package in nested directories inside
the current working, assuming a layout like that of the aports repository.
# OPTIONS
*-s, --security CVE1,...*
Include CVE in the *secfixes* comment section.
*-f, --fixes ISSUE*
Include *Fixes #ISSUE* in the commit message. This will close the upstream
issue when the commit is merged into the aports master branch.
*-k, --keep*
Keep existing packages.
*-h, --help*
Print help information and exit.
# ENVIRONMENT
APORTSDIR
Force operating on an alternate directory.
# EXAMPLES
```
abump mml-1.0.0
abump glibmm2.68-2.78.0
abump telegram-desktop-4.11.8
```
# SEE ALSO
abuild(1), apkgrel(1), newapkbuild(1), APKBUILD(5), apk(8).
# AUTHORS
Natanael Copa <_ncopa@alpinelinux.org_> and open source contributors.

View File

@ -73,8 +73,8 @@ fixes #${fixes#\#}
fi
msg "$message"
sed -i -e "s/^pkgver=.*/pkgver=$ver/" \
-e "s/^pkgrel=.*/pkgrel=0/" \
sed -i -e "s/^pkgver=[^ ]*/pkgver=$ver/" \
-e "s/^pkgrel=[^ ]*/pkgrel=0/" \
APKBUILD
$ABUILD $abuild_opts checksum all
@ -96,7 +96,7 @@ fixes #${fixes#\#}
usage() {
cat <<-__EOF__
$program $program_version - bump pkgver in APKBUILDs
Usage: $program [-s CVE-1,CVE-2,...] [-f ISSUE] [-R|--recursive] [-k|--keep] PKGNAME-1.2.3 ...
Usage: $program [-s CVE-1,CVE-2,...] [-f ISSUE] [-k|--keep] PKGNAME-1.2.3 ...
Options:
-s, --security CVE1,CVE-2,... Security update
-f, --fixes ISSUE Fixes ISSUE

File diff suppressed because it is too large Load Diff

View File

@ -4,50 +4,52 @@ use strict;
use warnings;
use autodie qw(:all);
use feature qw(:5.14);
use experimental 'switch';
use LWP::UserAgent;
use LWP::ConnCache;
use JSON;
use URI;
use Text::Wrap qw(wrap $columns);
use File::Basename qw(dirname);
our $packager = '';
my %pkgmap = ();
my %licenses = ();
my $template = <<'EOF';
# Automatically generated by apkbuild-pypi, template 3
# Automatically generated by apkbuild-pypi, template 4
[% authors %]
pkgname=[% pkgname %]
#_pkgreal is used by apkbuild-pypi to find modules at PyPI
_pkgreal=[% pkgreal %]
pkgver=[% pkgver %]
pkgrel=[% pkgrel %]
#_pkgreal is used by apkbuild-pypi to find modules at PyPI
_pkgreal=[% pkgreal %]
pkgdesc="[% pkgdesc %]"
provides="[% provides %]"
replaces="[% replaces %]"
url="http://packages.python.org/pypi/[% pkgreal %]"
url="[% url %]"
arch="noarch"
license="[% license %]"
depends="python3"
checkdepends="python3-dev"
makedepends="py3-setuptools"
subpackages=""
depends=""
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="[% source %]"
builddir="$srcdir/$_pkgreal-$pkgver"
builddir="[% builddir %]"
options="[% options %]"[% options_comment %]
[% compatibility %]
build() {
python3 setup.py build
gpep517 build-wheel \
--wheel-dir .dist \
--output-fd 3 3>&1 >&2
}
check() {
python3 setup.py test
python3 -m venv --clear --without-pip --system-site-packages .testenv
.testenv/bin/python3 -m installer .dist/*.whl
.testenv/bin/python3 -m pytest
}
package() {
PYTHONPATH=$pkgdir`python3 -c "import site; print(site.getsitepackages()[0])"` \
python3 setup.py install \
--prefix=/usr \
--root="$pkgdir" \
--single-version-externally-managed
python3 -m installer -d "$pkgdir" \
.dist/*.whl
}
EOF
@ -73,14 +75,31 @@ sub read_assignments_from_file {
my %mline = $text =~ /^(\w+)\s*=\s*\"([^\"]*)\".*$/mg;
my %hash = ( %sline, %mline );
my $authors = join("\n", $text =~ /^# Contributor: .*$/mg, $text =~ /^# Maintainer: .*$/mg);
return \%hash if $filename ne 'APKBUILD';
my $authors = join( "\n",
$text =~ /^# Contributor: .*$/mg,
$text =~ /^# Maintainer: .*$/mg );
$hash{'authors'} = $authors if length($authors) > 1;
my $provides = $text =~ m/provides=\"(.*)\"".*/mg;
$hash{'provides'} = $1 if length($provides) >= 1;
if ($text =~ m/^provides=\"(.*)\"(.*)$/m) {
$hash{'provides'} = $1;
$hash{'provides_comment'} = $2;
}
my $requires = $text =~ m/^requires=\"(.*)\"".*$/mg;
$hash{'requires'} = $1 if length($requires) >= 1;
if ($text =~ m/^replaces=\"(.*)\"(.*)$/m) {
$hash{'replaces'} = $1;
$hash{'replaces_comment'} = $2;
}
# workaround for `builddir="$srcdir"/$_pkgname-$pkgver`
if ($text =~ m/^builddir=\"(.*)\"([^\s]*)/m) {
$hash{'builddir'} = $1 . $2;
}
if ($text =~ m/^options=\"(.*)\"(.*)$/m) {
$hash{'options'} = $1;
$hash{'options_comment'} = $2;
}
return \%hash;
}
@ -94,6 +113,7 @@ sub map_pypi_to_apk {
sub map_license {
my ($license) = @_;
$license //= '';
$license =~ s/ or / /g;
return $license;
@ -101,48 +121,131 @@ sub map_license {
sub get_source {
my ($distdata) = @_;
my $pkgname = $distdata->{info}{name};
my $source;
for my $url (@{$distdata->{urls}}) {
return $url->{url} if $url->{python_version} eq 'source'
if ($url->{python_version} eq 'source') {
$source = URI->new($url->{url});
last;
}
}
die "Unable to locate sources for $pkgname.\n" unless $source;
my $filename = ($source->path_segments)[-1];
my $pretty_path = substr($pkgname, 0, 1) . "/$pkgname";
my $pretty_url = $source->clone;
$pretty_url->path("/packages/source/$pretty_path/$filename");
my $response = $ua->head($pretty_url);
if ($response->is_success) {
return $pretty_url->as_string;
} else {
return $source->as_string;
}
die "Unable to locate sources for $distdata->{name}.\n";
}
sub read_apkbuild {
return read_assignments_from_file('APKBUILD');
}
sub format_line {
my $line = shift;
return "\t" . $line . "\n";
}
sub format_source {
my $srcurl = shift;
my $orig_src = shift;
$orig_src =~ s/^\s+//mg;
$orig_src =~ s/\s+/ /g;
my @sources = split (/\s/, $orig_src);
return $srcurl if @sources <= 1;
shift @sources if $sources[0] =~ m/pkgver/;
my $patches;
for my $patch (@sources) {
next if $patch eq "";
$patches .= format_line($patch);
}
return $srcurl . "\n" . ($patches // '') . "\t";
}
sub write_apkbuild {
my ($distdata, $apkbuild) = @_;
my $replaces = undef;
my $provides = undef;
my $authors = undef;
my $license = undef;
my $url = undef;
my $pkgname = undef;
my $pkgdesc = undef;
my $pkgrel = 0;
my $builddir = undef;
my $options = undef;
my $options_comment = undef;
my $orig_source = "";
if (our $use_homepage) {
$url =
$distdata->{info}{project_urls}{Homepage}
|| $distdata->{info}{home_page};
}
if (defined $apkbuild) {
$authors = $apkbuild->{authors};
$provides = $apkbuild->{provides};
$replaces = $apkbuild->{replaces};
$license = $apkbuild->{license};
$url = $apkbuild->{url};
$pkgname = $apkbuild->{pkgname};
$pkgdesc = $apkbuild->{pkgdesc};
$pkgrel = $apkbuild->{pkgrel};
$builddir = $apkbuild->{builddir};
$options = $apkbuild->{options} if defined $apkbuild->{options};
$options_comment = $apkbuild->{options_comment} if defined $apkbuild->{options_comment};
$orig_source = $apkbuild->{source};
if ($apkbuild->{pkgver} eq $distdata->{info}{version}) {
$pkgrel++;
}
}
my $pkgreal = $distdata->{info}{name};
my $srcurl = get_source($distdata);
my %repl = (
authors => ($authors or "# Contributor: $packager\n# Maintainer: $packager"),
pkgname => map_pypi_to_apk($distdata->{info}{name}),
pkgreal => $distdata->{info}{name},
pkgname => ($pkgname or map_pypi_to_apk($pkgreal)),
pkgreal => $pkgreal,
pkgver => $distdata->{info}{version},
pkgrel => $pkgrel,
source => get_source($distdata),
license => map_license($distdata->{info}{license}),
pkgdesc => $distdata->{info}{summary},
provides => ($provides or ''),
replaces => ($replaces or ''),
source => format_source($srcurl, $orig_source),
license => ($license or map_license($distdata->{info}{license})),
url => ($url or "https://pypi.org/project/${pkgreal}/"),
pkgdesc => ($pkgdesc or $distdata->{info}{summary} or "Python module for $pkgreal"),
builddir => ($builddir or ''),
options => ($options or ''),
options_comment => ($options_comment or ''),
);
$repl{compatibility} = "";
if ($replaces) {
my $comment = $apkbuild->{'replaces_comment'} // '';
$repl{compatibility} .= "\nreplaces=\"$replaces\"" . $comment;
}
if ($provides) {
my $comment = $apkbuild->{'provides_comment'} // '';
$repl{compatibility} .= "\nprovides=\"$provides\"" . $comment;
}
$repl{compatibility} .= "\n" if $replaces or $provides;
$repl{source} =~ s/-$repl{pkgver}/-\$pkgver/g;
$template =~ s/\[% (.*?) %\]/$repl{$1}/g;
open my $fh, '>:utf8', 'APKBUILD';
@ -154,8 +257,15 @@ sub write_apkbuild {
return \%repl;
}
sub unpack_source {
system('abuild checksum unpack');
}
sub prepare_tree {
system('abuild checksum unpack prepare');
my %options = @_;
unpack_source if $options{unpack};
system('abuild prepare');
}
sub find_package_name {
@ -188,42 +298,172 @@ sub find_package_name {
sub get_data {
my ($package) = @_;
my $response = $ua->get("https://pypi.python.org/pypi/$package/json");
my $response = $ua->get("https://pypi.org/pypi/$package/json");
$response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content);
return $distdata;
}
sub get_deps {
my ($data) = @_;
sub parse_requires_dist {
my $reqs = shift;
chdir "src/$data->{pkgreal}-$data->{pkgver}";
my $reqs = `python3 ./setup.py --requires`;
# Valid PyPI regex: https://peps.python.org/pep-0508/#names
my $pypi_regex = qr/(?i)([A-Z0-9][A-Z0-9][A-Z0-9._-]*[A-Z0-9])/;
my @reqs = split /\n/, $reqs;
my @depends =
map { m/$pypi_regex/; $1 || () }
grep { $_ !~ m/; extra ==/ }
@$reqs;
foreach my $i (0 .. $#reqs) {
$reqs[$i] =~ s/(\(|\s+).*$//;
$reqs[$i] = map_pypi_to_apk($reqs[$i]);
my @checkdeps =
map { m/$pypi_regex/; $1 || () }
grep { m/; extra == ["'](tests|pytest)["']/ }
@$reqs;
my %reqs = (
depends => \@depends,
checkdeps => \@checkdeps,
);
return \%reqs;
}
sub format_depends {
my $deps = shift;
$columns = 102;
$deps =~ s/ {2,}/ /g;
$deps =~ s/^\s//g;
$deps =~ s/\s$//g;
if ( length($deps) >= $columns ) {
$deps = wrap( "\t", "\t", $deps );
}
$deps =~ s/\s$//g;
chdir '../..';
if ( length($deps) >= $columns ) {
$deps = "\n" . $deps . "\n\t";
}
return $deps;
}
sub get_deps {
my ($distdata, $data) = @_;
my $reqs = parse_requires_dist($distdata->{info}{requires_dist});
my %depends = ('py3-pytest' => 'py3-pytest');
my @depends =
map {
my $apkname = map_pypi_to_apk($_);
if (exists $depends{$apkname}) { () }
else { $depends{$apkname} = $apkname }
}
@{$reqs->{depends}};
my @checkdeps =
map {
my $apkname = map_pypi_to_apk($_);
exists($depends{$apkname}) ? () : $apkname
}
@{$reqs->{checkdeps}};
my $apk = read_file('APKBUILD');
$reqs = join ' ', @reqs;
my $depends = format_depends(join ' ', @depends);
$apk =~ s/pymakedepends=""/pymakedepends="$reqs"/;
$apk =~ s/^depends=""/depends="$depends"/m;
unshift @checkdeps, 'py3-pytest';
my $checkdeps = format_depends(join ' ', @checkdeps);
$apk =~ s/^checkdepends="py3-pytest"/checkdepends="$checkdeps"/m;
# remove empty variables
$apk =~ s/.*=""\n//g;
$apk =~ s/.*="".{0,}\n//g;
open my $fh, '>:utf8', 'APKBUILD';
print $fh $apk;
say "Requires: $reqs";
say "Requires: @depends\n\nCheckDepends: @checkdeps";
}
sub write_old_deps {
my ($data, $apkbuild) = @_;
my $apk = read_file('APKBUILD');
if (my $depends = $apkbuild->{depends}) {
$apk =~ s/^depends=".*"/depends="$depends"/m;
}
if (my $makedeps = $apkbuild->{makedepends}) {
if ($makedeps =~ m/py3-gpep517/) {
$apk =~ s/^makedepends=".*"/makedepends="$makedeps"/m;
} else {
$apk =~ s/^makedepends="(.*)"/makedepends="$1 $makedeps"/m;
}
}
if (my $checkdeps = $apkbuild->{checkdepends}) {
if ($checkdeps =~ m/py3-pytest/) {
$apk =~ s/^checkdepends=".*"/checkdepends="$checkdeps"/m;
} else {
$apk =~ s/^checkdepends="(.*)"/checkdepends="$1 $checkdeps"/m;
}
}
# remove empty variables
$apk =~ s/.*="".{0,}\n//g;
open my $fh, '>:utf8', 'APKBUILD';
print $fh $apk;
}
sub update_builddir {
my $apkbuild = read_apkbuild;
my $pkgreal = $apkbuild->{'_pkgreal'};
my $pkgname = $apkbuild->{pkgname};
my $pkgver = $apkbuild->{pkgver};
my $oldbuilddir = $apkbuild->{builddir};
my $build_path = glob("
src/*${pkgver}/pyproject.toml
src/*${pkgver}/setup.py
");
if ($build_path) {
my $newbuilddir = dirname($build_path);
$newbuilddir =~ s/src/\$srcdir/;
$newbuilddir =~ s/$pkgreal/\$_pkgreal/;
$newbuilddir =~ s/$pkgver/\$pkgver/;
my $apk = read_file('APKBUILD');
if ($pkgname eq $pkgreal and
$newbuilddir eq '$srcdir/$_pkgreal-$pkgver') {
# this will be deleted by the remove empty
# variables regex in get_deps/write_old_deps
$apk =~ s/^builddir=".*"/builddir=""/m;
$newbuilddir = '<same as default, deleted>';
} elsif ($newbuilddir eq $oldbuilddir) {
return;
} else {
$apk =~ s/^builddir=".*"/builddir="$newbuilddir"/m;
}
print "\n\$builddir redefined:\n\t",
"OLD: $oldbuilddir, NEW: $newbuilddir\n\n";
open my $fh, '>:utf8', 'APKBUILD';
print $fh $apk;
}
}
my $abuild_conf = read_assignments_from_file('/etc/abuild.conf');
@ -234,95 +474,104 @@ $packager = $user_abuild_conf->{PACKAGER} if $user_abuild_conf->{PACKAGER};
sub usage {
say <<'EOF';
Usage: apkbuild-pypi [create <package> | check | recreate | upgrade | update]
Usage: apkbuild-pypi [create <package> [homepage] | check | recreate [deps] | upgrade | update]
In the repository root:
create <package>: Creates an APKBUILD for <package>
create <package> homepage: Creates an APKBUILD for <package> with url= field set to project homepage, if available
In the package root:
check : Reports current & latest version of the package
recreate : Recreates the APKBUILD
recreate [deps] : Recreates the APKBUILD [also recalculate dependencies]
upgrade : Upgrades to the latest version of the package
update : Updates APKBUILD metadata
EOF
}
given ($ARGV[0]) {
when ('create') {
my $package = $ARGV[1];
$package or die usage;
if (! defined $ARGV[0]) {
die usage;
} elsif ($ARGV[0] eq 'create') {
my $package = $ARGV[1];
$package or die usage;
my $distdata = get_data($package);
my $apkname = map_pypi_to_apk($package);
my $distdata = get_data($package);
my $apkname = map_pypi_to_apk($package);
mkdir $apkname;
chdir $apkname;
mkdir $apkname;
chdir $apkname;
my $data = write_apkbuild($distdata, undef);
prepare_tree;
if ($ARGV[2] and $ARGV[2] eq 'homepage') { our $use_homepage = 1; }
get_deps($data);
} when ('recreate') {
my $apkbuild = read_apkbuild;
if (! defined $apkbuild->{_pkgreal}) {
$apkbuild->{_pkgreal} = find_package_name($apkbuild);
}
my $distdata = get_data($apkbuild->{_pkgreal});
my $pkgver = $distdata->{info}{version} =~ s/^[^0-9]+//r;
if ($pkgver ne $apkbuild->{pkgver}) {
#Reset pkgrel on upgrade on recreate
say "Upgrading PyPI module from $apkbuild->{pkgver} to $pkgver";
$apkbuild->{pkgrel}=0;
}
my $data = write_apkbuild($distdata, $apkbuild);
my $data = write_apkbuild($distdata, undef);
unpack_source;
update_builddir;
prepare_tree;
get_deps($data);
} when ('upgrade') {
my $apkbuild = read_apkbuild;
if (! defined $apkbuild->{_pkgreal}) {
$apkbuild->{_pkgreal} = find_package_name($apkbuild);
}
my $distdata = get_data($apkbuild->{_pkgreal});
my $pkgver = $distdata->{info}{version};
if ($pkgver ne $apkbuild->{pkgver}) {
say "Upgrading PyPI package from $apkbuild->{pkgver} to $pkgver";
my $text = read_file('APKBUILD');
$text =~ s/^(pkgver)=.*$/$1=$pkgver/mg or
die "Can't find pkgver line in APKBUILD";
$text =~ s/^(pkgrel)=.*$/$1=0/mg or
die "Can't find pkgrel line in APKBUILD";
open my $fh, '>:utf8', 'APKBUILD';
print $fh $text;
close $fh;
} else {
say "Already up to date with PyPI";
}
} when ('check') {
my $apkbuild = read_apkbuild;
if (! defined $apkbuild->{_pkgreal}) {
$apkbuild->{_pkgreal} = find_package_name($apkbuild);
}
my $distdata = get_data($apkbuild->{_pkgreal});
my $pkgver = $distdata->{info}{version};
say "$apkbuild->{pkgname}: Latest version: $pkgver Packaged version: $apkbuild->{pkgver}";
if ($pkgver ne $apkbuild->{pkgver}) {
exit(1);
}
} when ('update') {
prepare_tree;
} default {
die usage;
get_deps($distdata, $data);
prepare_tree( unpack => 0 );
} elsif ($ARGV[0] eq 'recreate') {
my $apkbuild = read_apkbuild;
if (! defined $apkbuild->{_pkgreal}) {
$apkbuild->{_pkgreal} = find_package_name($apkbuild);
}
my $distdata = get_data($apkbuild->{_pkgreal});
my $pkgver = $distdata->{info}{version} =~ s/^[^0-9]+//r;
if ($pkgver ne $apkbuild->{pkgver}) {
#Reset pkgrel on upgrade on recreate
say "Upgrading PyPI module from $apkbuild->{pkgver} to $pkgver";
$apkbuild->{pkgrel}=0;
}
my $data = write_apkbuild($distdata, $apkbuild);
unpack_source;
update_builddir;
if ($ARGV[1] and $ARGV[1] eq 'deps') { get_deps($distdata, $data); }
else { write_old_deps($data, $apkbuild); }
prepare_tree( unpack => 0 );
} elsif ($ARGV[0] eq 'upgrade') {
my $apkbuild = read_apkbuild;
if (! defined $apkbuild->{_pkgreal}) {
$apkbuild->{_pkgreal} = find_package_name($apkbuild);
}
my $distdata = get_data($apkbuild->{_pkgreal});
my $pkgver = $distdata->{info}{version};
if ($pkgver ne $apkbuild->{pkgver}) {
say "Upgrading PyPI package from $apkbuild->{pkgver} to $pkgver";
my $text = read_file('APKBUILD');
$text =~ s/^(pkgver)=.*$/$1=$pkgver/mg or
die "Can't find pkgver line in APKBUILD";
$text =~ s/^(pkgrel)=.*$/$1=0/mg or
die "Can't find pkgrel line in APKBUILD";
open my $fh, '>:utf8', 'APKBUILD';
print $fh $text;
close $fh;
} else {
say "Already up to date with PyPI";
}
} elsif ($ARGV[0] eq 'check') {
my $apkbuild = read_apkbuild;
if (! defined $apkbuild->{_pkgreal}) {
$apkbuild->{_pkgreal} = find_package_name($apkbuild);
}
my $distdata = get_data($apkbuild->{_pkgreal});
my $pkgver = $distdata->{info}{version};
say "$apkbuild->{pkgname}: Latest version: $pkgver Packaged version: $apkbuild->{pkgver}";
if ($pkgver ne $apkbuild->{pkgver}) {
exit(1);
}
} elsif ($ARGV[0] eq 'update') {
prepare_tree( unpack => 1 );
} else {
die usage;
}

View File

@ -132,7 +132,7 @@ finalize()
fi
# Get CPU count
local cpucount=$(grep -c '^processor' /proc/cpuinfo)
cpucount=$(grep -c '^processor' /proc/cpuinfo || [ $? -eq 1 ])
if [ $cpucount -gt 1 -a -n "$(grep 'sibling.*2' /proc/cpuinfo)" ]; then
# Hyper-Threading enabled
cpucount=$(( $cpucount / 2 ))

View File

@ -17,21 +17,41 @@ fi
usage() {
cat >&2 <<-__EOF__
cat <<-__EOF__
$program $program_version - find ABI breakages in package upgrades
Usage: $program
Usage: $program [-h|--help]
Run in the directory of a built package.
Options:
-h, --help Print this help
__EOF__
}
args=$(getopt -o h --long help \
-n "$program" -- "$@")
if [ $? -ne 0 ]; then
usage >&2
exit 2
fi
eval set -- "$args"
while true; do
case $1 in
-h|--help) usage; exit 0;;
--) shift; break;;
*) exit 1;; # getopt error
esac
shift
done
if [ $# -gt 0 ]; then
usage
usage >&2
exit 2
fi
if ! [ -f "$ABUILD_CONF" ] && ! [ -f "$ABUILD_USERCONF" ]; then
if ! [ -f "$ABUILD_CONF" ] && ! [ -f "$ABUILD_USERCONF" ] && ! [ -f "$ABUILD_DEFCONF" ]; then
die "no abuild.conf found"
fi
@ -47,9 +67,15 @@ fi
startdir="$PWD"
tmpdir=$(mktemp -d -t checkpkg-script.XXXXXX)
trap "rm -rf '$tmpdir'" INT EXIT
trap "rm -rf '$tmpdir'; exit" INT EXIT
cd "$tmpdir" || die "failed to create temp dir"
# storage for downloaded/copied apks
mkdir -p apks
# default to pigz for unpacking
gunzip="$(command -v pigz || echo gzip) -d"
for i in $pkgname $subpackages; do
_pkgname=${i%%:*}
pkg=${_pkgname}-$pkgver-r$pkgrel
@ -65,18 +91,23 @@ for i in $pkgname $subpackages; do
[ -f "$filepath" ] || die "can't find $pkgfile"
# generate a temp repositories file with only the http(s) repos
grep -E "^https?:" /etc/apk/repositories > $tmpdir/repositories
grep -E "^https?:" /etc/apk/repositories > "$tmpdir"/repositories
oldpkg=$(apk fetch --repositories-file $tmpdir/repositories --simulate $_pkgname 2>&1 | sed 's/^Downloading //')
oldpkg=$(apk fetch --repositories-file "$tmpdir"/repositories --simulate $_pkgname 2>&1 | sed 's/^Downloading //')
if [ "${oldpkg}" = "${pkg}" ]; then
die "the built package ($_pkgname) is already in the repo"
fi
# For our local repo (newsize) apk info might return multiple packages, e.g. if different
# version of the package where build previously. Filter out this specific pkgver using awk.
newsize=$(apk info --repositories-file /dev/null --repository "$REPODEST"/$repo --size $_pkgname | \
awk "/^${pkg//+/\\+}/ { found = 1 } /^[0-9]+/ { if (found) { print \$0; exit } }")
oldsize=$(apk info --repositories-file $tmpdir/repositories --size $_pkgname | awk '/^[0-9]+/ { print $0 }' | head -1)
# apk info could return multiple lines if multiple packages share a provide
# (e.g. dnsmasq); filter with the exact package name and take the second line:
# 7zip-23.01-r0 installed size:
# 1668 KiB
newsize="$(apk info --repositories-file /dev/null --repository "$REPODEST"/$repo --size $_pkgname | \
grep -F "$pkg" -A1 | \
tail -n1)"
oldsize="$(apk info --repositories-file "$tmpdir"/repositories --size "$_pkgname" | \
grep -F "$oldpkg" -A1 | \
tail -n1)"
if [ "$oldsize" = "$newsize" ]; then
msg "No size differences for $_pkgname."
@ -84,22 +115,42 @@ for i in $pkgname $subpackages; do
msg "Size difference for $_pkgname: $oldsize -> $newsize"
fi
apk fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \
| tar -zt | grep -v '^\.SIGN\.' | sort > filelist-$_pkgname-old \
|| die "failed to download old pkg, maybe run 'apk update'?"
apk fetch --quiet --repositories-file "$tmpdir"/repositories --stdout "$_pkgname" > apks/old.apk \
|| msg2 "Old apk for $_pkgname missing. (new package/arch? broken internet?)"
tar -ztf "$filepath" | grep -v '^\.SIGN\.' | sort > "filelist-$_pkgname"
# pre-uncompress to not decompress twice
# we do a decompression + tar -t for the file list, but then later we might do a full extraction for sodiff.
# to not decompress here and then later again, store the intermediate tar
$gunzip -c 2>/dev/null < apks/old.apk > apks/old.tar &
$gunzip -c "$filepath" < "$filepath" > apks/new.tar &
wait
tar -t -f apks/old.tar 2>/dev/null | grep -v '^\.SIGN\.' | sort > "filelist-$_pkgname-old" &
tar -t -f apks/new.tar | grep -v '^\.SIGN\.' | sort > "filelist-$_pkgname-new" &
wait
diff -u "filelist-$_pkgname-old" "filelist-$_pkgname"
diff -U3 "filelist-$_pkgname-old" "filelist-$_pkgname-new"
if diff "filelist-$_pkgname-old" "filelist-$_pkgname" | grep '\.so' > /dev/null 2>&1; then
mkdir -p pkg
cd pkg
tar -zxf "$filepath" > /dev/null
diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
if diff -U0 "filelist-$_pkgname-old" "filelist-$_pkgname-new" | grep -q '\.so'; then
echo "SODIFF:"
mkdir -p "$_pkgname-pkg-old" "$_pkgname-pkg-new"
tar -C "$_pkgname-pkg-old" 2>/dev/null -x -f apks/old.tar > /dev/null &
tar -C "$_pkgname-pkg-new" -x -f apks/new.tar > /dev/null &
wait
# filter to things that start with -+ but strip the header (---/+++)
diff -U0 "filelist-$_pkgname-old" "filelist-$_pkgname-new" | grep -E '^(\+|-)[A-Za-z0-9]+' | grep '\.so' | while read -r diff_sofile; do
case "$diff_sofile" in
-*) path="$_pkgname-pkg-old"; sofile="${diff_sofile#\-}" ;;
+*) path="$_pkgname-pkg-new"; sofile="${diff_sofile#\+}" ;;
esac
# skip symlinks (only adds duplicate output or is dangling), and things that aren't valid elfs
# matching .so above matches anything with .so in the name, e.g. xyz.sourceforge
if ! [ -L "$path"/"$sofile" ] && readelf -h "$path"/"$sofile" >/dev/null 2>&1; then
echo "$diff_sofile: " "$(objdump -p "$path"/"$sofile" | grep SONAME)"
fi
done
cd ..
else
msg "No soname differences for $_pkgname."
fi

View File

@ -1,5 +1,6 @@
export CFLAGS="-Os -Wformat -Werror=format-security"
export CXXFLAGS="-Os -Wformat -Werror=format-security -D_GLIBCXX_ASSERTIONS=1"
export CFLAGS="-Os -fstack-clash-protection -Wformat -Werror=format-security"
export CXXFLAGS="-Os -fstack-clash-protection -Wformat -Werror=format-security"
export CXXFLAGS="$CXXFLAGS -D_GLIBCXX_ASSERTIONS=1 -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -D_LIBCPP_ENABLE_HARDENED_MODE=1"
export LDFLAGS="-Wl,--as-needed,-O1,--sort-common"
export GOFLAGS="-buildmode=pie -modcacherw -trimpath -buildvcs=false"
# Do note that these should work with at least GDC and LDC
@ -9,6 +10,7 @@ export JOBS=$(nproc)
export MAKEFLAGS=-j$JOBS
export SAMUFLAGS=-j$JOBS
export CARGO_BUILD_JOBS=$JOBS
export CMAKE_BUILD_PARALLEL_LEVEL=$JOBS
export CTEST_PARALLEL_LEVEL=$JOBS
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
@ -17,17 +19,17 @@ export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse"
export CTEST_OUTPUT_ON_FAILURE=ON
export CTEST_NO_TESTS_ACTION=error
export PERL_MM_USE_DEFAULT=1
SRCDEST=/var/cache/distfiles
# The package will be stored as $REPODEST/$repo/$pkgname-$pkgver-r$pkgrel.apk
# where $repo is the name of the parent directory of $startdir.
REPODEST=$HOME/packages/
# PACKAGER and MAINTAINER are used by newapkbuild when creating new aports for
# the APKBUILD's "Contributor:" and "Maintainer:" comments, respectively.
#PACKAGER="Your Name <your@email.address>"
#MAINTAINER="$PACKAGER"
# what to clean up after a successful build
CLEANUP="srcdir bldroot pkgdir deps"

View File

@ -64,7 +64,7 @@ hostspec_to_libc() {
}
readconfig() {
local _APORTSDIR _BUILDDIR _PKGDEST _SRCPKGDEST _REPODEST _SRCDEST
local _APORTSDIR _BUILDDIR _PKGDEST _SRCPKGDEST _REPODEST _SRCDEST _ABUILD_USERDIR
local _CC=gcc _CXX=g++ _LD=ld _CARCH _CHOST _CTARGET _CPPFLAGS _CFLAGS _CXXFLAGS _LDFLAGS
local _JOBS _MAKEFLAGS _PACKAGER _USE_COLORS _USE_CCACHE
local _BUILDCC _BUILDCXX _BUILDLD _BUILDCPPFLAGS _BUILDCXXFLAGS _BUILDCFLAGS
@ -76,6 +76,7 @@ readconfig() {
[ -n "${SRCPKGDEST+x}" ] && _SRCPKGDEST=$SRCPKGDEST
[ -n "${REPODEST+x}" ] && _REPODEST=$REPODEST
[ -n "${SRCDEST+x}" ] && _SRCDEST=$SRCDEST
[ -n "${ABUILD_USERDIR+x}" ] && _ABUILD_USERDIR=$ABUILD_USERDIR
[ -n "${CC+x}" ] && _CC=$CC
[ -n "${CXX+x}" ] && _CXX=$CXX
[ -n "${LD+x}" ] && _LD=$LD
@ -98,11 +99,11 @@ readconfig() {
[ -n "${USE_COLORS+x}" ] && _USE_COLORS="$USE_COLORS"
[ -n "${USE_CCACHE+x}" ] && _USE_CCACHE="$USE_CCACHE"
: ${ABUILD_DEFCONF:=${ABUILD_SHAREDIR:-$sharedir}/default.conf}
: ${ABUILD_CONF:=$sysconfdir/abuild.conf}
: ${ABUILD_USERDIR:=$HOME/.abuild}
: ${ABUILD_USERCONF:=$ABUILD_USERDIR/abuild.conf}
[ -f "$ABUILD_DEFCONF" ] && . "$ABUILD_DEFCONF"
: ${ABUILD_CONF:=$sysconfdir/abuild.conf}
[ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF"
ABUILD_USERDIR=${_ABUILD_USERDIR-${ABUILD_USERDIR:-$HOME/.abuild}}
: ${ABUILD_USERCONF:=$ABUILD_USERDIR/abuild.conf}
[ -f "$ABUILD_USERCONF" ] && . "$ABUILD_USERCONF"
APORTSDIR=${_APORTSDIR-$APORTSDIR}

View File

@ -32,7 +32,7 @@ is_github_url() {
prepare_rust() {
cat >>APKBUILD<<__EOF__
cargo fetch --target="$CTARGET" --locked
cargo fetch --target="\$CTARGET" --locked
__EOF__
}
@ -84,14 +84,14 @@ build_meson() {
cat >>APKBUILD<<__EOF__
abuild-meson \\
. output
output .
meson compile -C output
__EOF__
}
build_perl() {
cat >>APKBUILD<<__EOF__
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
perl Makefile.PL INSTALLDIRS=vendor
make
__EOF__
}
@ -105,7 +105,7 @@ __EOF__
build_python_gpep517() {
cat >>APKBUILD<<__EOF__
gpep517 build-wheel \\
--wheel-dir dist \\
--wheel-dir .dist \\
--output-fd 3 3>&1 >&2
__EOF__
}
@ -118,7 +118,8 @@ __EOF__
build_empty() {
cat >>APKBUILD<<__EOF__
# Replace with proper build command(s)
# Replace with proper build command(s).
# Remove if there is no build command.
:
__EOF__
}
@ -132,7 +133,7 @@ __EOF__
check_cmake() {
cat >>APKBUILD<<__EOF__
ctest --test-dir build --output-on-failure
ctest --test-dir build
__EOF__
}
@ -144,15 +145,16 @@ __EOF__
check_python_gpep517() {
cat >>APKBUILD<<__EOF__
python3 -m venv --clear --without-pip --system-site-packages testenv
testenv/bin/python3 -m installer dist/*.whl
testenv/bin/python3 -m pytest
python3 -m venv --clear --without-pip --system-site-packages .testenv
.testenv/bin/python3 -m installer .dist/*.whl
.testenv/bin/python3 -m pytest
__EOF__
}
check_empty() {
cat >>APKBUILD<<__EOF__
# Replace with proper check command(s)
# Replace with proper check command(s).
# Remove and add !check option if there is no check command.
:
__EOF__
}
@ -208,7 +210,7 @@ __EOF__
package_python_gpep517() {
cat >>APKBUILD<<__EOF__
python3 -m installer -d "\$pkgdir" \\
dist/*.whl
.dist/*.whl
__EOF__
}
@ -230,7 +232,7 @@ __EOF__
newaport() {
local newname="${1##*/}"
local pn=${newname%[-_][0-9]*}
local pv
local prearchive postarchive pv
local source=
is_url "$1" && source="$1"
@ -241,6 +243,10 @@ newaport() {
fi
pv=${newname%.t*} #strip .tar.gz .tgz .tar.bz2 etc
pv=${pv#*[a-z]}
prearchive=${source%/archive/*}
postarchive=${source#*/archive/}
postarchive=${postarchive#refs/tags/}
source="${prearchive}/archive/${postarchive}"
source="${source%.t*}/$pkgname-$pv.tar.gz"
elif [ "$pn" != "$newname" ]; then
pv=${newname#$pn[-_]}

View File

@ -1,7 +1,5 @@
# This is an example APKBUILD file. Use this as a start to creating your own,
# and remove these comments.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.
# Contributor: Your Name <youremail@domain.com>
# Maintainer: Your Name <youremail@domain.com>
@ -11,22 +9,22 @@ pkgrel=0
pkgdesc=""
url=""
arch="all"
license="GPL"
license="unknown"
depends=
depends_dev=
makedepends="$depends_dev"
install=
subpackages="$pkgname-dev $pkgname-doc"
source="https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
source="https://downloads.sourceforge.net/NAME/NAME-$pkgver.tar.gz"
builddir="$srcdir"/$pkgname-$pkgver
prepare() {
cd "$builddir"
default_prepare
# When needed add additional preparation below. Otherwise remove this function
}
build() {
cd "$builddir"
./configure --prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
@ -35,7 +33,6 @@ build() {
}
package() {
cd "$builddir"
make DESTDIR="$pkgdir" install
# remove the 2 lines below (and this) if there is no init.d script
@ -44,10 +41,9 @@ package() {
}
check() {
# uncomment the 2 lines below if there is a testsuite. we assume the testsuite
# uncomment the line below if there is a testsuite. we assume the testsuite
# is run using "make check", which is the default for autotools-based build systems.
# cd "$builddir"
# make check
}
md5sums="" #generate with 'abuild checksum'
sha512sums="" #generate with 'abuild checksum'

View File

@ -1,7 +1,10 @@
# Sample conf.d file for alpine linux
# Configuration for /etc/init.d/<SERVICE>
#
# Specify daemon options here.
#
# User (and group) to run <SERVICE> as.
#command_user="<USER>[:<GROUP>]"
sample_opts=""
# Additional arguments for <SERVICE> daemon.
#command_args=
# Comment out to disable process supervisor.
supervisor=supervise-daemon

View File

@ -1,14 +1,14 @@
#!/sbin/openrc-run
# Sample init.d file for alpine linux.
name="SampleService"
description="Sample init.d file for Alpine Linux"
name=
command="/usr/sbin/$name"
command_args="$sample_opts"
: "${command_user:="<USER>"}"
command="/usr/sbin/<SERVICE>"
: "${command_args:="--default-args"}"
command_background="yes"
start_stop_daemon_args="--user $sample_user:$sample_group"
pidfile="/run/$name.pid"
pidfile="/run/$RC_SVCNAME.pid"
depend() {
need net

View File

@ -141,7 +141,7 @@ abuild_fetch_locking_body() {
pid1=\$!
# give enough time for abuild-fetch to call curl
sleep 0.2
sleep 0.5
# the first stamp should not exist, second instance should block the retry
if [ -e stamp3 ]; then

View File

@ -15,6 +15,7 @@ init_tests \
abuild_keygen_kernel \
export ABUILD_SHAREDIR="$SRCDIR"/..
export ABUILD_USERDIR="$HOME"/.abuild
export GIT=false
export FAKEKEY="$SRCDIR/testdata/abuild.key"
export FAKEKEYPUB="$SRCDIR/testdata/abuild.key.pub"

View File

@ -9,9 +9,13 @@ init_tests \
abuild_sign_installed_missing_pub \
abuild_sign_installed_missing_priv \
abuild_sign_installed \
abuild_sign_owner
abuild_sign_owner_type_invalid \
abuild_sign_owner_type_default \
abuild_sign_owner_type_rsa \
abuild_sign_owner_type_rsa256
export ABUILD_SHAREDIR="$(atf_get_srcdir)/.."
export ABUILD_USERDIR="$HOME"/.abuild
init_keys() {
cp -ra "$(atf_get_srcdir)"/testdata/.abuild "$PWD"
@ -63,7 +67,14 @@ abuild_sign_installed_body() {
abuild-sign --installed
}
abuild_sign_owner_body() {
abuild_sign_owner_type_invalid_body() {
init_keys
atf_check -s exit:1 \
-e match:"abuild-sign: supported types are RSA and RSA256" \
abuild-sign -t DSA foo.tar.gz
}
abuild_sign_owner_type_default_body() {
init_keys
echo foo > .PKGINFO
tar -zcf foo.tar.gz .PKGINFO || atf_fail "Failed to create unsigned test archive"
@ -73,6 +84,34 @@ abuild_sign_owner_body() {
abuild-sign foo.tar.gz
atf_check -s exit:0 \
-o match:"0/0.*\.SIGN\.RSA" \
-o match:"0/0.*\.SIGN\.RSA\." \
tar -ztvf foo.tar.gz
}
abuild_sign_owner_type_rsa_body() {
init_keys
echo foo > .PKGINFO
tar -zcf foo.tar.gz .PKGINFO || atf_fail "Failed to create unsigned test archive"
atf_check -s exit:0 \
-e match:"Signed" \
abuild-sign -t RSA foo.tar.gz
atf_check -s exit:0 \
-o match:"0/0.*\.SIGN\.RSA\." \
tar -ztvf foo.tar.gz
}
abuild_sign_owner_type_rsa256_body() {
init_keys
echo foo > .PKGINFO
tar -zcf foo.tar.gz .PKGINFO || atf_fail "Failed to create unsigned test archive"
atf_check -s exit:0 \
-e match:"Signed" \
abuild-sign -t RSA256 foo.tar.gz
atf_check -s exit:0 \
-o match:"0/0.*\.SIGN\.RSA256\." \
tar -ztvf foo.tar.gz
}

View File

@ -10,11 +10,11 @@ init_tests \
abuild_invalid_filename \
abuild_usr_lib64 \
abuild_dbg_subpackage \
abuild_SETFATTR_in_dbg \
abuild_reproducible \
abuild_checksum_generation \
abuild_checksum_duplicates \
abuild_subpkg_dep_leak \
abuild_subpkg_libs \
abuild_py_providers_creation \
abuild_py_dependency_scan \
abuild_py_dependency_scan_conflict \
@ -23,11 +23,17 @@ init_tests \
abuild_invalid_pkgnames \
abuild_invalid_subpkgnames \
abuild_invalid_subpkg_version \
abuild_warn_pkgver_patch_version \
abuild_provide_pkgname \
abuild_validate_depends \
abuild_subpackage_arch \
abuild_large_doc_subpackage \
abuild_bigdocs \
abuild_pkgver_digit_letter_digit \
abuild_multiline_license \
abuild_license_spdx \
abuild_git_ceiling \
abuild_package_size_zero \
abuild_package_size_nonzero \
abuild_package_size \
abuild_keepdirs \
abuild_amove \
abuild_doc \
abuild_dev \
@ -37,7 +43,15 @@ init_tests \
abuild_cleanoldpkg \
abuild_path_with_spaces \
abuild_pyc_warn \
abuild_pyc
abuild_pyc \
abuild_setcap_binary \
abuild_setcap_binary_with_option \
abuild_command_provides \
abuild_gocache_dir \
abuild_cargo_home_dir \
abuild_fish_comp_split \
abuild_deps \
abuild_usr_merge
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
export ABUILD_CONF=/dev/null
@ -74,7 +88,7 @@ abuild_simple_pkg_without_deps_body() {
init_keys
cp -r "$testrepo"/pkg1 .
cd pkg1
atf_check -s exit:0 \
atf_check -s exit:0 -o ignore \
-e not-match:"WARNING" \
-e not-match:"fatal" \
abuild
@ -226,16 +240,6 @@ abuild_dbg_subpackage_body() {
fi
}
abuild_SETFATTR_in_dbg_body() {
init_keys
cp -ra "$testrepo"/dbgpkg .
cd dbgpkg
SETFATTR=true atf_check -s exit:0 \
-o match:"hello world" \
-e match:"Build complete" \
abuild
}
abuild_reproducible_body() {
init_keys
cp -ra "$testrepo" .
@ -248,12 +252,12 @@ abuild_reproducible_body() {
pkgs=$(abuild listpkg)
abuild || atf_fail "first build failed"
checksums=$(cd "$REPODEST"/testrepo/$arch && md5sum $pkgs)
checksums=$(cd "$REPODEST"/testrepo/$arch && sha512sum $pkgs)
echo "$checksums"
rm -r "$REPODEST"/testrepo
abuild || atf_fail "rebuild failed"
checksums2=$(cd "$REPODEST"/testrepo/$arch && md5sum $pkgs)
checksums2=$(cd "$REPODEST"/testrepo/$arch && sha512sum $pkgs)
echo "$checksums2"
if [ "$checksums" != "$checksums2" ]; then
@ -332,6 +336,35 @@ abuild_subpkg_dep_leak_body() {
|| atf_fail "subpkg-dep-leak-subpkg should not depend on tar"
}
abuild_subpkg_libs_body() {
init_keys
mkdir -p testrepo/pkg
cd testrepo/pkg
cat > APKBUILD <<-EOF
maintainer="Natanael Copa <ncopa@alpinelinux.org>"
pkgname="pkg"
pkgver=1.0
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
subpackages="\$pkgname-libs"
options="!check"
package() {
mkdir -p "\$pkgdir"/usr/lib
touch "\$pkgdir"/usr/lib/libfoo.so.1
}
EOF
abuild clean unpack prepare build rootpkg || atf_fail "abuild failed"
if ! [ -e pkg/pkg-libs/usr/lib/libfoo.so.1 ]; then
find pkg
atf_fail "libfoo.so.1 was not moved"
fi
}
abuild_py_providers_creation_body() {
init_keys
cp -ra "$testrepo" .
@ -395,14 +428,17 @@ abuild_valid_pkgnames_body() {
cp -ra "$testrepo"/test-pkgname .
cd test-pkgname
atf_check -s exit:0 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
TESTNAME=foo atf_check -s exit:0 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
TESTSUBNAME=foo atf_check -s exit:0 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
TESTNAME="more_+-2.0-complicated" atf_check -s exit:0 \
-e match:"Validating" \
abuild validate
}
abuild_invalid_pkgnames_body() {
@ -410,14 +446,20 @@ abuild_invalid_pkgnames_body() {
cp -ra "$testrepo"/test-pkgname .
cd test-pkgname
TESTNAME="" atf_check -s exit:1 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
TESTNAME="-foo" atf_check -s exit:1 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
TESTNAME="foo with spaces" atf_check -s exit:1 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
TESTNAME="width@at" atf_check -s exit:1 \
-e match:"Validating" \
abuild validate
TESTNAME="width=equal" atf_check -s exit:1 \
-e match:"Validating" \
abuild validate
}
abuild_invalid_subpkgnames_body() {
@ -425,11 +467,11 @@ abuild_invalid_subpkgnames_body() {
cp -ra "$testrepo"/test-pkgname .
cd test-pkgname
TESTSUBNAME="" atf_check -s exit:1 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
TESTSUBNAME="-foo" atf_check -s exit:1 \
-e match:"Checking sanity" \
abuild sanitycheck
-e match:"Validating" \
abuild validate
}
abuild_invalid_subpkg_version_body() {
@ -441,25 +483,108 @@ abuild_invalid_subpkg_version_body() {
abuild all
}
abuild_warn_pkgver_patch_version_body() {
abuild_provide_pkgname_body() {
init_keys
cp -ra "$testrepo"/test-pkgname .
cd test-pkgname
TESTPKGVER=1.0_p1 atf_check -s exit:0 \
-e not-match:'WARNING' \
abuild sanitycheck
TESTPKGVER=1.0p1 atf_check -s exit:0 \
-e match:'WARNING.*1.0_p1' \
abuild sanitycheck
TESTNAME=provided atf_check -s exit:1 \
-e match:"provides must not contain" \
abuild validate
TESTNAME=test TESTPROVIDES='test~1' atf_check -s exit:1 \
-e match:"provides must not contain" \
abuild validate
TESTNAME=test TESTPROVIDES='test=1' atf_check -s exit:1 \
-e match:"provides must not contain" \
abuild validate
TESTNAME=test TESTPROVIDES='test>1' atf_check -s exit:1 \
-e match:"provides must not contain" \
abuild validate
TESTNAME=test TESTPROVIDES='test<=1' atf_check -s exit:1 \
-e match:"provides must not contain" \
abuild validate
}
abuild_validate_depends_body() {
init_keys
cp -ra "$testrepo"/test-pkgname .
cd test-pkgname
TESTDEPENDS="foo" TESTMAKEDEPENDS="bar" \
atf_check -s exit:0 \
-e match:"Validating" \
abuild validate
TESTDEPENDS="foo=1.0 bar>=1.0" TESTMAKEDEPENDS="baz<=1.0 x<2.0 z>1 !blah" \
atf_check -s exit:0 \
-e match:"Validating" \
abuild validate
TESTDEPENDS="foo~1.0 bar>~1.0 baz<~1"
atf_check -s exit:0 \
-e match:"Validating" \
abuild validate
for i in "foo=bar" "foo=~1.0" "foo>1.0_invalid"; do \
TESTDEPENDS="$i" atf_check -s exit:1 \
-e match:"Validating" \
abuild validate
done
}
abuild_subpackage_arch_body() {
init_keys
cp -ra "$testrepo" .
cd testrepo/subpackage-arch
arch="$(abuild -A)"
for i in noarch all "$arch"; do
TESTSUBARCH="$i" abuild all
[ -f "$REPODEST/testrepo/$arch/test-pkgname-$i-1.0-r0.apk" ] || \
atf_fail "Failed to place $i arch subpackage correctly"
rm -rf "$REPODEST/testrepo"
done
}
abuild_large_doc_subpackage_body() {
init_keys
cp -ra "$testrepo"/large-doc-subpkg .
cd large-doc-subpkg
atf_check -s exit:0 -o ignore \
-e match:"-doc subpackage is unusually large" \
abuild all
}
abuild_bigdocs_body() {
init_keys
cp -ra "$testrepo"/large-doc-subpkg .
cd large-doc-subpkg
options=bigdocs atf_check -s exit:0 -o ignore \
-e not-match:"-doc subpackage is unusually large" \
abuild all
}
abuild_pkgver_digit_letter_digit_body() {
cp -ra "$testrepo"/test-pkgname .
cd test-pkgname
TESTPKGVER=1.0p1 atf_check -s exit:1 \
-e match:'ERROR.*version' \
abuild validate
}
abuild_multiline_license_body() {
cp -ra "$testrepo"/test-licenses .
cd test-licenses
abuild rootpkg
atf_check -o match:'^license = MIT AND GPL-3.0-only OR GPL-3.0-or-later AND BSD-Clause-4$' \
atf_check -o match:'^license = MIT AND \(GPL-3.0-only OR GPL-3.0-or-later AND BSD-4-Clause\)$' \
cat pkg/.control.test-licenses/.PKGINFO
}
abuild_license_spdx_body() {
cp -ra "$testrepo"/test-licenses .
cd test-licenses
TESTPKGVER=1.0_p1 atf_check -s exit:0 \
-e not-match:'WARNING' \
abuild validate
}
abuild_git_ceiling_body() {
init_keys
git init
@ -490,76 +615,136 @@ abuild_git_ceiling_body() {
abuild
}
create_fake_du() {
mkdir -p bin
cat > bin/du <<-EOF
#!/bin/sh
echo 0
EOF
chmod +x bin/du
PATH="$PWD/bin:$PATH"
}
abuild_package_size_zero_body() {
abuild_package_size_body() {
init_keys
mkdir -p test-size
create_fake_du
cd test-size
cat > APKBUILD <<-EOF
# Maintainer: Test User 123 <123@example.com>
# test package
pkgname="test-size"
pkgname="test-size"
pkgver="1.0"
pkgrel=0
pkgdesc='Dummy test package that has no files'
url='https://gitlab.alpinelinux.org/alpine/aports'
arch='noarch'
license='MIT'
install="\$pkgname.post-install"
install="\$pkgname-empty-script.post-install"
trigger="\$pkgname-empty-trigger.trigger=/"
subpackages="
\$pkgname-empty-noscript:_empty
\$pkgname-empty-script:_empty
\$pkgname-empty-trigger:_empty
\$pkgname-dirs:_dirs
\$pkgname-files:_files
\$pkgname-many:_many
\$pkgname-holes:_holes
\$pkgname-hardlink:_hardlink
\$pkgname-symlink:_symlink
"
# Test if multi line bc output is handle properly
export BC_LINE_LENGTH=1
package() {
mkdir -p "\$pkgdir"
}
_empty() {
mkdir -p "\$subpkgdir"
}
_dirs() {
mkdir -p "\$subpkgdir/a/ /v/e/r/y/ /d/e/e/p/ /d/i/r"
mkdir -p "\$subpkgdir"/b "\$subpkgdir"/c
}
_files() {
mkdir -p "\$subpkgdir"
cd "\$subpkgdir"
printf 'test\\n' > test
touch empty
mkdir -p dir
printf 'more\\n' > dir/more
printf 'size leak!\\n' > secret
chmod a-rwx secret
printf 'quoting and stuff\\n' > dir/"\\\$can't \\"touch \\\\this"
}
_many() {
mkdir -p "\$subpkgdir"
for i in \$(seq 10000); do
printf '\\n' > "\$subpkgdir/\$i"
done
}
_holes() {
mkdir -p "\$subpkgdir"
dd if=/dev/zero bs=1 seek=65534 count=1 of="\$subpkgdir"/holes
}
_hardlink() {
mkdir -p "\$subpkgdir"
cd "\$subpkgdir"
printf 'test\\n' > test
ln test link
ln test link2
}
_symlink() {
mkdir -p "\$subpkgdir"
ln -s / "\$subpkgdir"/link
}
EOF
cat > test-size.post-install <<-EOF
cat > test-size-empty-script.post-install <<-EOF
#!/bin/sh
echo 1
EOF
cat > test-size-empty-trigger.trigger <<-EOF
#!/bin/sh
echo 1
EOF
abuild rootpkg
# should be set to 1
atf_check -o match:'^size = 1$' \
cat pkg/.control.test-size/.PKGINFO
local i size
for i in \
empty-noscript:0 \
empty-script:1 \
empty-trigger:1 \
dirs:1 \
files:39 \
many:10000 \
holes:65535 \
hardlink:5 \
symlink:1 \
; do \
size=$(awk -F ' = ' '$1 == "size" {print $2}' pkg/.control.test-size-${i%:*}/.PKGINFO)
[ "$size" -eq "${i#*:}" ] ||
atf_fail "$i failed: got $size"
done
}
abuild_package_size_nonzero_body() {
abuild_keepdirs_body() {
init_keys
mkdir -p test-size
mkdir -p test-amove
cd test-size
cd test-amove
cat > APKBUILD <<-EOF
# Maintainer: Test User 123 <123@example.com>
# test package
pkgname="test-size"
pkgname="test-keepdirs"
pkgver="1.0"
pkgrel=0
pkgdesc='Dummy test package that has files'
pkgdesc='Dummy test package - keepdirs'
url='https://gitlab.alpinelinux.org/alpine/aports'
arch='noarch'
license='MIT'
options='keepdirs'
package() {
mkdir -p "\$pkgdir"
printf "%s" "very important data" > "\$pkgdir"/testfile
mkdir -p "\$pkgdir"/usr/bin
}
EOF
abuild rootpkg
# should not be set to 1
atf_check -o not-match:'^size = 1$' \
cat pkg/.control.test-size/.PKGINFO
abuild rootpkg || atf_fail "abuild rootpkg failed"
test -d pkg/test-keepdirs/usr/bin || atf_fail "$i failed"
}
abuild_amove_body() {
@ -569,8 +754,6 @@ abuild_amove_body() {
cd test-amove
cat > APKBUILD <<-EOF
# Maintainer: Test User 123 <123@example.com>
# test package
pkgname="test-amove"
pkgver="1.0"
pkgrel=0
@ -582,37 +765,49 @@ abuild_amove_body() {
\$pkgname-etc:_etc
\$pkgname-bin:_bin
\$pkgname-sbin:_sbin
\$pkgname-root:_root
\$pkgname-var:_var
\$pkgname-usr:_usr"
\$pkgname-usr:_usr
\$pkgname-space:_space"
package() {
mkdir -p "\$pkgdir"/etc \
"\$pkgdir"/bin \
"\$pkgdir"/sbin \
"\$pkgdir"/usr/bin \
"\$pkgdir"/usr/sbin \
"\$pkgdir"/var/lib/\$pkgname \
"\$pkgdir"/usr/share
touch "\$pkgdir"/etc/file \
"\$pkgdir"/etc/\$pkgname.conf \
"\$pkgdir"/bin/hello \
"\$pkgdir"/sbin/shello \
"\$pkgdir"/usr/bin/hello \
"\$pkgdir"/usr/sbin/shello \
"\$pkgdir"/root \
"\$pkgdir"/usr/sbin/space' ' \
"\$pkgdir"/var/lib/\$pkgname/testfile \
"\$pkgdir"/usr/share/a \
"\$pkgdir"/usr/share/b
ln -s dangling "\$pkgdir"/symlink
}
_file() {
amove etc/file
}
_etc() {
# leading and trailing /
amove /etc/
amove ///etc/
}
_bin() {
# trailing /
amove bin/
amove usr/bin///
}
_sbin() {
# no leading and trailing /
amove usr/sbin/shello
}
_root() {
# no /
amove sbin/shello
amove root
# symlink without existing target
amove symlink
}
_var() {
# leading /
@ -621,6 +816,11 @@ abuild_amove_body() {
_usr() {
# glob *
amove usr/share/*
! amove no-glob-match/*
}
_space() {
# with space
amove usr/sbin/space' '
}
EOF
@ -628,13 +828,16 @@ abuild_amove_body() {
for i in \
test-amove-file/etc/file \
test-amove-etc/etc/test-amove.conf \
test-amove-bin/bin/hello \
test-amove-sbin/sbin/shello \
test-amove-bin/usr/bin/hello \
test-amove-sbin/usr/sbin/shello \
test-amove-root/root \
test-amove-root/symlink \
test-amove-var/var/lib/test-amove/testfile \
test-amove-usr/usr/share/a \
test-amove-usr/usr/share/b \
test-amove-space/usr/sbin/space' ' \
; do \
test -f pkg/$i || atf_fail "$i failed"
[ -L pkg/"$i" ] || [ -e pkg/"$i" ] || atf_fail "$i failed"
done
}
@ -645,7 +848,6 @@ abuild_doc_body() {
cd foo
cat > APKBUILD <<-EOF
# Maintainer: Test User 123 <123@example.com>
# test package
pkgname="foo"
pkgver="1.0"
pkgrel=0
@ -683,7 +885,6 @@ abuild_dev_body() {
cd foo
cat > APKBUILD <<-EOF
# Maintainer: Test User 123 <123@example.com>
# test package
pkgname="foo"
pkgver="1.0"
pkgrel=0
@ -792,7 +993,6 @@ abuild_cleanoldpkg_body() {
for v in 0.9 1.0 1.1; do
cat > APKBUILD <<-EOF
# Maintainer: Test User 123 <123@example.com>
# test package
pkgname="foo"
pkgver="$v"
pkgrel=0
@ -805,7 +1005,7 @@ abuild_cleanoldpkg_body() {
mkdir -p "\$pkgdir"
}
EOF
CARCH=$arch atf_check -e not-empty abuild
CARCH=$arch atf_check -e not-empty abuild clean unpack rootpkg
done
done
@ -902,3 +1102,266 @@ abuild_pyc_body() {
atf_check -o match:"foo=1.0-r0" -o match:"pyc" \
grep install_if pkg/.control.foo-pyc/.PKGINFO
}
abuild_setcap_binary_body() {
init_keys
cp -ra "$testrepo"/setcap .
cd setcap
atf_check -s exit:1 \
-e match:"Found binary with extra capabilities" \
-e match:"Found setcap binary executable by others" \
abuild all
}
abuild_setcap_binary_with_option_body() {
init_keys
cp -ra "$testrepo"/setcap .
cd setcap
options=setcap atf_check -s exit:0 \
-e not-match:"Found binary with extra capabilities" \
-e match:"Found setcap binary executable by others" \
abuild all
}
abuild_command_provides_body() {
init_keys
mkdir testprovides
cd testprovides
cat >APKBUILD<<-EOF
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=testprovides
pkgver=1.0
pkgrel=0
pkgdesc="Dummy test package that installs a file and directory in path"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
prepare() { mkdir -p "\$builddir"; }
build() { true; }
check() { true; }
package() {
mkdir -p "\$pkgdir/usr/bin"
printf "%s\n" '#!/bin/sh' >"\$pkgdir/usr/bin/foo"
chmod +x "\$pkgdir/usr/bin/foo"
cp -a "\$pkgdir/usr/bin/foo" "\$pkgdir/usr/bin/foo@"
mkdir -p "\$pkgdir/usr/bin/dir/"
ln -s /usr/bin/not-on-the-host-system-but-in-a-dependency "\$pkgdir/usr/bin/link"
}
EOF
abuild rootpkg
atf_check \
-o match:"provides = cmd:foo=1.0-r0" \
-o not-match:"provides = cmd:foo@=1.0-r0" \
-o match:"provides = cmd:link=1.0-r0" \
-o not-match:"provides = cmd:dir=1.0-r0" \
grep '^provides = ' pkg/.control.testprovides/.PKGINFO
}
abuild_gocache_dir_body() {
init_keys
mkdir gocache-dir
cd gocache-dir
cat >APKBUILD<<-EOF
# Maintainer: Joe User <juser@example.com>
pkgname="gocache-dir"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
prepare() {
mkdir -p "\$builddir"
}
build() {
echo "dir:\$GOCACHE"
}
package() {
:
}
EOF
unset GOCACHE
MOVE_CACHES=1 \
atf_check -s exit:0 \
-o match:"dir:.*/tmp/go" \
abuild prepare build
}
abuild_cargo_home_dir_body() {
init_keys
mkdir cargo-home-dir
cd cargo-home-dir
cat >APKBUILD<<-EOF
# Maintainer: Joe User <juser@example.com>
pkgname="cargo-home-dir"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
prepare() {
mkdir -p "\$builddir"
}
build() {
echo "dir:\$CARGO_HOME"
}
package() {
:
}
EOF
unset CARGO_HOME
MOVE_CACHES=1 \
atf_check -s exit:0 \
-o match:"dir:.*/tmp/cargo" \
abuild prepare build
}
abuild_fish_comp_split_body() {
init_keys
mkdir fish-split-dir
cd fish-split-dir
cat >APKBUILD<<-EOF
# Maintainer: Joe User <juser@example.com>
pkgname="fish-split-dir"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
prepare() {
mkdir -p "\$builddir"
}
package() {
mkdir -p "\$pkgdir"/usr/share/fish/completions/
mkdir -p "\$pkgdir"/usr/share/fish/vendor_completions.d/
echo "comp" > "\$pkgdir"/usr/share/fish/completions/comp.fish
echo "comp" > "\$pkgdir"/usr/share/fish/vendor_completions.d/comp.fish
}
EOF
# test that there is a warning for the legacy dir existing
atf_check -s exit:0 \
-e match:"fish completions for programs should be located in /usr/share/fish/vendor_completions.d" \
abuild prepare build rootpkg
# now add the correct subpackage
echo 'subpackages="$pkgname-fish-completion"' >> APKBUILD
abuild clean prepare build rootpkg
if ! [ -d pkg/fish-split-dir-fish-completion/usr/share/fish/completions ]; then
echo "missing old dir"
exit 1
fi
if ! [ -d pkg/fish-split-dir-fish-completion/usr/share/fish/vendor_completions.d ]; then
echo "missing new dir"
exit 1
fi
}
create_mock_apk() {
mkdir -p usr/bin
cat > usr/bin/apk <<-EOF
#!/bin/sh
if [ "\$1" = "--print-arch" ]; then
echo 'aarch64'
exit 0
fi
printf 'apk %s\n' "\$*" >&2
EOF
chmod +x usr/bin/apk
ln -s apk usr/bin/abuild-apk
PATH="$PWD/usr/bin:$PATH"
}
abuild_deps_body() {
create_mock_apk
mkdir testdeps
cd testdeps
cat >APKBUILD <<-EOF
# Maintainer: Joe User <juser@example.com>
pkgname="testdeps"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
depends="foo"
makedepends="bar"
checkdepends="checkdep"
makedepends_host="hostdep"
makedepends_build="builddep"
EOF
# native build. pull in both depends and makedepends
# do not install in any --root
atf_check \
-e match:'Installing for build: foo bar checkdep$' \
-e match:'apk add .*--virtual .makedepends-testdeps foo bar checkdep' \
-e not-match:'apk add .*--root' \
abuild deps
# dont install checkdep with ABUILD_BOOTSTRAP
ABUILD_BOOTSTRAP=1 atf_check \
-e not-match:"apk add.*checkdep" \
abuild deps
# crosscompile:
# install makedepends_build without --root
# install makedepends_host with --root
CTARGET='s390x' CHOST='ppc64le' CBUILDROOT="$PWD/root" atf_check \
-e match:'Installing for build: builddep' \
-e match:'Installing for host: hostdep' \
-e match:'apk add .*--virtual .makedepends-testdeps builddep' \
-e not-match:'apk add.*--root.*builddep' \
-e match:'apk add .*--root.*hostdep' \
-e match:'apk add .*--arch s390x.*hostdep' \
-e not-match:'apk add.*checkdep' \
abuild deps
# crosscompile, set only CHOST
CHOST='armhf' atf_check \
-e match:'apk add.*builddep' \
-e not-match:'apk add.*--root.*builddep' \
-e match:'apk add.*--root.*--arch armhf.*hostdep' \
-e not-match:'apk add.*--arch armhf.*builddep' \
abuild deps
# Check shell_escape
atf_check \
-e match:"apk add .*--repository It's \\\\b'\"\"' \"escaped\"/.*" \
abuild -P "It's \b'\"\"' \"escaped\"" deps
}
abuild_usr_merge_body() {
init_keys
mkdir usrmergetest
cd usrmergetest
cat >APKBUILD <<-EOF
# Maintainer: Joe User <juser@example.com>
pkgname="usrmergetest"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
options="!check"
package() {
mkdir -p \
"\$pkgdir"/lib \
"\$pkgdir"/bin \
"\$pkgdir"/sbin
}
EOF
atf_check -s exit:0 \
-e match:"WARNING:.*: Packages must not put anything under /lib, use /usr/lib instead" \
-e match:"WARNING:.*: Packages must not put anything under /bin, use /usr/bin instead" \
-e match:"WARNING:.*: Packages must not put anything under /sbin, use /usr/bin instead" \
abuild
}

40
tests/checkapk_test Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
init_tests \
checkapk_help \
checkapk_invalid_opt \
checkapk_missing_abuild_conf \
checkapk_missing_apkbuild
DATADIR=$(atf_get_srcdir)/testdata
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
export ABUILD_CONF=/dev/null
export ABUILD_USERCONF=/dev/null
checkapk_help_body() {
atf_check -s exit:0 \
-o match:"Usage:" \
checkapk --help
}
checkapk_invalid_opt_body() {
atf_check -s not-exit:0 \
-e match:"Usage:" \
checkapk --invalid
}
checkapk_missing_abuild_conf_body() {
ABUILD_DEFCONF=/dev/null atf_check \
-s not-exit:0 \
-e match:"no abuild.conf found" \
checkapk
}
checkapk_missing_apkbuild_body() {
atf_check \
-s not-exit:0 \
-e match:"must be run in the directory of a built package" \
checkapk
}

View File

@ -1,6 +1,4 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="dbgpkg"
pkgver="1.0"
pkgrel=0

View File

@ -1,6 +1,4 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="invalid-filename"
pkgver="1.0"
pkgrel=0

View File

@ -0,0 +1,33 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname="large-doc-subpkg"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package to check if large doc subpackages cause a warning to be emitted"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
subpackages="$pkgname-doc"
source=""
prepare() {
mkdir -p "$builddir"
}
build() {
true
}
check() {
true
}
package() {
mkdir -p "$pkgdir/usr/bin"
cat >"$pkgdir/usr/bin/foo" <<EOF
#!/bin/sh
EOF
mkdir -p "$pkgdir/usr/share/doc/$pkgname"
dd bs=1024 count=$((3 * 1024)) if=/dev/random \
of="$pkgdir/usr/share/doc/$pkgname/large-file"
}

View File

@ -1,6 +1,4 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="lib64test"
pkgver="1.0"
pkgrel=0

View File

@ -1,6 +1,4 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="pkg-path-with-spaces"
pkgver="1.0"
pkgrel=0

View File

@ -1,6 +1,4 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="pkg1"
pkgver="1.0"
pkgrel=0

View File

@ -0,0 +1,31 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=setcap
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package that has an setcap binary but no setcap option"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
source=""
prepare() {
mkdir -p "$builddir"
}
build() {
true
}
check() {
true
}
package() {
mkdir -p "$pkgdir/usr/bin"
cat >"$pkgdir/usr/bin/foo" <<EOF
#!/bin/sh
EOF
chmod +x "$pkgdir/usr/bin/foo"
setcap cap_net_bind_service=+ep "$pkgdir/usr/bin/foo"
}

View File

@ -0,0 +1,22 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=${TESTNAME-test-pkgname}
pkgver="${TESTPKGVER-1.0}"
pkgrel=0
pkgdesc="Dummy subpackage arch"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
subpackages="$pkgname-$TESTSUBARCH:_sub:$TESTSUBARCH"
options="!archcheck"
check() {
true
}
package() {
mkdir -p "$pkgdir"
}
_sub() {
mkdir -p "$subpkgdir"
}

View File

@ -1,6 +1,4 @@
# Maintainer: Olliver Schinagl <oliver@schinagl.nl>
# test package
pkgname="${TESTNAME-test-licenses}"
pkgver="1.0"
pkgrel=0
@ -8,10 +6,10 @@ pkgdesc='Dummy test package that has multi-line licenses'
url='https://gitlab.alpinelinux.org/alpine/aports'
arch='noarch'
license='MIT AND
GPL-3.0-only OR
GPL-3.0-or-later AND
BSD-Clause-4
(GPL-3.0-only OR
GPL-3.0-or-later AND
BSD-4-Clause)
'
prepare() {

View File

@ -1,6 +1,4 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname=${TESTNAME-test-pkgname}
pkgver="${TESTPKGVER-1.0}"
pkgrel=0
@ -8,7 +6,10 @@ pkgdesc="Dummy test package that fails to build"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
provides="${TESTPROVIDES-provided}"
subpackages="${TESTSUBNAME-$pkgname-sub}:_sub"
depends="$TESTDEPENDS"
makedepends="$TESTMAKEDEPENDS"
prepare() {
mkdir -p "$builddir"