Compare commits

...

327 Commits

Author SHA1 Message Date
13bf342e37 build-base -> base-build 2020-05-11 08:00:05 -04:00
9e1fc4ed1a rootbld packages as a variable 2020-05-09 17:15:42 -04:00
056a61ccf5 POSIX-ish compatibility fixes 2020-05-04 15:19:12 -04:00
b12fd561c8 Abuild /bin/sh compatibility 2020-04-03 15:57:57 -04:00
Rasmus Thomsen
69fc8b8fc1 newapkbuild: use 'plain' buildtype for meson and 'None' buildtype for CMake
This way Meson and CMake will use the C{,PP,XX}FLAGS we've set in
`/etc/abuild.conf`. Without this change CMake and meson will overwrite
our CFLAGS with custom flags. Most importantly, they prefer -O1/-O2 over
our -Os.

See also: https://lists.alpinelinux.org/~alpine/devel/%3C2896c13070c508a49cbaa72c8fb7f34ea947358b.camel%40cogitri.dev%3E
2020-02-21 18:01:48 +01:00
Wictor Lund
6d741ffba8 abuild.in: in snapshot(), fix recursive calls
- Call "$abuild_path" instead of plain "abuild"
- Pass $forceroot as done elsewhere
2020-02-16 23:46:58 +01:00
Leo
af0c88e6ab set CARGO_HOME to $SRCDEST/cargo
CARGO_HOME tells cargo where to store installed dependencies, save it to
a directory in $SRCDEST so we don't need to download all dependencies
again when compiling a rust package.
2020-02-16 23:30:17 +01:00
Leo
e125a76489 newapkbuild: do out-of-source CMake builds by default
It is recommended by upstream CMake (it will warn when you do in-source
builds) to keep generated files away from the source.
2020-02-16 19:05:42 +01:00
Sören Tempel
d0828c0655 abuild: include $pkgname in temporary rootbld directory
This makes it easier to figure out to which build the directory belongs
to. Occasionally, I have many failed abuild rootblds in my /var/tmp and
including the $pkgname in the directory would help me associating the
directories with failed builds I recently executed.
2020-02-16 12:34:58 +01:00
Timo Teräs
bad781082d abuild: use stat instead of df to figure filesystem type
Fixes the error:
  df: .: can't find mount point

When running abuild inside a chroot when the root file system
mountpoint information is not necessarily directly available.
2020-02-08 12:51:10 +02:00
Timo Teräs
c9d3df08b3 functions.sh: exclusively use apk --print-arch to detect build arch
Originally "gcc -dumpmachine" was used to detect build gcc triplet.
However, abuild does not depend on gcc or build-base (but installs
it if needed to build) so gcc might not be there. Additionally
abuild-sign can be used standalone, and does not have gcc dependency.

Using ${CC:-gcc} is problematic in cross-compile, as CC might be
already set for the cross-compiler and would result giving the target
host triplet.

It was deemed simplest to use "apk --print-arch" exclusively to detect
the builder host type, or specify CBUILD manually. If there is need
to use abuild/abuild-sign on non-Alpine hosts withou apk, we can
later add fallback that uses "uname -m" to detect the architecture
and guess Alpine CBUILD from it.

Fixes #9974
Fixes: 5adf47c1 "functions.sh: use apk --print-arch for CARCH if gcc is missing"
Fixes: 95cd15c0 "functions.sh: dont die if gcc is missing"
2020-02-07 23:14:23 +02:00
Leo
57185172c5 fix typo in sample for pre and post install 2020-02-05 17:27:26 +01:00
Natanael Copa
5adf47c168 functions.sh: use apk --print-arch for CARCH if gcc is missing 2020-01-31 09:47:44 +00:00
kpcyrd
4f5b0a14bd abuild: explicitly sort apk content 2020-01-30 10:41:06 +00:00
kpcyrd
660f793d6d abuild: set fixed atime and ctime in tar 2020-01-30 10:41:06 +00:00
Leo
d5826968b7 abuild.in: add default bashcomp, zshcomp and fishcomp functions 2020-01-28 08:57:40 +00:00
Sören Tempel
d5f4982a9a abuild-keygen: make size of private key configurable
Previously, a key size of 2048 bits was hardcoded. While this is still
the default, it can now be changed. Additionally, the default key size
might be changed to 4096 in the future.
2019-12-23 15:12:14 +01:00
Natanael Copa
0d3dc71833 ==== release 3.5.0 ==== 2019-12-19 15:17:57 +00:00
Natanael Copa
478d4e9452 ==== release 3.5.0_rc3 ==== 2019-12-18 12:36:19 +00:00
Natanael Copa
ec96c604e9 abuild: fix building without git
fixes #9981
2019-12-05 08:32:30 +00:00
Natanael Copa
bb0324e398 abuild: fix applying patches from https
fix patches such as https://dev.alpinelinux.org/archive/domoticz/openzwave-1.6.patch

previously it would only work with the filenamename.patch::$url syntax
2019-11-28 12:46:12 +00:00
Natanael Copa
0745179c4f ==== release 3.5.0_rc2 ==== 2019-11-26 18:42:46 +00:00
Natanael Copa
80a2e6f8cf abuild: set SOURCE_DATE_EPOCH from rootpkg 2019-11-26 18:41:32 +00:00
Sören Tempel
918b7b1920 abuild: Fix abuild rootbld
Without this change abuild rootbld would fail with:

	touch: invalid date '@'

Because SOURCE_DATE_EPOCH wasn't set when abuild rootbld was used. This
is a bug introduced in 71d9d5233b9db3be91510addcb28721545d93185. Instead
of reverting the aforementioned commit move the SOURCE_DATE_EPOCH
initialization to a custom function and also call it from the abuild
rootbld function.

Fixes #9978
2019-11-14 10:36:33 +01:00
Natanael Copa
51d9e3bcb9 Revert "abuild: make built package reproducible"
The introduction of the --pax-options seems to confuse apk and resulted
in `BAD archive' errors.

This reverts commit f04a2ee34b28a38c4349ef1f94686a07afce730f.
2019-11-07 20:46:36 +00:00
Natanael Copa
95cd15c025 functions.sh: dont die if gcc is missing
abuild-sign does not use gcc.

fixes #9974
2019-11-07 16:02:47 +00:00
Natanael Copa
21dcfb1f21 ==== release 3.5.0_rc1 ==== 2019-11-07 15:39:35 +00:00
Natanael Copa
d8cfcd5dc9 abuild: detect /bin/sh dependency even if shebang has spaces
fixes !7
2019-11-07 15:39:35 +00:00
Fredrik Gustafsson
6d321050e5 Change permissions for sudo to 4555
Currently the permissions for abuild-sudo is set to 4111, this make it
impossible to move the sudo file after it has being created. Moving
the sudo file is needed by yocto when creating an apk-package of abuild.
The sudo binary in debian stretch since if debian does it, it can't be bad.

Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com>
2019-11-07 15:39:35 +00:00
Bart Ribbers
2162348a9a Allow round brackets in the license variable 2019-11-07 15:39:35 +00:00
Natanael Copa
71d9d5233b abuild: get the git commit date only when needed
getting the commit date can be timeconsuming so only do it once we need
it. We also re-use the ABUILD_LAST_COMMIT to speed up the operation.
2019-11-07 14:40:55 +00:00
Natanael Copa
114c0cf287 abuild: rename global last_commit to ABUILD_LAST_COMMIT
rename the global variable to upppercase.
2019-11-07 14:40:55 +00:00
Natanael Copa
1cfbdf688c abuild: fix git_* functions
Add -- to explicitly separate out the file path.

Let git_last_commit_epoch take an option with the hash.
2019-11-07 14:40:55 +00:00
Natanael Copa
f04a2ee34b abuild: make built package reproducible
Flags to make the tarball reproducible is taken from here:
http://h2.jaguarpaw.co.uk/posts/reproducible-tar/
2019-11-07 13:24:43 +00:00
Natanael Copa
672032a4be abuild-sign: dont set timestamp in gzip
This improves reproducibility of builds
2019-11-07 13:23:36 +00:00
Natanael Copa
b80a27b86a abuild-sign: use pigz if available
This is similar to what we do in abuild. It improves performance on
multicore machines.
2019-11-07 13:21:45 +00:00
Natanael Copa
5b34b696d4 abuild: set SOURCE_DATE_EPOCH to last commit date by default
set datestamps to be used in the built packages to date of commit. This
makes it much easier to have reproducible builds.
2019-11-07 12:06:24 +00:00
Natanael Copa
918cba2a77 make: install depends as virtual 2019-11-07 12:02:24 +00:00
Richard Mortier
b3dcf19ef7 make: add depends target
Signed-off-by: Richard Mortier <mort@cantab.net>
2019-11-07 12:01:13 +00:00
Natanael Copa
c486b3b4f3 allow override sharedir for testing
Aloow overrid sharedir with global ABUILD_SHAREDIR so we test the local
functions.sh instead of a system installed functions.sh
2019-11-07 11:42:23 +00:00
Natanael Copa
f3dc428ea0 rename datadir -> sharedir
abuild uses datadir as local variable in various functions. Rename the
global datadir to sharedir to avoid confusion.
2019-11-07 11:42:23 +00:00
Natanael Copa
43fb2c012e add basic tests using bats 2019-11-07 11:32:37 +00:00
Jakub Jirutka
a8f564287e newapkbuild: simplify source URL derived from GitHub URL
GitHub allows to reference https://github.com/<user>/<proj>/archive/<ver>.tar.gz
also as https://github.com/<user>/<proj>/archive/<ver>/<anything>.tar.gz.
2019-10-27 20:35:10 +01:00
Jakub Jirutka
6c3b2e6b58 newapkbuild: run cargo install with --locked
This forces cargo to install the exact versions of the dependencies
specified in Cargo.lock. This is essential for reproducible builds!
2019-10-27 13:50:53 +01:00
Natanael Copa
b09bdddff3 abuild: remove unused print_version function
the function is not used since commit  3379e675512d (abuild: print
version of built package early)
2019-10-01 16:56:47 +00:00
Natanael Copa
511b934182 abuild: add -V for print abuild version 2019-10-01 16:51:21 +00:00
Natanael Copa
66177eb5ec abuild: only set sysconfdir in functions.sh
we set sysconfdir in functions.sh so there is no need to set it in
abuild.
2019-10-01 16:20:53 +00:00
Leo
1c075c2855 Fix package version check on checkapk
The assignment of the oldpkg variable is missing the name of the package
2019-10-01 17:14:36 +01:00
Rasmus Thomsen
05eee44039 newapkbuild: add rust support 2019-10-01 17:12:19 +01:00
Joseph Burt
f9da71cc68 apkbuild-cpan.in: add 'configure' prereqs
Prereqs from the 'configure' phase also belong in makedepends
2019-10-01 17:08:51 +01:00
Joseph Burt
baf17c8dd7 apkbuild-cpan.in: always start pkgver with a digit
The 'version' string from CPAN can start with 'v...' or similar.
2019-10-01 17:08:51 +01:00
Leo
dbf0e80e62 Make default_dev move to /usr/share/pkgconfig 2019-10-01 17:01:11 +01:00
Leo
6e5bd59d6f Add support for parsing pkg-config files in /usr/share/pkgconfig 2019-10-01 16:37:42 +01:00
Natanael Copa
aa86438443 abuild: add amove func to move from $pkgdir to $subpkgdir
moving files and directories from $pkgdir to $subpkgdir is a common
pattern, so make a helper function for this.

usage: amove FILESPEC...

FILESPEC is a list of files or patterns/globs that will be exanded by
the shell.

amove will clean up empty directories after moving the files/dirs.

Example usage:

  amove 'usr/lib/lib*.a'
  amove 'etc/*.d' # moves both etc/conf.d and etc/init.d
  amove 'lib/*.so' 'usr/lib/*.so'

  cd "$pkgdir"
  find usr -name '*.h' | xargs amove

This is based on the work of Chloe Kudryavtsev:
https://github.com/alpinelinux/abuild/pull/92
2019-10-01 16:25:45 +01:00
Natanael Copa
610f1982ef Makefile: clean *.o files 2019-10-01 15:00:31 +01:00
Natanael Copa
f9707808ef abuild: various USE_CCACHE fixes
- set PATH in the rootbld environment so ccache is actually used.

- drop the check for command -v ccache. ccache will be pulled in as
  build dependency so we don't need to die if its missing.

- create ~/.ccache if missing rather than die. This directory will
  normally be created by ccache itself, but we need to create it so we
  can bind mount it incase of rootbld.

- don't die if ccache.conf is missing. ccache will create it.
2019-10-01 13:13:43 +00:00
Natanael Copa
3ca7660b66 abuild: only set up ccache in rootbld when USE_CCACHE is set
avoid install ccache and bind mount ~/.ccache when USE_CCACHE is not
set.

This fixes bind mount error when ~/.ccache is missing and USE_CCACHE is
unset.
2019-10-01 12:49:49 +00:00
Joseph Benden
b1b47140ea feat: add support for ccache
This introduces basic support for ccache, during packaging builds.

If you are building many packages, it is recommended to manually
increase the maximum size of the ccache cache. This is typically
achieved by modifying `~/.ccache/ccache.conf` and adjusting the
`max_size` setting.

Signed-off-by: Joseph Benden <joe@benden.us>
2019-09-30 12:08:17 +00:00
Richard Mortier
9be3a6c6a0 abuild: simplify depends_static
Should not be any significant functional difference.
2019-09-30 12:05:28 +00:00
tcely
5486d877c5 abuild: -static depends on -dev by default
When you have `-dev` and install `-libs-static`, for example,
it helps to only need to add one to `makedepends` instead of both.

After a grep of the current aports, it turns out matching the
prefix of `subpkgname` will be more useful.
2019-09-30 11:58:20 +00:00
Pete Dietl
7a8b3a8e7d Allow for git remote url to end in aports.git, (i.e., allow SSH git remotes) 2019-09-30 10:35:01 +00:00
Timothy Legge
6310405af8 apkbuild-pypi.in: fix bugs, upgrade for python3 only and add to make 2019-08-09 09:32:34 +00:00
Natanael Copa
0d4bb95046 gitignore apkbuild-pypi 2019-08-09 09:32:02 +00:00
Natanael Copa
9c284d4c33 abuild: convert -{alpha,beta,rc,pre} version suffixes from pkgconf
convert version suffixes in pkgconf modversion to something apk
can deal with.
2019-08-09 08:21:37 +00:00
Natanael Copa
7edafd8c75 abuild: verify that the pkgconf version is valid 2019-08-09 08:16:41 +00:00
Kaarle Ritvanen
baa554477e abuild: install dependencies from other repos 2019-08-07 14:30:46 +03:00
Kaarle Ritvanen
9a398eac0c abuild: remove recursive mode
This functionality is no longer needed by the build servers and is broken as it
does not handle
* provides= tags
* automatic dependencies added by trace_apk_deps()
* inter-repository dependencies
* circular dependencies caused by the unit tests in check()
2019-08-07 14:22:31 +03:00
Oliver Smith
c54d39d8aa abuild: rename makedepends_host virtual package
With a recent change in apk [1], virtual packages of the same name will
upgrade each other. Adjust abuild to this by not using the same virtual
package name for two types of dependencies.

This fixes the way crosscompilers are built in postmarketOS [2], which
is essentially the same as running this on Alpine's gcc aport:
$ cd aports/main/gcc
$ C_TARGET_ARCH=armhf CTARGET=armv6-alpine-linux-musleabihf \
  BOOTSTRAP=nobuildbase CBUILDROOT=/ abuild -r
...
>>> gcc-armhf: Installing for host:
(1/24) Upgrading .makedepends-gcc-armhf (20190714.104731 -> 20190714.104741)
(2/24) Purging binutils-armhf (2.31.1-r2)
...

[1] apk-tools.git 37fbafcd928c466c82c892a7868d686d710e5d07
    ("add: make virtual packages upgradeable (ref #9957)")
[2] https://gitlab.com/postmarketOS/pmaports/blob/master/cross/gcc-armhf/APKBUILD

Fixes: https://gitlab.alpinelinux.org/alpine/apk-tools/issues/10649
2019-08-05 11:57:21 +00:00
Leo
cb3a67edca add missing backslash on rmdir command 2019-07-30 05:48:40 +00:00
Natanael Copa
b8b8a651fc abuild: remove empty dirs in main package
clean up empty dirs
2019-07-17 13:57:17 +00:00
kpcyrd
ba16a67781 abuild: add SOURCE_DATE_EPOCH support 2019-07-17 13:11:20 +00:00
Pete Dietl
2c2a518ac7 change ~ to /home/pdietl 2019-07-17 12:47:12 +00:00
Pete Dietl
beb1b41054 abuild.in: fixup flags and usage text 2019-07-17 12:43:44 +00:00
Keith Maxwell
e476188c6f Better use license.lst in abuild sanitycheck
Before this change an invalid licence= in an APKBUILD will pass `abuild
sanitycheck`. '/usr/share/spdx/license.lst' contains one licence per line.
`grep -x` will match partial lines whereas `grep -w` will only match whole
lines.

An simple demonstration is with 'GPL-3.0' which is not a valid SPDX licence
identifier. 'GPL-3.0-only' and 'GPL-3.0-or-later' are valid licences.

```
$ grep --help
BusyBox v1.30.1 (2019-04-26 06:26:16 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...

Search for PATTERN in FILEs (or stdin)

✂
        -w      Match whole words only
        -x      Match whole lines only
✂
$ grep -w -F GPL-3.0 /usr/share/spdx/license.lst
GPL-3.0-only
GPL-3.0-or-later
$ grep -x -F GPL-3.0 /usr/share/spdx/license.lst
$
```
2019-07-17 12:06:32 +00:00
tcely
c9d6159637 abuild-fetch: use local insecure variable 2019-07-17 12:02:13 +00:00
tcely
59c1c4a97a abuild-fetch: when http:// was used, ignore https:// problems 2019-07-17 12:02:13 +00:00
tcely
7bd32679b3 abuild-fetch: add -k (insecure as in curl) option 2019-07-17 12:02:13 +00:00
Natanael Copa
b7fd57f681 newapkbuild: make python packages only depend on setuptools
They normally don't need the python3-dev.
2019-07-17 12:00:57 +00:00
Russ
bffe0efc06 newapkbuild: add py3-setuptools to python apkbuild
Seeing as the default python build/check/package apkbuild functions call `setup.py` and that relies on `py3-setuptools`, perhaps it should be added to the makedepends.

Inspiration from https://github.com/alpinelinux/aports/pull/7641#pullrequestreview-234326397
2019-07-17 12:00:11 +00:00
Leo
68a054e274 make default_static depend on depends_static
keeps it in line with other default_ functions.
2019-07-17 11:58:21 +00:00
Leo
1dd4382ea1 abuild.in: make is_x_package functions reliant on being given a name 2019-07-17 09:27:45 +00:00
Leo
f6bcaee895 Fix condition check for adding static libraries to -dev package.
This was the wrong way, we only want to add the static library to the
-dev package when there isn't a -static package.
2019-07-08 11:28:38 +00:00
Max Rees
297de93aef abuild-sudo: don't allow --keys-dir
Not allowing --allow-untrusted is obviously a good idea, but it can be
trivially bypassed if --keys-dir is allowed:

$ abuild-apk add foo-1-r0.apk
ERROR: foo-1-r0.apk: UNTRUSTED signature
$ abuild-apk --allow-untrusted add foo-1-r0.apk
abuild-apk: --allow-untrusted: not allowed option
$ cp -rp /etc/apk/keys /tmp/keys
$ cp untrusted.pub /tmp/keys
$ abuild-apk --keys-dir /tmp/keys add foo-1-r0.apk
(1/1) Installing foo (1-r0)
OK: 4319 MiB in 806 packages

If both --allow-untrusted and --keys-dir are not allowed, then it should
no longer be possible for an unprivileged member of the abuild group to
add an untrusted package.

$ abuild-apk --keys-dir /tmp/keys add foo-1-r0.apk
abuild-apk: --keys-dir: not allowed option
2019-06-20 11:36:40 +02:00
Natanael Copa
0b3f983772 ==== release 3.4.0 ==== 2019-06-14 12:13:23 +00:00
Natanael Copa
c26cc11905 ==== release 3.4.0_rc5 ==== 2019-06-12 12:33:07 +00:00
Timothy Legge
00beae32aa apkbuild-cpan.in: add OR to licenses to indicate perl_5 GPL or artistic is a choice 2019-06-12 12:28:42 +00:00
Oliver Smith
7a9683a07b abuild usage fix: fetch does not verify sources
Replace text in usage description of fetch that claims to verify sources
with a suggestion to use 'abuild fetch verify', which will actually
verify them.

'abuild fetch' alone will not verify sources, as it only executes the
fetch() function.
2019-06-12 12:27:14 +00:00
Keith Maxwell
40e6e9995b APKBUILD.5: match install_if example to abuild.in
This change makes the example in the description of install_if in the
APKBUILD man page match abuild.in:1791.
2019-06-12 12:24:44 +00:00
Russ
2122fa7476 newapkbuild: use current directory for cmake 2019-06-12 12:21:19 +00:00
tcely
49c7560c86 newapkbuild: quote pkgname and pkgver
These are strings after all and should be quoted even if not strictly necessary because of tradition excluding spaces from package names.
2019-06-12 12:20:35 +00:00
Leo
b743186dfe newapkbuild.in: add default check() for meson packages. 2019-06-12 12:19:58 +00:00
Oliver Smith
da4aca278f Cosmetic: newapkbuild: comment for check sections
Add a '# Check sections' comment, for consistency with the equally
commented build and package sections.
2019-06-12 12:18:59 +00:00
Oliver Smith
635a699365 newapkbuild: fix empty function regression
Since the obsolete 'cd "$builddir"' statements have been removed in [1],
build(), check() and package() can generate empty functions if no build
system is specified or if there is no default for the given build
system. newapkbuild will then fail, as it tries to parse the script it
generated:

$ cd /home/pmos && newapkbuild test
/usr/bin/abuild: /home/pmos/test/APKBUILD: line 18: syntax error: unexpected "}"
$ cat test/APKBUILD
...
build() {
}
...

Fix this by placing ":" in functions that would be empty.

[1]: f83d19ce79ab9f2dcc5238346a910cd18ae0f330
2019-06-12 12:18:59 +00:00
Natanael Copa
8d092443d9 ==== release 3.4.0_rc4 ==== 2019-05-03 19:01:19 +02:00
Natanael Copa
1de902f2fa abuild: fix -openrc to work with multiple subpackages
allow a single APKBUILD have multiple -openrc subpackages.
2019-05-03 18:35:44 +02:00
Leo
f263cb9f49 abuild.in: fix warning with gawk-5.0
awk: cmd. line:1: warning: regexp escape sequence `\#' is not a known regexp operator
2019-04-30 09:35:51 +00:00
Natanael Copa
0a7026a485 ==== release 3.4.0_rc3 ==== 2019-04-30 07:49:03 +00:00
Natanael Copa
cf86b45836 abuild: cleanup default_dbg
Run the loop in a subshell via a pipe so we dont need a subshell for
each iteration.

Use `if ...; then` to make code slightly more readable.

Fix a whitespace before tab while at it.
2019-04-30 07:41:23 +00:00
tcely
acf1fa5553 abuild: default_dbg: do not trigger trap with test failure
Resolves alpinelinux/abuild#71
2019-04-30 07:12:00 +00:00
Leo
ed88353836 abuild.in: remove duplicate options_has call 2019-04-29 21:40:06 +00:00
tcely
5b163c2d58 abuild: default_dbg: eliminate side effects
- do not overwrite variables

srcdir is very important for abuild operation

- quoted various paths
- use a sub-shell to contain directory changing

Resolves alpinelinux/abuild#58
2019-04-29 20:52:23 +00:00
Natanael Copa
dc41c1fc52 ==== release 3.4.0_rc2 ==== 2019-04-29 20:03:20 +00:00
Kevin Daudt
2e77e3390f abuild-clean: add option to make files writable before cleanup
Some projects might leave files which are not writable for the current
user. The cleanup process then fails and leaves files / directories
behind.

This can easily be fixed by making everything writable before removing
the files.

Add the option 'chmod-clean' which does just that.
2019-04-29 19:26:43 +00:00
tcely
1d854182dd abuild: change word choice in comment 2019-04-29 18:44:35 +00:00
Natanael Copa
30a60d4523 abuild: fix whitespace before EOL 2019-04-29 18:43:46 +00:00
Leo
b849aae4b9 abuild: provide a default_static() and static() functions
- Also check for static archives and warn on lack of static subpackage
2019-04-29 18:38:22 +00:00
Ikke
f83d19ce79 newapkbuild: remove obsolete cd statements
Since `$builddir` is officially supported and abuild automatically cd's to `$builddir`, it does not need to be part of the template anymore.
2019-04-29 18:34:03 +00:00
Mike Sullivan
369e7069b8 Revert "abuild: replace command -v with which to fix build issues"
This reverts commit 57f2830739e31f9c73d2edaf5103502fbdae6822.

https://github.com/alpinelinux/aports/pull/7203 fixes the original problem
2019-04-29 18:33:37 +00:00
Timothy Legge
29bf802907 apkbuild-cpan.in: Update licenses to spdx format and remove redundant directory change 2019-04-29 18:32:46 +00:00
tcely
77746a0c3d abuild-fetch: enable curl certificate verification 2019-04-29 18:31:58 +00:00
tcely
d733d5e570 APKBUILD.5: sort depends_* descriptions 2019-04-29 18:30:55 +00:00
Luca Weiss
915c7d868b functions: adjust armhf triplet
From what I could find, it was changed to -musleabihf during the Alpine
3.6 release cycle but this function was never updated to reflect that
2019-04-29 18:19:25 +00:00
Natanael Copa
c0dc7acee7 Revert "abuild: unset depends for subpackages"
Apparently there are many packages that does soemthing like:

subpackages="$pkgname-foo:_foo"

_foo() {
	depends="$depends something-else"
}

and thus depend on the previous behavior. We need to revert and plan
this better.

This reverts commit 8fbbffd201a28a06804c7f6d3a2b5cd948c6ce07.
2019-04-25 12:41:22 +00:00
Sören Tempel
ff4f2253c1 APKBUILD.5: document depends_* variables for -doc and -openrc 2019-04-09 18:02:00 +02:00
Sören Tempel
f92353f57b abuild: add depends_libs variable to default_libs()
Other subpackage such as -dev, -doc and even -openrc allow adjusting
depends of the subpackage through such a variable. This is, for
instance, useful to remove a dependency of the origin package from the
-libs subpackage.

While at it document it in APKBUILD(5).
2019-04-09 18:01:44 +02:00
Natanael Copa
e2a012cba6 ==== release 3.4.0_rc1 ==== 2019-04-05 07:11:50 +00:00
Timothy Legge
629a780b1c get and use pkgdesc from cpan api data if the module has no metadata files (returnes unknown) 2019-04-03 16:07:03 +00:00
tcely
801578a06a abuild: -openrc should not inherit depends 2019-04-03 16:06:09 +00:00
Chloe Kudryavtsev
6a6310f030 Add default_cleanup_srcdir
In some cases, a simple rm -rf is not sufficent to clean srcdir.
One such case is the new go module system, that marks everything as
read-only - thus only letting root rm -rf it without a chmod.
There is a command intended to clean them - `go clean -modcache`.
However, for that to work, GOPATH must be defined and existent.
Running chmod for all srcdir cleanups makes no sense, nor does enforcing
root, or putting global overrides just for go.

This patch allows overriding what happens on `cleanup srcdir`, by
overriding cleanup_srcdir, and allows the use of default_cleanup_srcdir.

In our go example, it might be used as such:

cleanup_srcdir() {
	go clean -modcache
	default_cleanup_srcdir
}
2019-04-03 15:59:54 +00:00
Chloe Kudryavtsev
30d296ddb3 Make clean() use cleanup()
Avoid DRY issues, and increase consistency.
2019-04-03 15:57:14 +00:00
Natanael Copa
8fbbffd201 abuild: unset depends for subpackages
make sure that subpackages does not inherit main package's depends.
2019-03-21 13:42:36 +01:00
Natanael Copa
0238acc51d apkbuild-cpan: use $pkgver in source url
replace litteral version string with $pkgver in source url
2019-03-21 12:52:30 +01:00
Natanael Copa
67181962bf apkbuild-cpan: include modules that used to be part of core
we need to check if a given module currently is a part of core. Modules
which have a first_release may have been removed later, for example
Module::Build.
2019-03-21 12:28:11 +01:00
Natanael Copa
122bcd7cb2 apkbuild-cpan: remove prepare function from APKBUILD
the generation of Makefile is comparable with running configure, which
we normally do in the build() function, not in prepare.

also fix some whitespace damamge.
2019-03-21 11:34:06 +01:00
Timothy Legge
ede4203749 apkbuild-cpan.in fix issue with version check 2019-03-20 17:10:15 +00:00
Timothy Legge
422199858c apkbuild-cpan.in fix issues with update, recreate, etc 2019-03-20 17:10:15 +00:00
Timothy Legge
f98db143cb Many of setings should come from module not release api 2019-03-20 17:10:15 +00:00
Timothy Legge
c893530293 Fix for issue with apkbuild-cpan upgrade 2019-03-20 17:10:15 +00:00
Timothy Legge
27c430cc64 Updates for metacpan 2019-03-20 17:10:15 +00:00
Robert Hencke
0126fbdffb abuild-sudo: remove unused variable
This prevents clang from issuing a warning here.
2019-03-14 15:46:11 +01:00
Natanael Copa
0b86c457f3 ==== release 3.3.1 ==== 2019-03-05 11:45:16 +00:00
Oliver Smith
a54d3ba2ae abuild-tar.static: fix undefined reference errors
Link against the same libs as abuild-tar and fix the order of the CC
arguments.
2019-03-05 11:43:50 +00:00
Andrei Belov
2d2be1ca1b abuild-sign: actually catch errors while signing 2019-03-05 11:42:15 +00:00
Mike Sullivan
57f2830739 abuild: replace command -v with which to fix build issues 2019-03-05 11:28:04 +00:00
Carlo Landmeter
0a79fc62c9 Allow forcing of colored output
In some cases (ie drone ci) there is no tty available but its still
possible to display colors in the webui.
2019-02-25 23:10:16 +00:00
Natanael Copa
376ccc5bd6 abuild: add support for pkg-config prefix pcprefix
Fix issue when two -dev packages provides same pkg-config wil but with
different versions. For example libressl-dev and openssl-dev both ships
libssl.pc and libcrypto.pc, which resulted in automatic provides of
pc:libssl and pc:libcrypto.

apk would end up picking libressl-dev over openssl-dev for packages that
had automatic pc:libssl depends (for example libssl2-dev), when
openssl-dev was the one that was used during build.

To fix this we add support for a pcprefix so we can set
pcprefix="libressl:" in libressl APKBUILD which makes libressl-dev
provide pc:libressl:libssl. This is similar to what we do with
sonameprefix.

We do not yet automatically detect when the prefixed variant should be
used so for now we will have to explicitly add libressl-dev.

ref #9959
2019-02-22 13:57:08 +00:00
Natanael Copa
22753f5701 ==== release 3.3.0 ==== 2019-01-23 18:22:31 +00:00
Disassembler
9b04be2f79 abuild: replace $0 with $abuild_path, add $forceroot where missing 2019-01-10 16:08:51 +00:00
Natanael Copa
909623950f abuild: use pigz to compress control.tar.gz and manpages 2019-01-10 16:08:51 +00:00
Natanael Copa
bbe4a4fdfd abuild-sign: fall back to libressl if openssl is missing
openssl binary may be missing while migrating system from libressl to
openssl. Make sure we can always sign the backage if either is there.
2019-01-10 16:08:51 +00:00
Natanael Copa
832ab44934 ==== release 3.3.0_pre2 ==== 2019-01-09 16:28:33 +01:00
Natanael Copa
13aec9a141 abuild: avoid add depends to itself
packages should never depend on themselves which does not make sense.
This may happen if main package depends on a subpackage, then the
subpackages will inherit the global depends and the subpackage ends up
depend on itself.

Fix abuild to avoid this.
2019-01-09 16:23:46 +01:00
Carlo Landmeter
2f8bbc819e abuild: fix typo 2018-12-02 19:50:28 +00:00
Tiago Ilieve
0bfe4efa99 abuild.in: add multithreaded compression
The 'Compressing data' step takes a significant amount of time when
packaging software with huge binaries, like Kubernetes. This can
certainly be shortened using multithreaded compression, like 'pigz'.
2018-11-08 10:27:47 +00:00
Timo Teräs
100202920b abuild: print build start, end date and elapsed time 2018-11-08 11:55:46 +02:00
Sören Tempel
17cb68e9fb abuild-rmtemp: Do not follow symbolic links
Symbolic links might point to files outside of the chroot and
thus might delete files outside the chroot. This allows deletion
of arbitrary directories on the host from a malicious APKBUILD.

Following hard links shouldn't be a problem since hard links (usually)
cannot refer to directories and since remove(3) removes the link, not
the file it points to it shouldn't cause a problem.

I noticed this because alpine-baselayout creates /var/run as a symlink
to /run. Therefore causing /run to be deleted on the host when using
abuild-rmtemp which in turn causes a bunch of software to no longer
function properly (including OpenRC).
2018-10-11 17:46:45 +02:00
Natanael Copa
70f52b9b80 ==== release 3.3.0_pre1 ==== 2018-10-03 12:58:27 +00:00
Natanael Copa
324a57592e abuild: run build actions via runpart
So we make sure chdir $builddir happens when it should.
2018-10-03 12:46:18 +00:00
Natanael Copa
0bf61ee06a abuild: do not run check in fakeroot by default
Only run check in fakeroot if options="checkroot" is set. This makes
options="!checkroot" the default.

I expect most checks work as non-root, and if a testsuite requires root,
it will likely fail in fakeroot too. Fakeroot has also shown lower
performance for parallel builds.
2018-10-03 12:37:08 +00:00
Natanael Copa
3379e67551 abuild: print version of built package early
instead of printing abuild version, print package version. This is to
avoid confuse the abuild version with the package version.
2018-10-03 12:16:07 +00:00
Natanael Copa
2fe29d5829 abuild: chdir to $builddir if it exists
chdir to $builddir before running prepare, build, package or check.
2018-10-03 12:06:13 +00:00
Natanael Copa
4e455979e0 abuild: fix regression. run build
fix regression introduced in def219994d2dff3c2bd47eee76826dc79e042b2f
2018-10-03 12:06:13 +00:00
Natanael Copa
def219994d abuild: require package() function
make a missing function for package() a hard error.

this means we never run build in fakeroot.
2018-10-03 11:21:15 +00:00
Sören Tempel
015f0f69a8 checkapk: remove temporary dir on SIGINT and exit 2018-10-03 10:52:13 +00:00
Natanael Copa
51830efbb5 newapkbuild: fix checksums to be last in ABPKUILD
ref https://github.com/alpinelinux/abuild/pull/42
2018-10-03 10:50:25 +00:00
Natanael Copa
1cbc853155 abuild: fix checksum update
Fix case where 1) checksum is a single line and 2) there is a variable
under the checksum that should be kept. For example:

  sha512sum="...."
  keepthis="..."

Previously the `keepthis` variable would have been removed.

ref https://github.com/alpinelinux/abuild/pull/41
2018-10-03 10:34:58 +00:00
Natanael Copa
c6609b4739 move logic of curl's http range error to abuild-fetch
Move the logic of deleting partial downloads to abuild-fetch, which
knows if it is curl or wget that was executed.
2018-10-03 09:23:16 +00:00
Oliver Smith
07d9f3bf6b Fix: incomplete partfile gets renamed to distfile
Abuild-fetch uses curl (fallback to wget) to download files. They are
saved with a ".part" extension first, so they can be resumed if
necessary. When the download is through, the ".part" extension gets
removed. However, when the server does not support resume of downloads
(e.g. GitHub's on the fly generated tarballs), then the ".part"
extension got removed anyway. Abuild aborts in that case. But when
running a third time, the distfile exists and it is assumed that this
is the full download.

Changes:
* abuild-fetch:
  * Only remove the ".part" extension, when curl/wget exit with 0
  * Pass the exit code from curl/wget as exit code of abuild-fetch
  * Wherever abuild-fetch would return an exit code on its own, the
    codes have been changed to be > 200 (so they don't collide with
    curl's as of now 92 exit codes)
  * Remove undocumented feature of downloading multiple source URLs at
    a time. This doesn't match with the usage description, was not used
    in abuild at all and it would have made it impossible to pass the
    exit code.
* abuild:
  * After downloading, when curl is installed and abuild-fetch has
    33 as exit code (curl's HTTP range error), then delete the partfile
    and try the download again.
2018-10-03 08:33:52 +00:00
A. Wilcox
3d0080de5e newapkbuild.1: fix mdoc style 2018-10-03 08:24:18 +00:00
A. Wilcox
6cc2e53f3f APKBUILD.5: fix mdoc syntax warnings 2018-10-03 08:24:18 +00:00
A. Wilcox
e073ce1890 docs: Add checkdepends variable 2018-10-03 08:24:18 +00:00
A. Wilcox
10181d9f94 man: Clarify arguments to install scripts 2018-10-03 08:24:18 +00:00
A. Wilcox
03d07e200f man: Better document install scripts 2018-10-03 08:24:18 +00:00
A. Wilcox
8eb4be6c78 man: remove obsolete !libc_* options 2018-10-03 08:24:18 +00:00
A. Wilcox
6a71529fe3 man: Write requested improvements to documentation 2018-10-03 08:24:18 +00:00
A. Wilcox
3e9503bc83 Add initial manpage drafts 2018-10-03 08:24:18 +00:00
prspkt
7fc859d626 sample.APKBUILD: use https for sourceforge download links 2018-09-24 21:43:49 +02:00
prspkt
9aef4769d1 newapkbuild: use https for sourceforge download links 2018-09-24 21:43:49 +02:00
Jakub Jirutka
1820691b94 newapkbuild: fix default check function for python3
`setup.py check` does not run package tests, it performs just some check
of the package metadata. The correct command is `setup.py test`.
2018-07-29 16:21:29 +02:00
Natanael Copa
07b6609d74 ==== release 3.2.0 ==== 2018-06-22 07:24:10 +00:00
Oliver Smith
a68354ebc5 newapkbuild: check arguments and improve usage()
Changes:
* argument sanity checks:
  * `PKGNAME[-PKGVER] | SRCURL`
    * check if missing
    * check if specified more than once (see below)
  * specifying more than one buildtype flag
  * `-n` (set pkgname) without using SRCURL as last argument
  * `-s` (sourceforge source) without using PKGNAME as last argument
* Typo fix: exist -> exists
* `usage()`:
  * always print PKGNAME and PKGDESC (instead of NAME and DESC,
    NAME was used in one place and PKGNAME in another)
  * link to <https://spdx.org/licenses/>
  * `-m` (meson) flag was missing in short usage line at the top
  * indicate that the buildtypes are exclusive
  * `-c` flag: remove "to new directory" wording to make the
    message shorter (this should be obvious)
  * remove empty line at the end

NOTE: Before this commit, the `PKGNAME[-PKGVER] | SRCURL` was allowed
to be specified more than once, and the code looped over the arguments.
But this was not documented in `usage()` and had unexpected results:

```
$ newapkbuild first second third
$ tree
.
___ first
    ___ APKBUILD
    ___ first
    ___ ___ APKBUILD
    ___ ___ first
    ___ ___ ___ APKBUILD
    ___ ___ ___ src
    ___ ___ src
    ___ src
```
2018-06-21 15:30:58 +00:00
Natanael Copa
0bb0bd8498 ==== release 3.2.0_rc2 ==== 2018-05-31 16:43:10 +02:00
Natanael Copa
c0a862930c abuild: fix race when stripping
scanelf may pick up tempfiles created by strip or setfattr since it runs
in spearate process and pipes the out to a subshell. This causes a race
and may lead to the while loop attempt to strip seomthing that no longer
exists.

We fix that by test if file exists before try manipulate it. We could
have written he file list to a temp file first, but this way we benefit
from multiple cores working in parallel.
2018-05-31 16:37:31 +02:00
A. Wilcox
75b8cacaf0 newapkbuild: move checksum call to after fetch
unpack will no longer unpack without a checksum, even with -f.  This
means that newapkbuild will not be able to deduce what kind of build
system is contained within, so the templates for CMake, Perl, etc are
never used.

This patch ensures checksumming is done right after fetch, so that
unpack works properly.
2018-05-24 17:58:55 +02:00
A. Wilcox
db5ca2996a newapkbuild: fix typo 2018-05-24 17:58:55 +02:00
Jakub Jirutka
6c2fc64d74 newapkbuild: create check() function 2018-05-07 22:33:12 +02:00
Jakub Jirutka
1264917824 newapkbuild: change python to python3 2018-05-07 22:22:26 +02:00
Jonathan Sieber
20f5ea679b abuild: Fix usage info about package command
abuild package misleadingly stated that it will create packages in
$REPODIR (suggesting that it actually creates apks).
2018-04-25 00:10:15 +02:00
Sören Tempel
720a2c185e abuild.in: don't fail if git describe fails
`git describe` by default looks for tags, but `git clone` does not clone
tags by default which causes failures on travis currently.

Also redirect `git describe` errors to /dev/null while being here.
2018-04-22 16:21:21 +02:00
Natanael Copa
be30cda326 ==== release 3.2.0_rc1 ==== 2018-04-17 21:06:32 +00:00
Natanael Copa
6d2d09840f abuild: fix unxz with threading
busybox unxz does not support --threads/-T option
2018-04-17 21:02:28 +00:00
Natanael Copa
fd97176583 abuild: simplify optional git usage
set git=true if git is missing so all git commands are ignored. This
simplifies the code a bit
2018-04-17 16:52:54 +00:00
Carlo Landmeter
6fc2f40a0d abuild: add multithread decommpressing support 2018-04-15 18:33:57 +00:00
Carlo Landmeter
683225c064 abuild: allow SPDX license operators
valid operators are AND OR WITH
2018-04-11 20:33:39 +00:00
Manuel Tiago Pereira
38620eeb9f Make file missing in source var explicit.
I've forgot to add a patch file to the source variable in an APKBUILD,
altought I did add it to the sums variable.

The error message made it
seem that I've forgot to add the file to the source directory, which led
me to check if my build system was missing the files for some reason.

Only after reading the `abuild.in` file did I understood what happened.

Hopefully this change makes the message clearer and more helpful.
2018-04-11 15:34:14 +00:00
Jonathan Neuschäfer
33183dadf5 Fix a few typos 2018-04-11 14:09:32 +00:00
Carlo Landmeter
e6ce1f1151 abuild: check license for valid SPDX license identifiers
licenses will be checked against the license.lst file provided by
the spdx-licenses-list package when installed except when explicitly
disabled by the !spdx options flag.
2018-04-11 14:07:36 +00:00
Oliver Smith
4501a6cc5e Don't print 'git: not found' errors
abuild, as packaged in Alpine Linux, does not depend on git. But when
you use it without git, it will print out errors like the following:

/usr/bin/abuild: line 2554: git: not found

With this commit, it saves the git_path in the beginning (just like
abuild_path). Later in the code it does not try to run git if that
variable is empty.

Notably `abuild rootbld` is already checking whether `abuild-rootbld`
is installed, and that subpackage of `abuild` does already depend on
`git`. So no additional check was added before using `git ` inside
`rootbld`.

Fixes #32
2018-03-20 15:09:58 +01:00
Oliver Smith
6981f3a6ae abuild: Change -f (force) to not ignore checksums/init scripts
The force flag used to skip the following functions, without any
documentation in the help (-h) output:

  * verify (checksum verification)
  * initdcheck (check if the init scripts are openrc scripts)
  * check_arch (check if the target architecture is in "arch=")
  * check_libc (check if the target libc is masked in the options)

This was counter-intuitive and could even be dangerous (when one relies
on the checksum verification to prevent man-in-the-middle attacks, but
always uses the -f flag).

With this commit, it only skips check_arch and check_libc besides the
package up to date check and the help output mentions this.
2018-03-16 00:40:07 +01:00
Sören Tempel
54dbf5f383 abuild: set arch for -openrc subpackage to noarch 2018-03-11 16:29:00 +01:00
Sören Tempel
f5eb69a5bd abuild: add postcheck for -openrc subpackage 2018-03-11 16:29:00 +01:00
Sören Tempel
45529e54d2 abuild.in: ensure that $triggers is not in $source
Since we already check that $install is not in $source is does make
sense to also check that $triggers is not in $source.
2018-03-11 15:56:02 +01:00
William Pitcock
051d2ced74 rootbld: if networking is enabled, copy resolv.conf into the build root 2018-03-08 00:48:04 +00:00
Natanael Copa
f1dfa55428 abuild: fix typo 2018-02-20 18:02:07 +00:00
Natanael Copa
e970c74b0e abuild: add sanitycheck of provides
provides cannot contain the pkgname or apk will be very unhappy.
2018-01-02 14:22:42 +01:00
Oliver Smith
d007f7967c newapkbuild: fix typo 2017-12-30 10:46:02 +01:00
Nils Andreas Svee
55cef04cf9 abuild: add triplet definitions for mips architectures 2017-12-11 09:04:46 +02:00
William Pitcock
0ea273ebca rootbld: allow the fake $HOME to be writable
this is needed for running some test runners such as kyua under rootbld.
2017-11-15 00:11:14 +00:00
William Pitcock
f7b19c3454 abuild: rootbld: run testsuites if requested, also handle package() only builds 2017-11-10 21:34:27 +00:00
William Pitcock
3225884ed3 abuild: rootbld: fix order of bind-mounts given to bwrap
when building a package with abuildd, a copy of the git checkout is cloned to /tmp, which
causes difficulties.
2017-11-08 05:18:10 +00:00
William Pitcock
4b24af9e9f abuild: add support for provider_priority
provider_priority is a number which determines what priority a package should be
given when solving a dependency graph using a provides entry instead of a direct
package, in the event of conflicts.
2017-11-02 04:51:51 +00:00
Sören Tempel
800e4a8187 newapkbuild.in: fix package_meson by escaping $pkgdir 2017-10-28 10:35:16 +02:00
Carlo Landmeter
573925a0dc abuild: add env option to require tests
This adds an env option REQUIRE_CHECK to require testsuites to
be run. This does not clutter getopts so it can be safely removed
afterwards when we enforce tests globally. This will allow our CI
infrastructure to enforce testsuites where possible.
2017-10-26 22:14:11 +02:00
Natanael Copa
6261608ece ==== release 3.1.0 ==== 2017-10-25 13:48:15 +00:00
Natanael Copa
919e549a04 abuild: use provides = cmd:foo instead of 'command:foo'
it is slightly shorter
2017-10-24 13:42:38 +00:00
William Pitcock
4dfc57946e abuild: log command: providers 2017-10-20 14:53:34 +00:00
A. Wilcox
83f37d0076 newapkbuild: use make 'package' phase for CMake as well 2017-10-19 13:25:24 +02:00
Sören Tempel
17eb90499e newapkbuild: always set makedepends in newaport 2017-10-19 10:49:39 +02:00
Sören Tempel
22fe641721 newapkbuild: add command line flag for cmake to getopts
It is documented in the help output but didn't work because getopts(1)
didn't check for that option. I am assuming the person who added cmake
support simply forgot to adjust the getopts line.
2017-10-19 10:42:11 +02:00
Sören Tempel
f91242fe39 newapkbuild: add support for meson 2017-10-19 10:40:28 +02:00
Natanael Copa
0f9d333305 ==== release 3.0.2 ==== 2017-09-28 10:43:46 +00:00
Natanael Copa
a2f839fd27 abuild: only print version if we are building
The purpose was to show abuild version in the build logs
2017-09-28 10:43:28 +00:00
A. Wilcox
dc4f5cb972 abuild: fix typo 2017-09-28 10:01:10 +03:00
A. Wilcox
0296de9cd1 newapkbuild: detect CMakeLists.txt file for CMake
Some CMake packages do not have cmake/ directory, but all have
CMakeLists.txt present in the root directory.
2017-09-28 10:01:10 +03:00
Timo Teräs
545eed3a24 abuild: rootbld: reflect build branch in the builder hostname 2017-09-27 14:58:56 +03:00
Timo Teräs
4736a56c8e abuild: do not try to strip standalone elf images
Guile uses ELF is internal object format, and creates them as
"no machine" and "standlone" OSABI. Scanelf supports printing
OSABI, so use that to filter these out.
See: https://github.com/alpinelinux/aports/pull/1714

This also removes unneccessary 'sed' from the pipeline as it's
simple to read each field outputted by scanelf.
2017-09-26 07:27:49 +00:00
tmpfile
56b8d45079 abuild.in: remove saveas- syntax and fix sourcecheck()
As discussed in alpinelinux/aports#1438
saveas- was removed from abuild-fetch.c with https://github.com/alpinelinux/abuild/pull/20 but abuild.in slipped.
Also fixes a wget -s instance that's not supported by recent busybox (-s was changed for --spider).
/cc @kaniini
2017-09-19 12:02:57 +00:00
A. Wilcox
71157f9cdc git: ignore abuild-rmtemp executable 2017-09-19 12:02:57 +00:00
A. Wilcox
c1a106cc6c abuild-rmtemp: define _XOPEN_SOURCE to ensure FTW_DEPTH is visible 2017-09-19 12:02:57 +00:00
A. Wilcox
f1faef7868 abuild: ensure a package has deps before printing them
After the first dep is printed, `shift` is called to avoid the special
case where the first dep cannot have a comma prepended.  However,
if there are no deps for a package (seen early on in the aports main
repo in acf-jquery), $# is 0.  POSIX specifies that `shift` has two
options when the shift operand (1) is greater than $#:

- if non-interactive, it can exit the shell
- if it does not exit the shell, it must return a non-zero exit code

Since we run the shell with -e, the second case folds in to the first.

BusyBox ash does not implement this behaviour, but bash does when called
as /bin/sh or when the `posix` shopt is set.
2017-09-19 12:02:57 +00:00
A. Wilcox
2b709f7e20 git: ignore abuild-gzsplit 2017-09-19 12:02:57 +00:00
Natanael Copa
d03366f80c abuild: avoid print version multiple times
and respect -q flag
2017-09-19 11:59:18 +00:00
Breno Leitao
da720069ca abuild: Always print the builder version
Currently is hard to discover what abuild version was used on a build log.
This lack of information makes it hard to reproduce a buld failure.

This change simply adds the abuild version at all logs.
2017-09-19 11:59:18 +00:00
tmpfile
0ab473f28a apkbuild-pypi.in: modernize 2017-09-19 11:59:18 +00:00
Natanael Copa
95a9455b5a ==== release 3.0.0 ==== 2017-09-19 11:09:44 +00:00
Natanael Copa
9a63a17228 abuild: exit with success if arch is disabled
the set -e made script exit early
2017-09-19 11:08:13 +00:00
William Pitcock
eb0a7d0811 abuild: prepare_metafiles: use new /bin/sh virtual instead of hardcoded busybox dependency 2017-08-05 22:03:13 +00:00
A. Wilcox
a74359e8e2 abuild: Add default split OpenRC function 2017-07-26 16:00:12 +00:00
Kaarle Ritvanen
829a501de7 abuild-sudo: prevent forging of user name 2017-07-20 15:14:43 +03:00
Natanael Copa
443fc07c79 abuild: print url we are fetching
This is useful for debugging
2017-07-20 08:08:17 +00:00
Natanael Copa
1efaa3996e abuild: add sanitycheck for secfixes comment
The secfixes comment will be parsed and added to alpine-secdb. add
sanitycheck so we catch errors early.
2017-07-20 08:08:17 +00:00
Natanael Copa
3923c36af9 ==== release 3.0.0_rc4 ==== 2017-07-17 18:08:16 +02:00
Natanael Copa
6f60008bc4 abuild-sudo: fix segfault when there are no controlling term
if there are no controlling reminal getlogin() may return NULL. We use
getpwuid() to try figure out the username and verify that we actually
have a username before we set environment USER.
2017-07-17 17:24:07 +02:00
Kaarle Ritvanen
f92283f5b9 ==== release 3.0.0_rc3 ==== 2017-07-17 15:35:23 +03:00
Kaarle Ritvanen
90d62ca5e0 abuild: rootbld: require metapackage 2017-07-16 19:29:54 +03:00
Kaarle Ritvanen
4aa6e2ddff abuild: rootbld: improve version compatibility 2017-07-16 19:19:24 +03:00
Kaarle Ritvanen
e7404e1633 abuild: rootbld: require envsubst 2017-07-16 19:19:24 +03:00
Timo Teräs
91de00773f apkbuild-cpan: separate './Build test' to check step 2017-07-11 15:05:10 +03:00
Timo Teräs
37cbcc6d99 apkbuild-cpan: perl no longer has '.' in path, add it for prepare() 2017-07-11 15:04:12 +03:00
tmpfile
ba1d1a3d61 apkbuild-cpan: modernize 2017-07-11 15:02:18 +03:00
Kaarle Ritvanen
cf18bf6ed9 abuild: rootbld: make mkusers work 2017-07-06 17:45:20 +03:00
Kaarle Ritvanen
ee52fee11c abuild: rootbld: always require repo template 2017-07-06 16:17:31 +03:00
Kaarle Ritvanen
e3a2e14ffa abuild: build in chroot
This patch is based on earlier work by Timo Teräs.
2017-06-27 14:52:50 +03:00
Kaarle Ritvanen
5a4e6f3889 abuild-sudo: enforce correct value for USER 2017-06-27 14:52:50 +03:00
Kaarle Ritvanen
440bb02fd7 abuild-sudo: allow commands with '-' in the name 2017-06-27 14:52:50 +03:00
Kaarle Ritvanen
6ff70e3763 abuild: disable trap when entering the handler 2017-06-27 14:52:50 +03:00
Carlo Landmeter
9605ce1792 abuild: add config option to globally enable dbg 2017-06-27 08:06:45 +02:00
A. Wilcox
610bf6c281 abuild: fix bad git merge 2017-06-23 18:56:00 +03:00
A. Wilcox
27005a2cb0 newapkbuild: fix usage output 2017-06-23 11:27:41 +03:00
A. Wilcox
f39ef92cde abuild: use portable awk exponentiation operator 2017-06-23 11:27:41 +03:00
A. Wilcox
597a7f167b abuild: call tar portably 2017-06-23 11:27:41 +03:00
A. Wilcox
9dd4a70eb3 abuild: Correctly comment default_dbg 2017-06-23 11:27:41 +03:00
A. Wilcox
67f297d3ac abuild: Add verbose option '-v' to show everything 2017-06-23 11:27:41 +03:00
Andrej
56355bff21 Allow $patch_args to pass multiple arguments to patch 2017-06-21 18:15:06 +00:00
Henrik Riomar
5268ae8076 abuild-sudo.c: setgid as well
set our gid to root so apk commit hooks run with the same gid as when
running  "sudo apk add ..." from command line.
2017-06-21 18:14:48 +00:00
Shiz
79525de509 abuild: add !checkroot option to run tests without fakeroot
Due to fakeroot being very permissive with regards to file permissions,
some package testsuites that explicitly check for failing permission checks
will fail.

For those testsuites, give the APKBUILD the option to run the tests outside
of a fakeroot environment.
2017-06-21 18:14:32 +00:00
tmpfile
f9132fad76 abuild-fetch.c: remove saveas- syntax 2017-06-21 18:14:18 +00:00
Oliver Smith
3d74cd9e8e Add parameter '-D' for alternative APKINDEX description
This patch allows to set a nice description for the APKINDEX, in case
the aport that is being built is not inside a git repository.

I have tested it, and it behaves exactly like without the patch,
even when git is not installed, or the folder is not inside a git repository:
The `|| true` at the end of the DESCRIPTION= line makes sure, aport
does not get aborted, just like it does not get aborted in that case
as of now, as the `git describe` command gets executed in a subshell.
2017-06-21 18:13:18 +00:00
A. Wilcox
c8253dc83a abuild: More readable message for missing dependencies 2017-06-12 09:39:46 +00:00
Timo Teräs
035a68ab11 functions.sh: add armel triplet 2017-06-01 10:55:30 +00:00
Jakub Jirutka
5dfb7a3634 newapkbuild: fix build_cmake template - escape parameters 2017-05-19 21:19:00 +02:00
Andrej
033349d31c Fix false set -e termination
`readconfig()` would return the result of `[ -z "$CBUILDROOT" ]` condition (line 123) and trigger shell termination in abuild.
This also fixes building packages with a different $CTARGET and therefore cross-compile tools.
2017-04-27 06:34:44 +00:00
Breno Leitao
5b7b1f80cb abuild: Add support for lzip source packages
Currently abuild does not understand .tar.lz packages, which blocks
the inclusion of certain packages in Alpine Linux.

I found this issue when adding 'ed' package to the repository. With
this change, abuild package will now depend on lzip package. I might
send a patch for abuild's APKBUILD.
2017-04-08 16:28:09 +00:00
Sören Tempel
c95263d877 remove explicit || return 1 from all sample APKBUILDs
Those statement are no longer needed because abuild now runs with
`set -e` by default.

See also: 36d5193776180385a39626a83241822736a5f6b8
2017-04-05 10:30:44 +00:00
Natanael Copa
ecc1f509c6 abuild: set -e fix for update_config_{sub,guess} 2017-04-04 13:12:48 +00:00
William Pitcock
1ddc910eb3 abuild: wrap check() with fakeroot 2017-03-27 19:38:38 +00:00
William Pitcock
dec68bd03f abuild: use new PKG_CONFIG_MAXIMUM_TRAVERSE_DEPTH env variable to disable the SAT solver 2017-03-27 06:00:03 +00:00
Natanael Copa
0a2f7b14c2 ==== release 3.0.0_rc2 ==== 2017-03-24 11:32:43 +00:00
Natanael Copa
76f3ac4058 abuild: fix -K option
make sure we don't delete files when -K is specified

fixes #7008
2017-03-24 11:32:09 +00:00
William Pitcock
834cb718f6 abuild: if ABUILD_BOOTSTRAP environment variable is set, do not ever enable check() or checkdepends 2017-03-21 09:28:34 +00:00
Natanael Copa
3b61bfb644 abuild: fix runpart
we need to run the function for runpart in the same shell, otherwise we
will lose the global variables set in the split functions.
2017-03-21 08:05:44 +00:00
Natanael Copa
9c1595dc42 functions: fix abuild -A
fix so abuild -A does not exit with error if gitbase fails

this was introduced with the set -e
2017-03-20 16:13:07 +00:00
Natanael Copa
c2e91c2f66 ==== release 3.0.0_rc1 ==== 2017-03-20 12:34:00 +00:00
Kaarle Ritvanen
36d5193776 abuild: enable -e shell option 2017-03-07 12:29:38 +02:00
Kaarle Ritvanen
d8174e4f3a abuild: fix dependency checking
- versioned dependencies
- dependencies on 'provides' tags or library names
2017-03-07 12:29:38 +02:00
William Pitcock
c909c82ac2 abuild: expand on APKBUILD check() warning message 2017-02-28 08:22:36 +00:00
Timo Teräs
9be173c677 functions.sh: set host compiler when cross-compiling
We chose to use kernel style HOST* instead of the gcc's
*_FOR_HOST.
2017-02-24 10:20:21 +02:00
Timo Teräs
32dbf36f0e abuild: use BOOTSTRAP to determine if build-base is needed
Just checking the build, host and target triplet is not enough
due to various different combinations used in the early bootstrap.
So use detect specifical bootstrap setting.
2017-02-24 10:16:55 +02:00
Timo Teräs
5a8993e161 abuild: $depends should not part of $makedepends_build 2017-02-24 08:55:13 +02:00
Timo Teräs
53ae72567d abuild: fix setting build-base properly for cross-create/cross-build 2017-02-23 13:31:49 +02:00
Timo Teräs
ad46156cc7 abuild: use $builddir in default_prepare only if it exists 2017-02-17 15:17:44 +02:00
Natanael Copa
2c1aaa5536 abuild: unset md5 and sha256 sums when updating checksum
this fixes problem with abump
2017-02-17 11:07:15 +01:00
Timo Teräs
30c5103bfb abuild: remove g++ makedepends warning from toolchain packages 2017-02-17 09:20:58 +02:00
Timo Teräs
ab748f4eda abuild: make build-base target specific 2017-02-16 16:07:27 +02:00
Timo Teräs
6fa4c26226 abuild: allow injecting extra dependencies for bootstrap
Allowing bootstrap.sh to inject extra dependencies for build/host/target,
simplifies things greatly in the bootstrap script.
2017-02-16 15:18:16 +02:00
William Pitcock
a7f9bff0f7 functions: fix cross-compile triplet for armhf architecture 2017-02-14 05:52:54 +00:00
Timo Teräs
9d2567f1e6 abuild: preserve xattrs when creating -dbg 2017-02-09 11:32:49 +00:00
G.J.R. Timmer
21bf69f6ad abuild: fix package size calculation on certain filesystems 2017-02-08 13:10:36 +02:00
Natanael Copa
ab79e3fe6f abuild: fix location of built apk
we need to replace noarch with CARCH for now
2017-02-01 11:49:40 +01:00
Timo Teräs
4442efff6e abuild: add symlinksrc target for create the source file symlinks
needed for upcoming 'rootbld' support
2017-01-31 10:23:56 +02:00
Tuomas Jaakola
520cc15fe9 abuild: support local archives 2017-01-31 10:21:13 +02:00
Timo Teräs
14f8fcfb37 apkbuild-cpan: fix warnings, improve recreate, add check support 2017-01-31 10:20:14 +02:00
William Pitcock
7c1609b1bb sample apkbuild: document check() function usage 2017-01-29 09:50:29 +00:00
William Pitcock
ea1db36f1f abuild: implement check and $checkdepends support.
The check() function is an APKBUILD overridable function which runs a testsuite.  The packages listed in
$checkdepends are packages which will be installed at build time only if check() will be run.
2017-01-29 09:47:25 +00:00
Valery Kartel
89d62e9d4d abuild.in: fix dealing with named remote patches (closes github #11)
for patches like:
patchname.patch::http://github/.../commit/<md5hash>.patch

use strict filename instead of the whole line
2017-01-27 06:41:59 +00:00
Timo Teräs
0ff2cf73f5 abuild: use only sha512sum
use only the strongest hash. this simplifies apkbuilds a bit.
2017-01-26 13:57:18 +02:00
William Pitcock
ac5dbfca7f abuild: add missing triplet definitions for ppc and ppc64 architectures 2017-01-24 01:20:34 +00:00
Breno Leitao
f41036ac3a abuild: check for ppc64le on config.guess
Currently, if aarch64 exists in config.guess, it is not updated.
This breaks spl, which has aarch64 entry, but not ppc64le.

update_config_guess should update config.guess if any of those
does not exists.
2017-01-19 22:20:42 +01:00
Breno Leitao
7301f84f26 abuild: Add support for ppc64le
This is the initial patches that starts to add support for the ppc64le
platform.
2017-01-17 09:39:43 +02:00
Timo Teräs
6926e206a8 abuild-gzsplit: new tool to split .apk to it's base components
required tool for re-signing packages
2017-01-10 14:16:16 +02:00
Timo Teräs
8bddd02b10 abuild: remove noarch files from CARCH target direct
this is where it is built too
2017-01-09 11:17:39 +02:00
xentec
971504f0ec abuild: pass --arch to apk whenever sysroot is used
so we can crosscompile for different architectures
2016-12-21 10:05:41 +00:00
Przemyslaw Pawelczyk
6b2fd4a891 abuild: make default_prepare() always end up in "$builddir"
So far default_prepare() ended up in "$builddir" only if there were any
patches.  It's better to be more consistent and make such change always.
2016-12-04 02:38:09 +01:00
Jakub Jirutka
454beb0c5c abuild-sign: indent heredoc 2016-11-23 21:59:12 +01:00
Jakub Jirutka
4d6114bdce abuild: change shebang to /bin/ash
This script uses variable expansion / pattern replacement, which is not
defined in POSIX-sh. Also APKBUILDs are not required to be strictly
POSIX-sh compatible. If someone run abuild on system with e.g. dash as
/bin/sh, then it fails (and someone reported exactly that on IRC
today). Therefore abuild should explicitly use /bin/ash in shebang and
not /bin/sh.
2016-11-23 21:44:52 +01:00
Timo Teräs
e18d6228e7 abuild: properly detect failure of dependency installation 2016-10-31 15:49:29 +02:00
Natanael Copa
69fd2290fe ==== release 2.29.0 ==== 2016-10-24 16:14:18 +02:00
Jakub Jirutka
4f37c8efd3 abuild: set default builddir when not defined in APKBUILD 2016-09-02 23:13:31 +02:00
Jakub Jirutka
35077b43e8 replace deprecated ... syntax with $(...) in shell scripts 2016-08-23 00:09:07 +02:00
Jakub Jirutka
81c8888228 buildlab: replace echos in usage with heredoc 2016-08-23 00:09:07 +02:00
Jakub Jirutka
948fedc5f7 indent heredocs when possible 2016-08-23 00:09:06 +02:00
Jakub Jirutka
e8508f7b18 add .editorconfig and fix code formatting 2016-08-20 16:16:37 +02:00
Sören Tempel
8a4680cc74 abuild: don't overwrite existing files when using unzip in unpack
Default is asking for each file.
2016-08-18 23:45:33 +02:00
Carlo Landmeter
b874a4c8cd abuild: add update_config_guess 2016-08-12 15:26:06 +02:00
Sören Tempel
4f7a4556a0 abuild: ash only always local in functions these days 2016-08-11 14:04:44 +02:00
Jakub Jirutka
042bf4297f checkapk: fix to work with https repositories 2016-08-09 15:02:17 +02:00
Timo Teräs
4134332906 abuild: fix dependency tracing for cross builds 2016-08-01 14:28:44 +03:00
Timo Teräs
495dac7fa9 abuild: unify dependency installation and removal code
this fixes cross deps such as "CHOST=armhf abuild deps"
to work properly.

if makedepends is not defined the following default
will be used (as that's the definition cross-build
aware apkbuilds use):
  makedepends="$makedepends_build $makedepends_host"
2016-08-01 14:28:44 +03:00
Timo Teräs
a01d11d9bc abuild: check both build and host dependencies first
So we don't waste time installing dependencies on builder if
the host dependencies are not satisfiable.
2016-08-01 14:28:44 +03:00
Timo Teräs
9207fccde2 abuild: display target arch in xterm title for cross build 2016-08-01 14:28:44 +03:00
Timo Teräs
d13decf47b functions: add s390x triplet and arch 2016-08-01 14:28:44 +03:00
Timo Teräs
8c8d741b32 abuild: use subpkgarch to construct the package paths everywhere 2016-08-01 14:28:44 +03:00
Timo Teräs
f7e2b48d1c abuild: remove PKGDEST and install_after features
supporting these features with cross building is non-trivial
and they do are generally not useful features, so remove them.
as result the abuildrepo is also removed to write out paths.
all package generation paths now use $REPODEST/$repo/$CARCH
which allows easily writing packages to correct $subpkgarch
in future commits.
2016-08-01 14:28:44 +03:00
Timo Teräs
f459607da7 abuild: use proper strip for each subpkg according to it's arch 2016-08-01 14:28:44 +03:00
Timo Teräs
b217bbb2ea abuild: support subpackages="pkg:split:arch" syntax
For proper cross-build support, the subpackage arch needs to
be known before invoking the split function. This implements
a way to do that. This also changes to write the actual subpkg
arch to .PKGINFO - apk index --rewrite-arch still overwrites
index to have machine arch for noarch packages.
2016-08-01 14:28:44 +03:00
Timo Teräs
26ec31c6c2 abuild: improve cross compiling support 2016-08-01 14:28:44 +03:00
Francesco Colista
9f8ef6b870 apkbuild-cpan: fixed error "Experimental keys on scalar is now forbidden" due to perl upgrade to 5.24 version 2016-07-28 09:44:34 +00:00
31 changed files with 4259 additions and 1032 deletions

18
.editorconfig Normal file
View File

@ -0,0 +1,18 @@
# http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
[apkbuild-gem-resolver.in]
indent_size = 2
indent_style = space
[apkbuild-pypi.in]
indent_size = 4
indent_style = space

5
.gitignore vendored
View File

@ -2,7 +2,9 @@
*.o
abuild
abuild-fetch
abuild-gzsplit
abuild-keygen
abuild-rmtemp
abuild-sign
abuild-sudo
abuild-tar
@ -10,9 +12,12 @@ abump
ap
apkbuild-cpan
apkbuild-gem-resolver
apkbuild-pypi
apkgrel
buildlab
checkapk
devbuild
functions.sh
newapkbuild
src
pkg

571
APKBUILD.5 Normal file
View File

@ -0,0 +1,571 @@
.Dd February 13, 2018
.Dt APKBUILD 5 PRM
.Os "Alpine Linux"
.Sh NAME
.Nm APKBUILD
.Nd metadata and instructions to build a package
.Sh SYNOPSIS
.Nm /usr/src/packages/<repo>/<package>/APKBUILD
.Sh DESCRIPTION
An
.Nm
file is used by tools such as
.Xr abuild 1
to build a package for eventual installation by the
.Xr apk 8
package manager.
It defines metadata such as the name of the package, the version information,
the source license, and contact information for the developer.
It additionally contains the commands needed to build, test, and install the
package.
.Pp
The
.Nm
format is similar to a typical shell script; you set pre-defined variables and
implement pre-defined functions, and the
.Xr abuild 1
(or similar) utility will use them to create the package.
.Ss Required Variables
The following variables must be set in all
.Nm
files:
.Bl -tag -width Ds
.It Cm pkgname
Specifies name of the package.
This is typically the name of the package upstream; however, note that all
letters must be lowercased.
.Pp
Libraries for scripting languages should have a prefix before the library name
describing the language.
Such prefixes include
.Em lua- ,
.Em perl- ,
.Em py- ,
and
.Em rb- .
Not all languages use prefixes.
For a definitive list, consult the PREFIXES file in the root directory of the
repository you are using for packaging.
.It Cm pkgver
Specifies the version of the software being packaged.
The version of a package must consist of one or more numbers separated by the
radix (decimal point).
The final number may have a single letter following it, for upstreams that use
such a versioning scheme (such as 1.5a, 1.5b, 1.5c).
.Pp
After the final number (and optional single letter), a suffix may be appended,
which must be an underscore (_) followed by one of
.Em alpha ,
.Em beta ,
.Em pre ,
.Em rc ,
.Em cvs ,
.Em svn ,
.Em git ,
.Em hg ,
or
.Em p ,
optionally followed by another number.
If the suffix is
.Em alpha ,
.Em beta ,
.Em pre ,
or
.Em rc ,
it is considered to be earlier than the version without a suffix; if the suffix
is
.Em cvs ,
.Em svn ,
.Em git ,
.Em hg ,
or
.Em p ,
it is considered to be later than the version without a suffix.
All of the following examples are valid versions, in order from lowest to
highest:
.Pp
1.0, 1.1_alpha2, 1.1.3_pre, 1.1.3, 1.1.3_hg, 1.2, 1.2a, 1.2b
.It Cm pkgrel
Specifies the package release number of this particular package version.
This indicates when a package has changed without a corresponding change in
version.
Always increment
.Cm pkgrel
when you change the contents, dependencies, or metadata of a package.
The first release of a package is always
.Li 0 .
.It Cm pkgdesc
Specifies what the package contains.
.Cm pkgdesc
must be 128 characters or less, and should concisely describe what actions the
software or items being packaged will allow the user to perform.
For example,
.Dq Fully-featured word processor with spell check and many plugins
would be a sufficient
.Cm pkgdesc
for AbiWord.
.It Cm url
Specifies the Web address of the package's upstream.
This allows users and future maintainers to find documentation, release
information, and contact information for the package.
If no Web address is available for the package, you must set
.Cm url
to an empty string ("").
.It Cm arch
Specifies the architectures for which the package may be built.
It is highly recommended that you set this variable to "all" if the package is
portable.
.Pp
You may use "noarch" if the package does not contain any architecture-specific
binary files - that is, any files that are compiled for the target only.
Such packages may include pure Python packages, shell script packages, and
JARs.
If you are not sure what this means, using "all" is safe.
.It Cm license
Specifies the license under which the package is distributed.
The value provided must match a SPDX license identifier.
.It Cm source
Specifies the location of both local and remote source files used to build the
package.
Typically, the remote source file(s) or archive(s) is specified, followed by
any local patches, install scripts, configuration files, or other necessary
files.
.El
.Ss Optional Variables
The following variables are not required, but may be set in any
.Nm
file:
.Bl -tag -width Ds
.It Cm checkdepends
Specifies test-time dependencies of the package.
Common packages that are used for testing include check, dejagnu, and
perl-test-command.
.It Cm depends
Specifies the run-time dependencies of the package.
The
.Xr abuild 1
utility will automatically scan the resultant package for shared library (.so)
dependencies; do not specify them here.
.It Cm install
Specifies install scripts for the package, if any.
See
.Sx Install Scripts
for more information about install scripts.
.It Cm install_if
Specifies a condition when
.Xr apk 8
should automatically install the package (or subpackage).
For instance, the OpenRC subpackages set
.Cm install_if
to
.Li openrc ${subpkgname%-openrc}=$pkgver-r$pkgrel
which means that the OpenRC subpackage will be automatically installed if
both OpenRC and the origin package are installed on the same computer.
.It Cm makedepends
Specifies build dependencies for the package.
.It Cm pkggroups
Specifies a space-separated list of login groups to create during build-time.
Note that you will need to create the login groups in a pre-install install
script as well; see
.Sx Install Scripts
for more information about install scripts.
.It Cm pkgusers
Specifies a space-separated list of user logins to create during build-time.
Note that you will ned to create the user logins in a pre-install install
script as well; see
.Sx Install Scripts
for more information about install scripts.
.It Cm provides
Specifies that the package "provides" the same contents as another package.
There are two formats that you may use for
.Cm provides :
a provider name, and a provider name with version.
.Pp
Specifying a provider name with version such as
.Li foobar=1.2
will cause the package to be an "alias" of foobar version 1.2.
It will be automatically installed if a user then runs
.Li apk add foobar
or similar, and it will conflict with a package named foobar.
.Pp
Specifying a provider name without a version such as
.Li baz
will cause the package to provide a "virtual" called baz.
Multiple packages with the same virtual provider can be installed on a system;
however, if a user runs
.Li apk add baz
they will provided a list of packages that provide baz and must select one and
install it.
.It Cm provider_priority
Specifies the numeric value for
.Xr apk 8
to use for the package when considering which provider should be installed for
the same
.Cm provides
virtual provider.
.It Cm replaces
Specifies packages that the package replaces.
This is typically used for packages renamed by upstream.
.It Cm subpackages
Specifies subpackages or split packages built with this package.
Typically, this will include
.Li $pkgname-dev
for development files (such as /usr/include and static library files) and
.Li $pkgname-doc
for documentation (such as /usr/share/doc and /usr/share/man).
.Pp
Each subpackage may be specified using three different methods.
The first, and most common, is
.Li $pkgname-foo
where
.Li foo
is the name of the split function specified later in the file.
Similar to the
.Cm package
function, the
.Li foo
function must move files from
.Pa $pkgdir
or
.Pa $srcdir
to
.Pa $subpkgdir
after creating
.Pa $subpkgdir .
.Pp
The second method is to simply call the subpackage
.Li foo
which will create a package called
.Li foo
instead of pkgname-foo.
.Pp
However,
.Li foo
in both of these examples cannot contain a hyphen, as shell function names
cannot have hyphens in them. In this case, the third method may be used:
.Li foo:funcname
where
.Li foo
is the name of the subpackage and
.Li funcname
is the name of the shell function in the
.Nm
that creates it.
.Pp
Note that an additional colon may be used to specify an architecture for the
subpackage; typically, this is used for marking miscellaneous files that are
not architecture-specific as noarch.
For example,
.Li $pkgname-doc $pkgname-foo $pkgname-foo-misc:foo_misc:noarch
will create the $pkgname-doc package using the
.Cm doc
function, the $pkgname-foo package using the
.Cm foo
function, and the $pkgname-foo-misc package using the
.Cm foo_misc
function and set $pkgname-foo-misc as noarch.
.It Cm triggers
Specifies a trigger script used by the package.
A trigger script is a shell script that is called whenever monitored files or
directories are modified.
You may specify the paths to monitor using the triggers variable as follows:
.Pp
.Li $pkgname.trigger=/usr/share/man:/usr/local/share/man
.Pp
This will run the package trigger script whenever files in
.Pa /usr/share/man
or
.Pa /usr/local/share/man
are created, modified, or removed.
.El
.Ss options
The
.Cm options
variable allows you to set parameters for the package at build time.
There are a number of valid options you may set, and you may set multiple
options by writing a space between each one.
.Bl -tag -width Ds
.It Cm !archcheck
Specifies that the package contains binaries that cannot run on the target
architecture.
This is primarily used for packages containing firmware, and should typically
never need to be used.
.It Cm charset.alias
Specifies that the package ships a /usr/lib/charset.alias file and that it
should be installed on the user's system.
This is almost never the case.
Do not use this option.
.It Cm !check
Specifies that the package will not run a test suite.
The reason for disabling the check phase should be noted in a comment.
.It Cm checkroot
Specifies that the package's test suite will be run in
.Xr fakeroot 8 .
This is necessary for some test suites which fail when run as non-root.
.It Cm !dbg
Specifies that the package should not be built with a debug information
package.
This is the default unless
.Ev DEFAULT_DBG
is set in the environment or
.Xr abuild.conf 5 .
It is typically used on packages that do not generate debug information (such
as pure Python packages) or packages that do not support debug information
packages.
.It Cm !fhs
Specifies that the package violates FHS and installs to a location such as
.Pa /usr/local ,
.Pa /opt ,
or
.Pa /srv .
.It Cm ldpath-recursive
Specifies that
.Xr abuild 1
should use the
.Fl --recursive
argument to
.Xr scanelf 1
when attempting to find shared library (.so) dependencies for the package.
.It Cm libtool
Specifies that the package requires its libtool (.la) files.
They will not be automatically removed by
.Xr abuild 1 .
.It Cm net
Specifies that the package build system requires access to a network.
This is discouraged and an issue should be filed with the package's authors.
.It Cm !strip
Specifies that
.Xr strip 1
should not be run on any of the package's binaries.
This is automatically implied if the -dbg subpackage is enabled, or if you are
using
.Ev DEFAULT_DBG .
.It Cm suid
Specifies that binaries in the package may be installed set-uid.
This is a security risk and it is highly recommended to use capabilities or
process separation instead of set-uid where available.
.It Cm textrels
Specifies that the package's binaries are known to contain relocations against
text segments.
By default,
.Xr abuild 1
will refuse to create such a package because this is a security concern.
.It Cm toolchain
Specifies that the package is part of the base toolchain set and may depend
on packages like
.Li g++ .
.It Cm !tracedeps
Specifies that
.Xr abuild 1
should not automatically populate
.Cm depends
with shared library (.so) or symlink target dependencies.
.El
.Ss Automatic Variables
The following variables are defined for you by
.Xr abuild 1 ,
but may be overridden if necessary.
.Bl -tag -width Ds
.It Cm builddir
Specifies the directory where the source code of the package will be built.
The default value is
.Pa $srcdir/$pkgname-$pkgver
which is appropriate for most source distributions.
If the source tarball does not create a $pkgname-$pkgver directory when it is
unpacked, you must override
.Cm builddir .
.It Cm pkgdir
Specifies the directory where the built files will be installed.
Typically, you will call
.Li make DESTDIR="$pkgdir" install
or similar to install the files.
The default value is
.Pa $startdir/pkg
and you should not modify this variable.
.It Cm srcdir
Specifies the directory where the files specified in
.Cm source
are downloaded and unpacked.
The default value is
.Pa $startdir/src
and you should not need to modify this.
.It Cm startdir
Specifies the directory where the
.Nm
file resides.
.It Cm subpkgdir
Specifies the directory where the subpackage's files should be placed.
This variable is only set inside subpackage functions.
.El
.Ss Special Variables
The following variables are used only in special circumstances, and may be
required or optional depending on their usage and the contents of other
variables.
.Bl -tag -width Ds
.It Cm depends_dev
Specifies the run-time dependencies of the -dev subpackage.
.It Cm depends_doc
Specifies the run-time dependencies of the -doc subpackage.
.It Cm depends_libs
Specifies the run-time dependencies of the -libs subpackage.
.It Cm depends_openrc
Specifies the run-time dependencies of the -openrc subpackage.
.It Cm depends_static
Specifies the run-time dependencies of the -static subpackage.
.It Cm giturl
Specifies the URL of the Git repository to use with
.Cm abuild checkout .
If the default branch of the repository is not desired, a different one may be
specified by appending
.Fl b Ar branch
where
.Cm branch
is the branch to checkout.
.El
.Ss Functions
Functions specified here may be present in any
.Nm
file, but with the exception of
.Cm package ,
are not strictly required.
.Bl -tag -width Ds
.It Cm fetch
This function is called to download the remote files in
.Cm source .
.It Cm unpack
This function unpacks any archives in
.Cm source
to
.Ev srcdir .
.It Cm prepare
Prepares the source in
.Ev srcdir
to be built.
The default
.Cm prepare
function ensures the build directories are set up correctly and applies any
*.patch files specified in
.Cm source .
You must call
.Cm default_prepare
if you write a custom
.Cm prepare
function.
.It Cm build
Compiles the source in
.Ev builddir .
You must implement this function yourself.
If no compilation is required, you may omit it.
.It Cm check
Runs the package's test suite.
This function must be implemented unless
.Li !check
was specified in
.Cm options .
.It Cm package
Installs the package into
.Ev pkgdir .
Note that
.Ev pkgdir
is not created for you; if this package installs no files (for example, a
metapackage), you must use
.Li mkdir -p "$pkgdir"
to skip the package phase.
.El
.Ss Install Scripts
An install script is run when an action is taken on a package by
.Xr apk 8 .
An install script must be written in shell and must have a
.Li #!/bin/sh
interpreter declaration as the first line.
The
.Cm install
variable must contain the install scripts needed by the package.
.Pp
The install script will be run inside the root filesystem where the package is
being installed.
A single argument will be passed to all scripts, which is the version of the
package being currently installed (or deinstalled).
The pre-upgrade and post-upgrade scripts will have an additional second
argument, which specifies the version of the package before the upgrade
process.
.Pp
The different actions that may have install scripts specified are as follows:
.Bl -tag -width Ds
.It Ic $pkgname.pre-install
Executed before the package is installed.
If this script exits with an error (non-zero exit code),
.Xr apk 8
will halt the installation and the package will not be installed.
This install script is typically used to create any users or groups needed as
described in
.Cm pkggroups
and
.Cm pkgusers .
.It Ic $pkgname.post-install
Executed after the package is installed.
If this script exits with an error (non-zero exit code),
.Xr apk 8
will mark the package as broken.
The
.Li apk fix
command will attempt to re-run the post-install script if this occurs.
.It Ic $pkgname.pre-upgrade
Executed before the package is upgraded.
If this script exits with an error (non-zero exit code),
.Xr apk 8
will mark the package as broken.
.It Ic $pkgname.post-upgrade
Executed after the package is upgraded.
If this script exits with an error (non-zero exit code),
.Xr apk 8
will mark the package as broken.
The
.Li apk fix
command will attempt to re-run the post-upgrade script if this occurs.
.It Ic $pkgname.pre-deinstall
Executed before the package is removed from the system.
If this script exits with an error (non-zero exit code),
.Xr apk 8
will not remove the package from the system.
.It Ic $pkgname.post-deinstall
Executed after the package is removed from the system.
Exiting with an error will have no effect.
.El
.Sh IMPLEMENTATION NOTES
Currently,
.Nm
files are sourced as normal shell scripts. This may change at a later date.
.Sh COMPATIBILITY
The
.Xr abuild 1
utility as distributed by Alpine uses the BusyBox Almquist shell, a part of
.Xr busybox 1
that is currently undocumented.
It is mostly compliant with
.St -p1003.2 ,
with some bash-like extensions.
The
.Xr abuild 1
utility as distributed by Adélie uses the user's preferred /bin/sh, which is
typically
.Xr bash 1 .
.Sh SEE ALSO
SPDX license reference (on the Web at <https://spdx.org/licenses/>),
.Xr abuild 1 ,
.Xr newapkbuild 1 ,
.Xr apk 8 .
.Sh HISTORY
The
.Nm
format and
.Xr abuild 1
utility first appeared in Alpine Linux 1.9.
.Sh AUTHORS
.An Timo Teräs Aq Mt timo.teras@iki.fi
.An Natanael Copa Aq Mt ncopa@alpinelinux.org
.Pp
Documentation:
.An A. Wilcox Aq Mt awilfox@adelielinux.org
.\" .Sh BUGS
.\" if we end up finding bugs that should be documented, put them here.

View File

@ -1,20 +1,21 @@
PACKAGE := abuild
VERSION := 2.28.0
VERSION := 3.5.0
prefix ?= /usr
bindir ?= $(prefix)/bin
sysconfdir ?= /etc
datadir ?= $(prefix)/share/$(PACKAGE)
abuildrepo ?= ~/.cache/abuild
sharedir ?= $(prefix)/share/$(PACKAGE)
mandir ?= $(prefix)/share/man
SCRIPTS := abuild abuild-keygen abuild-sign newapkbuild \
abump apkgrel buildlab apkbuild-cpan checkapk \
abump apkgrel buildlab apkbuild-cpan apkbuild-pypi checkapk \
apkbuild-gem-resolver
USR_BIN_FILES := $(SCRIPTS) abuild-tar abuild-sudo abuild-fetch
USR_BIN_FILES := $(SCRIPTS) abuild-tar abuild-gzsplit abuild-sudo abuild-fetch abuild-rmtemp
MAN_1_PAGES := newapkbuild.1
MAN_5_PAGES := APKBUILD.5
SAMPLES := sample.APKBUILD sample.initd sample.confd \
sample.pre-install sample.post-install
AUTOTOOLS_TOOLCHAIN_FILES := config.sub
AUTOTOOLS_TOOLCHAIN_FILES := config.sub config.guess
SCRIPT_SOURCES := $(addsuffix .in,$(SCRIPTS))
@ -34,18 +35,21 @@ LINK = $(CC) $(OBJS-$@) -o $@ $(LDFLAGS) $(LDFLAGS-$@) $(LIBS-$@)
SED_REPLACE := -e 's:@VERSION@:$(FULL_VERSION):g' \
-e 's:@prefix@:$(prefix):g' \
-e 's:@sysconfdir@:$(sysconfdir):g' \
-e 's:@datadir@:$(datadir):g' \
-e 's:@abuildrepo@:$(abuildrepo):g'
-e 's:@sharedir@:$(sharedir):g' \
SSL_CFLAGS ?= $(shell pkg-config --cflags openssl)
SSL_LDFLAGS ?= $(shell pkg-config --cflags openssl)
SSL_LIBS ?= $(shell pkg-config --libs openssl)
ZLIB_LIBS ?= $(shell pkg-config --libs zlib)
OBJS-abuild-tar = abuild-tar.o
CFLAGS-abuild-tar.o = $(SSL_CFLAGS)
LDFLAGS-abuild-tar = $(SSL_LDFLAGS)
LIBS-abuild-tar = $(SSL_LIBS)
LIBS-abuild-tar.static = $(LIBS-abuild-tar)
OBJS-abuild-gzsplit = abuild-gzsplit.o
LDFLAGS-abuild-gzsplit = $(ZLIB_LIBS)
OBJS-abuild-sudo = abuild-sudo.o
OBJS-abuild-fetch = abuild-fetch.o
@ -64,7 +68,7 @@ P=$(PACKAGE)-$(VERSION)
all: $(USR_BIN_FILES) functions.sh
clean:
@rm -f $(USR_BIN_FILES) functions.sh
@rm -f $(USR_BIN_FILES) *.o functions.sh
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -c $<
@ -78,29 +82,45 @@ abuild-tar: abuild-tar.o
abuild-fetch: abuild-fetch.o
$(LINK)
abuild-gzsplit: abuild-gzsplit.o
$(LINK)
abuild-tar.static: abuild-tar.o
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -static $(LIBS-$@) $^
$(CC) -static $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) $^ -o $@ $(LIBS-$@)
help:
@echo "$(P) makefile"
@echo "usage: make install [ DESTDIR=<path> ]"
check: $(USR_BIN_FILE) functions.sh
cd tests && bats *.bats
install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
$(DESTDIR)/$(datadir)
$(DESTDIR)/$(sharedir) $(DESTDIR)/$(mandir)/man1 \
$(DESTDIR)/$(mandir)/man5
for i in $(USR_BIN_FILES); do\
install -m 755 $$i $(DESTDIR)/$(bindir)/$$i;\
done
chmod 4111 $(DESTDIR)/$(prefix)/bin/abuild-sudo
chmod 4555 $(DESTDIR)/$(prefix)/bin/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
if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
fi
cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild/
cp $(AUTOTOOLS_TOOLCHAIN_FILES) $(DESTDIR)/$(prefix)/share/abuild/
cp functions.sh $(DESTDIR)/$(datadir)/
cp functions.sh $(DESTDIR)/$(sharedir)/
depends depend:
sudo apk --no-cache -U --virtual .abuild-depends add openssl-dev zlib-dev
.gitignore: Makefile
echo "*.tar.bz2" > $@

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -50,15 +51,36 @@ void add_opt(struct cmdarray *cmd, char *opt)
int usage(int eval)
{
printf("usage: %s [-d DESTDIR] URL\n", program);
printf("usage: %s [-h] [-d DESTDIR] URL\n", program);
return eval;
}
int fork_exec(char *argv[], int showerr)
{
int r = 202;
int status = 0;
pid_t childpid = fork();
if (childpid < 0 )
err(200, "fork");
if (childpid == 0) {
execvp(argv[0], argv);
if (showerr)
warn("%s", argv[0]);
_exit(201);
}
/* wait for curl/wget and get the exit code */
wait(&status);
if (WIFEXITED(status))
r = WEXITSTATUS(status);
return r;
}
/* create or wait for an NFS-safe lockfile and fetch url with curl or wget */
int fetch(char *url, const char *destdir)
int fetch(char *url, const char *destdir, bool insecure)
{
int lockfd, status=0;
pid_t childpid;
char outfile[PATH_MAX], partfile[PATH_MAX];
char *name, *p;
struct flock fl = {
@ -68,8 +90,8 @@ int fetch(char *url, const char *destdir)
.l_len = 0,
};
struct cmdarray curlcmd = {
.argc = 6,
.argv = { "curl", "-k", "-L", "-f", "-o", partfile, NULL }
.argc = 5,
.argv = { "curl", "-L", "-f", "-o", partfile, NULL }
};
struct cmdarray wgetcmd = {
.argc = 3,
@ -84,9 +106,6 @@ int fetch(char *url, const char *destdir)
name = url;
*p = '\0';
url = p + 2;
} else if (strstr(url, "saveas-") == url) {
*name++ = '\0';
url += 7; /* strlen("saveas-") */
} else {
name++;
}
@ -115,6 +134,12 @@ int fetch(char *url, const char *destdir)
if (access(outfile, F_OK) == 0)
goto fetch_done;
/* enable insecure mode when http. This may be useful when it redirects to https */
if (insecure || strstr(url, "http://") == url) {
add_opt(&curlcmd, "--insecure");
add_opt(&wgetcmd, "--no-check-certificate");
}
if (access(partfile, F_OK) == 0) {
printf("Partial download found. Trying to resume.\n");
add_opt(&curlcmd, "-C");
@ -125,27 +150,26 @@ int fetch(char *url, const char *destdir)
add_opt(&curlcmd, url);
add_opt(&wgetcmd, url);
childpid = fork();
if (childpid < 0 )
err(1, "fork");
status = fork_exec(curlcmd.argv, 0);
if (childpid == 0) {
execvp(curlcmd.argv[0], curlcmd.argv);
printf("Using wget\n");
execvp(wgetcmd.argv[0], wgetcmd.argv);
warn("%s", wgetcmd.argv[0]);
unlink(lockfile);
_exit(1);
}
wait(&status);
rename(partfile, outfile);
/* CURLE_RANGE_ERROR (33)
The server does not support or accept range requests. */
if (status == 33)
unlink(partfile);
/* is we failed execute curl, then fallback to wget */
if (status == 201)
status = fork_exec(wgetcmd.argv, 1);
/* only rename completed downloads */
if (status == 0)
rename(partfile, outfile);
fetch_done:
unlink(lockfile);
close(lockfd);
lockfile[0] = '\0';
return status;
}
void sighandler(int sig)
@ -163,13 +187,20 @@ void sighandler(int sig)
}
}
/* exit codes get passed through from curl/wget (so we can check in abuild
whether the server does not support resuming). Additional exit codes:
200: fork failed
201: curl/wget could not be started
202: curl/wget did not terminate normally
203: usage displayed */
int main(int argc, char *argv[])
{
int opt, r=0, i;
int opt;
bool insecure = false;
char *destdir = "/var/cache/distfiles";
program = argv[0];
while ((opt = getopt(argc, argv, "hd:")) != -1) {
while ((opt = getopt(argc, argv, "hd:k")) != -1) {
switch (opt) {
case 'h':
return usage(0);
@ -177,8 +208,11 @@ int main(int argc, char *argv[])
case 'd':
destdir = optarg;
break;
case 'k':
insecure = true;
break;
default:
printf("Unkonwn option '%c'\n", opt);
printf("Unknown option '%c'\n", opt);
return usage(1);
break;
}
@ -187,17 +221,13 @@ int main(int argc, char *argv[])
argv += optind;
argc -= optind;
if (argc < 1)
return usage(1);
if (argc != 1)
return usage(203);
signal(SIGABRT, sighandler);
signal(SIGINT, sighandler);
signal(SIGQUIT, sighandler);
signal(SIGTERM, sighandler);
for (i = 0; i < argc; i++) {
if (fetch(argv[i], destdir))
r++;
}
return r;
return fetch(argv[0], destdir, insecure);
}

75
abuild-gzsplit.c Normal file
View File

@ -0,0 +1,75 @@
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <zlib.h>
int main(void)
{
char obuf[8*1024], ibuf[8*1024];
z_stream zs;
int r = Z_OK, rc = 1, fd = -1;
size_t len;
if (inflateInit2(&zs, 15+32) != Z_OK)
goto err;
zs.avail_out = sizeof obuf;
zs.next_out = obuf;
while (1) {
if (zs.avail_in == 0) {
zs.avail_in = read(STDIN_FILENO, ibuf, sizeof ibuf);
zs.next_in = ibuf;
if (zs.avail_in < 0) goto err;
if (zs.avail_in == 0 && r == Z_STREAM_END) goto ok;
}
r = inflate(&zs, Z_NO_FLUSH);
if (r != Z_OK && r != Z_STREAM_END) goto err;
len = sizeof obuf - zs.avail_out;
if (len) {
if (fd < 0) {
const char *fn;
if (strncmp(obuf, ".SIGN.", 6) == 0)
fn = "signatures.tar.gz";
else if (strncmp(obuf, ".PKGINFO", 8) == 0)
fn = "control.tar.gz";
else if (rc == 1)
fn = "data.tar.gz", rc = 2;
else
goto err;
fd = open(fn, O_CREAT|O_TRUNC|O_WRONLY, 0777);
if (fd < 0) goto err;
}
zs.next_out = obuf;
zs.avail_out = sizeof obuf;
}
if (zs.avail_in == 0 || r == Z_STREAM_END) {
len = (void *)zs.next_in - (void *)ibuf;
if (write(fd, ibuf, len) != len) goto err;
memmove(ibuf, zs.next_in, zs.avail_in);
zs.next_in = ibuf;
}
if (r == Z_STREAM_END) {
if (fd >= 0) {
close(fd);
fd = -1;
}
inflateEnd(&zs);
if (inflateInit2(&zs, 15+32) != Z_OK) goto err;
}
}
ok:
rc = 0;
err:
if (fd >= 0) close(fd);
inflateEnd(&zs);
if (rc) fprintf(stderr, "failed\n");
return rc;
}

View File

@ -7,13 +7,13 @@
#
program_version=@VERSION@
datadir=@datadir@
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
if ! [ -f "$datadir/functions.sh" ]; then
echo "$datadir/functions.sh: not found" >&2
if ! [ -f "$sharedir/functions.sh" ]; then
echo "$sharedir/functions.sh: not found" >&2
exit 1
fi
. "$datadir/functions.sh"
. "$sharedir/functions.sh"
# ask for privkey unless non-interactive mode
@ -50,7 +50,7 @@ do_keygen() {
# generate the private key in a subshell with stricter umask
(
umask 0007
openssl genrsa -out "$privkey" 2048
openssl genrsa -out "$privkey" "$numbits"
)
openssl rsa -in "$privkey" -pubout -out "$pubkey"
@ -88,26 +88,29 @@ do_keygen() {
}
usage() {
cat >&2 <<__EOF__
$program $program_version - generate signing keys
Usage: $program [-a|--append] [-i|--install] [-n]
Options:
-a, --append Set PACKAGER_PRIVKEY=<generated key> in
$ABUILD_USERCONF
-i, --install Install public key into /etc/apk/keys using sudo
-n Non-interactive. Use defaults
-q, --quiet
-h, --help Show this help
cat >&2 <<-__EOF__
$program $program_version - generate signing keys
Usage: $program [-a|--append] [-i|--install] [-n]
Options:
-a, --append Set PACKAGER_PRIVKEY=<generated key> in
$ABUILD_USERCONF
__EOF__
-i, --install Install public key into /etc/apk/keys using sudo
-n Non-interactive. Use defaults
-b, --numbits [BITS] The size of the private key to generate in bits.
-q, --quiet
-h, --help Show this help
__EOF__
}
append_config=
install_pubkey=
non_interactive=
numbits=2048
quiet=
args=`getopt -o ainqh --long append,install,quiet,help -n "$program" -- "$@"`
args=$(getopt -o ab:inqh --long append,numbits:,install,quiet,help -n "$program" -- "$@")
if [ $? -ne 0 ]; then
usage
exit 2
@ -118,6 +121,7 @@ while true; do
-a|--append) append_config=1;;
-i|--install) install_pubkey=1;;
-n) non_interactive=1;;
-b|--numbits) numbits="$2"; shift 1;;
-q|--quiet) quiet=1;; # suppresses msg
-h|--help) usage; exit;;
--) shift; break;;

50
abuild-rmtemp.c Normal file
View File

@ -0,0 +1,50 @@
/*
* abuild-rmtemp
* Copyright (c) 2017 Kaarle Ritvanen
* Distributed under GPL-2
*/
#define _XOPEN_SOURCE 700
#include <err.h>
#include <errno.h>
#include <ftw.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#define PREFIX "/var/tmp/abuild."
static void fail() {
errx(1, "%s", strerror(errno));
}
static int handler(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
return remove(fpath);
}
int main(int argc, char **argv) {
if (argc < 2) return 0;
if (getuid()) {
argv[0] = "-abuild-rmtemp";
execv("/usr/bin/abuild-sudo", argv);
}
if (strncmp(argv[1], PREFIX, strlen(PREFIX)) || \
strchr(argv[1] + strlen(PREFIX), '/'))
errx(1, "Invalid path: %s", argv[1]);
struct stat s;
if (lstat(argv[1], &s)) fail();
struct passwd *p = getpwnam(getenv("USER"));
if (!p) errx(1, "Incorrect user");
if (s.st_uid != p->pw_uid) errx(1, "Permission denied");
if (nftw(argv[1], handler, 512, FTW_DEPTH|FTW_PHYS)) fail();
return 0;
}

View File

@ -7,16 +7,19 @@
#
program_version=@VERSION@
datadir=@datadir@
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
if ! [ -f "$datadir/functions.sh" ]; then
echo "$datadir/functions.sh: not found" >&2
if ! [ -f "$sharedir/functions.sh" ]; then
echo "$sharedir/functions.sh: not found" >&2
exit 1
fi
. "$datadir/functions.sh"
. "$sharedir/functions.sh"
gzip=$(command -v pigz || echo gzip)
do_sign() {
local f i keyname repo
local openssl=$(command -v openssl || echo libressl)
# we are actually only interested in the name, not the file itself
keyname=${pubkey##*/}
@ -25,37 +28,43 @@ do_sign() {
i=$(readlink -f $f)
[ -d "$i" ] && i="$i/APKINDEX.tar.gz"
repo="${i%/*}"
(
trap 'die "failed to sign $i"' EXIT
set -e
cd "$repo"
sig=".SIGN.RSA.$keyname"
openssl dgst -sha1 -sign "$privkey" -out "$sig" "$i"
$openssl dgst -sha1 -sign "$privkey" -out "$sig" "$i"
if [ -n "$SOURCE_DATE_EPOCH" ]; then
touch -h -d "@$SOURCE_DATE_EPOCH" "$sig"
fi
tmptargz=$(mktemp)
tar -c "$sig" | abuild-tar --cut | gzip -9 > "$tmptargz"
tar -f - -c "$sig" | abuild-tar --cut | $gzip -n -9 > "$tmptargz"
tmpsigned=$(mktemp)
cat "$tmptargz" "$i" > "$tmpsigned"
rm -f "$tmptargz" "$sig"
chmod 644 "$tmpsigned"
mv "$tmpsigned" "$i"
msg "Signed $i"
) || die "failed to sign $i"
set +e
trap - EXIT
done
}
usage() {
cat >&2 <<__EOF__
$program $program_version - sign indexes
Usage: $program [-k PRIVKEY] [-p PUBKEY] INDEXFILE...
$program -e
Options:
-e, --installed Check only of there exist a private key for signing
-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
-q, --quiet
-h, --help Show this help
cat >&2 <<-__EOF__
$program $program_version - sign indexes
Usage: $program [-k PRIVKEY] [-p PUBKEY] INDEXFILE...
$program -e
Options:
-e, --installed Check only of there exist a private key for signing
-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
-q, --quiet
-h, --help Show this help
__EOF__
__EOF__
}
check_installed=false
@ -63,7 +72,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:qh --long installed,private:,public:,quiet,help -n "$program" -- "$@")
if [ $? -ne 0 ]; then
usage
exit 2
@ -87,15 +96,15 @@ if [ $# -eq 0 ] && ! $check_installed; then
fi
if [ -z "$privkey" ]; then
cat >&2 << __EOF__
No private key found. Use 'abuild-keygen' to generate the keys.
Then you can either:
* set the PACKAGER_PRIVKEY in $ABUILD_USERCONF
('abuild-keygen -a' does this for you)
* set the PACKAGER_PRIVKEY in $ABUILD_CONF
* specify the key with the -k option to $program
cat >&2 <<-__EOF__
No private key found. Use 'abuild-keygen' to generate the keys.
Then you can either:
* set the PACKAGER_PRIVKEY in $ABUILD_USERCONF
('abuild-keygen -a' does this for you)
* set the PACKAGER_PRIVKEY in $ABUILD_CONF
* specify the key with the -k option to $program
__EOF__
__EOF__
exit 1
fi

View File

@ -12,6 +12,7 @@
#include <err.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -27,9 +28,16 @@ static const char* valid_cmds[] = {
"/bin/addgroup",
"/usr/sbin/addgroup",
"/sbin/apk",
"/usr/bin/abuild-rmtemp",
NULL
};
static const char* invalid_opts[] = {
"--allow-untrusted",
"--keys-dir",
NULL,
};
const char *get_command_path(const char *cmd)
{
const char *p;
@ -44,11 +52,19 @@ const char *get_command_path(const char *cmd)
return NULL;
}
void check_option(const char *opt)
{
int i;
for (i = 0; invalid_opts[i] != NULL; i++)
if (strcmp(opt, invalid_opts[i]) == 0)
errx(1, "%s: not allowed option", opt);
}
int is_in_group(gid_t group)
{
int ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
gid_t *buf = malloc(ngroups_max * sizeof(gid_t));
int ngroups, ret = 0;
int ngroups;
int i;
if (buf == NULL) {
perror("malloc");
@ -69,18 +85,32 @@ int main(int argc, const char *argv[])
const char *cmd;
const char *path;
int i;
struct passwd *pw;
grent = getgrnam(ABUILD_GROUP);
if (grent == NULL)
errx(1, "%s: Group not found", ABUILD_GROUP);
char *name = NULL;
pw = getpwuid(getuid());
if (pw)
name = pw->pw_name;
if (!is_in_group(grent->gr_gid)) {
char *name = getlogin();
errx(1, "User %s is not a member of group %s\n",
name ? name : "(unknown)", ABUILD_GROUP);
}
cmd = strrchr(argv[0], '-');
if (name == NULL)
warnx("Could not find username for uid %d\n", getuid());
setenv("USER", name ?: "", 1);
cmd = strrchr(argv[0], '/');
if (cmd)
cmd++;
else
cmd = argv[0];
cmd = strchr(cmd, '-');
if (cmd == NULL)
errx(1, "Calling command has no '-'");
cmd++;
@ -89,14 +119,14 @@ int main(int argc, const char *argv[])
if (path == NULL)
errx(1, "%s: Not a valid subcommand", cmd);
/* we dont allow --allow-untrusted option */
for (i = 1; i < argc; i++)
if (strcmp(argv[i], "--allow-untrusted") == 0)
errx(1, "%s: not allowed option", "--allow-untrusted");
check_option(argv[i]);
argv[0] = path;
/* set our uid to root so bbsuid --install works */
setuid(0);
/* set our gid to root so apk commit hooks run with the same gid as for "sudo apk add ..." */
setgid(0);
execv(path, (char * const*)argv);
perror(path);
return 1;

View File

@ -9,6 +9,9 @@ export MAKEFLAGS=-j$JOBS
# remove line below to disable colors
USE_COLORS=1
# uncomment line below to enable ccache support.
#USE_CCACHE=1
SRCDEST=/var/cache/distfiles
# uncomment line below to store built packages in other location
@ -22,7 +25,7 @@ REPODEST=$HOME/packages/
#MAINTAINER="$PACKAGER"
# what to clean up after a successful build
CLEANUP="srcdir pkgdir deps"
CLEANUP="srcdir bldroot pkgdir deps"
# what to cleanup after a failed build
ERROR_CLEANUP="deps"
ERROR_CLEANUP="bldroot deps"

1645
abuild.in

File diff suppressed because it is too large Load Diff

View File

@ -7,13 +7,13 @@
#
program_version=@VERSION@
datadir=@datadir@
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
if ! [ -f "$datadir/functions.sh" ]; then
echo "$datadir/functions.sh: not found" >&2
if ! [ -f "$sharedir/functions.sh" ]; then
echo "$sharedir/functions.sh: not found" >&2
exit 1
fi
. "$datadir/functions.sh"
. "$sharedir/functions.sh"
: ${ABUILD:="abuild"}
@ -86,18 +86,18 @@ fixes #${fixes#\#}
}
usage() {
cat >&2 <<__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 ...
Options:
-s, --security CVE1,CVE-2,... Security update
-f, --fixes ISSUE Fixes ISSUE
-R, --recursive Run abuild with -R for recursive building
-k, --keep Run abuild with -k to keep existing packages
-q, --quiet
-h, --help Show this help
cat >&2 <<-__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 ...
Options:
-s, --security CVE1,CVE-2,... Security update
-f, --fixes ISSUE Fixes ISSUE
-R, --recursive Run abuild with -R for recursive building
-k, --keep Run abuild with -k to keep existing packages
-q, --quiet
-h, --help Show this help
__EOF__
__EOF__
}
keep=
@ -108,8 +108,8 @@ fixes=
[ -n "$APORTSDIR" ] || error "can't locate \$APORTSDIR"
git rev-parse 2>/dev/null || die "not in a git tree"
args=`getopt -o f:s:Rkqh --long fixes:,security:,recursive,keep,quiet,help \
-n "$program" -- "$@"`
args=$(getopt -o f:s:Rkqh --long fixes:,security:,recursive,keep,quiet,help \
-n "$program" -- "$@")
if [ $? -ne 0 ]; then
usage
exit 2
@ -136,4 +136,3 @@ fi
abuild_opts="$recursive $keep"
do_bump "$@"

View File

@ -3,7 +3,10 @@
use strict;
use warnings;
use feature qw(:5.10);
use 5.016;
use feature "switch";
no if $] >= 5.018, warnings => "experimental::smartmatch";
use LWP::UserAgent;
use LWP::ConnCache;
use CPAN::Meta;
@ -11,8 +14,9 @@ use Module::CoreList;
use JSON;
my $license_mappings = {
"perl_5" => "GPL PerlArtistic",
"artistic_2" => "Artistic-2",
"perl_5" => "GPL-1.0-or-later OR Artistic-1.0-Perl",
"artistic_2" => "Artistic-2.0",
"gpl_3" => "GPL-3.0-only",
};
my $package_mappings = {
@ -21,37 +25,31 @@ my $package_mappings = {
};
our $packager = "";
my $template = <<'EOF';
# Automatically generated by apkbuild-cpan, template 1
# Contributor: [% packager %]
# Maintainer: [% packager %]
# Automatically generated by apkbuild-cpan, template 2
[% authors %]
pkgname=[% pkgname %]
_pkgreal=[% pkgreal %]
pkgver=[% pkgver %]
pkgrel=0
pkgdesc="Perl module for [% pkgreal %]"
url="http://search.cpan.org/dist/[% pkgreal %]/"
url="https://metacpan.org/release/[% pkgreal %]/"
arch="noarch"
license="GPL PerlArtistic"
license="GPL-1.0-or-later Artistic-1.0-Perl"
cpandepends=""
cpanmakedepends=""
cpancheckdepends=""
depends="$cpandepends"
makedepends="perl-dev $cpanmakedepends"
checkdepends="$cpancheckdepends"
subpackages="$pkgname-doc"
source="[% source %]"
builddir="$srcdir/$_pkgreal-$pkgver"
prepare() {
default_prepare || return 1
cd "$builddir"
if [ -e Build.PL ]; then
perl Build.PL installdirs=vendor || return 1
else
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
fi
build() {
:
}
build() {
check() {
:
}
@ -66,8 +64,7 @@ our $json = JSON->new;
$ua->env_proxy;
$ua->conn_cache(LWP::ConnCache->new());
sub read_file
{
sub read_file {
my ($filename) = @_;
local $/;
open my $fh, "<", $filename or die "could not open $filename: $!";
@ -76,10 +73,15 @@ sub read_file
sub read_assignments_from_file {
my ($filename) = @_;
return () if ( ! -e $filename );
my $text = read_file($filename);
my %sline = $text =~ /^(\w+)\s*=\s*([^\"\n]*)$/mg;
my %mline = $text =~ /^(\w+)\s*=\s*\"([^\"]*)\"$/mg;
my %hash = ( %sline, %mline );
my $authors = join("\n", $text =~ /^# Contributor: .*$/mg, $text =~ /^# Maintainer: .*$/mg);
$hash{'authors'} = $authors if length($authors) > 1;
return \%hash;
}
@ -96,17 +98,20 @@ sub read_apkbuild {
}
sub write_apkbuild {
my ($distdata) = @_;
my ($distdata, $authors, $moddata) = @_;
my $cpanid = $distdata->{releases}[0]->{cpanid};
my $cpanid = $distdata->{id};
$cpanid = substr($cpanid, 0, 1) . "/" . substr($cpanid, 0, 2) . "/$cpanid";
my %repl = (
packager => $packager,
pkgname => map_cpan_to_apk($distdata->{name}),
pkgreal => $distdata->{name},
pkgver => $distdata->{releases}[0]->{version},
source => "http://search.cpan.org/CPAN/authors/id/$cpanid/\$_pkgreal-\$pkgver.tar.gz",
authors => ($authors or "# Contributor: $packager\n# Maintainer: $packager"),
pkgname => map_cpan_to_apk($moddata->{distribution}),
pkgreal => $moddata->{distribution},
pkgver => $moddata->{version} =~ s/^[^0-9]+//r,
source => $moddata->{download_url},
pkgdesc => $distdata->{abstract},
);
$repl{source} =~ s/$repl{pkgver}/\$pkgver/g;
$template =~ s/\[% (.*?) %\]/$repl{$1}/g;
open my $fh, '>', "APKBUILD" or die;
@ -123,23 +128,24 @@ sub parse_deps {
my $deps = "";
for my $module ($reqs->required_modules) {
if (my $perlver = Module::CoreList->first_release($module)) {
if (Module::CoreList->is_core($module)) {
my $perlver = Module::CoreList->first_release($module);
say "$module is part of core perl since $perlver.";
next;
}
next if $module eq 'perl';
# map module name to package name
$response = $ua->get("http://search.cpan.org/api/module/$module");
$response = $ua->get("https://fastapi.metacpan.org/module/$module");
$response->is_success or die $response->status_line;
my $moddata = $json->decode($response->decoded_content);
$moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n";
$distfiles->{$moddata->{distvname}} = $moddata;
$distfiles->{$moddata->{distribution}} = $moddata;
}
# map package names to alpine packages
foreach ( keys $distfiles ) {
$response = $ua->get("http://search.cpan.org/api/dist/$_");
foreach ( keys %{ $distfiles } ) {
$response = $ua->get("https://fastapi.metacpan.org/release/$_");
$response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content);
$distdata->{error} and die "Error trying to locate $_: $distdata->{error}\n";
@ -147,7 +153,8 @@ sub parse_deps {
my $pkgname = map_cpan_to_apk($distdata->{name});
$deps .= "$pkgname ";
}
$deps =~ s/\s+$//;
$deps =~ s/\h+/ /g;
$deps =~ s/ $//;
return $deps;
}
@ -160,67 +167,58 @@ sub prepare_tree {
sub update_functions {
my $apkbuild = read_apkbuild;
my $metaprefix = "src/" . $apkbuild->{'_pkgreal'} . "-" . $apkbuild->{'pkgver'} . "/";
my $prepare_func;
my $build_func;
my $check_func;
my $package_func;
my $text = read_file "APKBUILD";
if (-e "$metaprefix/Build.PL" ) {
$prepare_func = <<'EOF';
prepare() {
default_prepare || return 1
cd "$builddir"
export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
perl Build.PL installdirs=vendor || return 1
}
EOF
$build_func = <<'EOF';
build() {
cd "$builddir"
export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
./Build && ./Build test
perl Build.PL installdirs=vendor
./Build
}
EOF
$package_func = <<'EOF';
package() {
cd "$builddir"
./Build install destdir="$pkgdir" || return 1
./Build install destdir="$pkgdir"
find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete
}
EOF
$check_func = <<'EOF';
check() {
./Build test
}
EOF
} else {
$prepare_func = <<'EOF';
prepare() {
default_prepare || return 1
cd "$builddir"
export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
}
EOF
$build_func = <<'EOF';
build() {
cd "$builddir"
export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
make && make test
PERL_MM_USE_DEFAULT=1 perl -I. Makefile.PL INSTALLDIRS=vendor
make
}
EOF
$package_func = <<'EOF';
package() {
cd "$builddir"
make DESTDIR="$pkgdir" install || return 1
make DESTDIR="$pkgdir" install
find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete
}
EOF
$check_func = <<'EOF';
check() {
export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
make test
}
EOF
}
$text =~ s/^prepare\(\) \{.*?^\}\n/$prepare_func/smg or
die "Can't replace prepare function APKBUILD";
$text =~ s/^build\(\) \{.*?^\}\n/$build_func/smg or
die "Can't replace build function APKBUILD";
$text =~ s/^package\(\) \{.*?^\}\n/$package_func/smg or
die "Can't replace package function APKBUILD";
$text =~ s/^check\(\) \{.*?^\}\n/$check_func/smg or
die "Can't replace check function APKBUILD";
open my $fh, '>', "APKBUILD" or die;
print $fh $text;
@ -228,6 +226,7 @@ EOF
}
sub do_depends {
my $apkbuild = read_apkbuild;
my $metaprefix = "src/" . $apkbuild->{'_pkgreal'} . "-" . $apkbuild->{'pkgver'} . "/";
my $meta;
@ -251,14 +250,21 @@ sub do_depends {
say "CPAN deps: $deps";
say "Recommend: " . parse_deps $meta->effective_prereqs->requirements_for('runtime', 'recommends');
my $makedeps = parse_deps $meta->effective_prereqs->requirements_for('build', 'requires');
$makedeps .= ' ' . parse_deps $meta->effective_prereqs->requirements_for('build', 'recommends');
$makedeps .= ' ' . parse_deps $meta->effective_prereqs->requirements_for('test', 'requires');
$makedeps .= ' ' . parse_deps $meta->effective_prereqs->requirements_for('test', 'recommends');
my $makedeps = parse_deps(
$meta->effective_prereqs->requirements_for('configure', 'requires'),
$meta->effective_prereqs->requirements_for('configure', 'recommends'),
$meta->effective_prereqs->requirements_for('build', 'requires'),
$meta->effective_prereqs->requirements_for('build', 'recommends')
);
say "CPAN build deps: $makedeps";
say "CPAN requires: " . parse_deps($meta->effective_prereqs->requirements_for('configure', 'requires'), $meta->effective_prereqs->requirements_for('build', 'requires'));
say "CPAN recommds: " . parse_deps($meta->effective_prereqs->requirements_for('configure', 'recommends'), $meta->effective_prereqs->requirements_for('build', 'recommends'));
my $checkdeps = parse_deps($meta->effective_prereqs->requirements_for('test', 'requires'), $meta->effective_prereqs->requirements_for('test', 'recommends'));
say "CPAN check deps: $makedeps";
my $text = read_file "APKBUILD";
if ($abstract) {
if ($abstract && $abstract ne 'unknown') {
$text =~ s/^pkgdesc=\"([^\"]*)\"$/pkgdesc=\"$abstract\"/mg or
die "Can't find cpandepends line in APKBUILD";
}
@ -274,6 +280,8 @@ sub do_depends {
die "Can't find cpandepends line in APKBUILD";
$text =~ s/^cpanmakedepends=\"([^\"]*)\"$/cpanmakedepends=\"$makedeps\"/mg or
die "Can't find cpanmakedepends line in APKBUILD";
$text =~ s/^cpancheckdepends=\"([^\"]*)\"$/cpancheckdepends=\"$checkdeps\"/mg or
die "Can't find cpancheckdepends line in APKBUILD";
open my $fh, '>', "APKBUILD" or die;
print $fh $text;
@ -282,52 +290,61 @@ sub do_depends {
sub get_data {
my $apkbuild = read_apkbuild;
my $response = $ua->get("http://search.cpan.org/api/dist/$apkbuild->{_pkgreal}");
$apkbuild->{_pkgreal} or die "Not apkbuild-cpan generated APKBUILD";
my $response = $ua->get("https://fastapi.metacpan.org/release/$apkbuild->{_pkgreal}");
$response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content);
$distdata->{error} and die "Error trying to locate $apkbuild->{_pkgreal}: $distdata->{error}\n";
return ($apkbuild, $distdata);
$response = $ua->get("https://fastapi.metacpan.org/module/$distdata->{main_module}");
$response->is_success or die $response->status_line;
my $moddata = $json->decode($response->decoded_content);
$moddata->{error} and die "Error trying to locate $distdata->{main_module}: $moddata->{error}\n";
return ($apkbuild, $distdata, $moddata);
}
my $abuild_conf = read_assignments_from_file("/etc/abuild.conf");
$packager = $abuild_conf->{PACKAGER} if $abuild_conf->{PACKAGER};
my $user_abuild_conf = read_assignments_from_file($ENV{"HOME"} . "/.abuild/abuild.conf");
$packager = $user_abuild_conf->{PACKAGER} if $user_abuild_conf->{PACKAGER};
given ( $ARGV[0] ) {
when ("create") {
my $module = $ARGV[1];
my $response;
$module or die "Module name is a mandatory argument";
$response = $ua->get("http://search.cpan.org/api/module/$module");
$response = $ua->get("https://fastapi.metacpan.org/module/$module");
$response->is_success or die $response->status_line;
my $moddata = $json->decode($response->decoded_content);
$moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n";
$response = $ua->get("http://search.cpan.org/api/dist/$moddata->{distvname}");
$response = $ua->get("https://fastapi.metacpan.org/release/$moddata->{distribution}");
$response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content);
$distdata->{error} and die "Error trying to locate $module: $distdata->{error}\n";
my $apkname = map_cpan_to_apk $distdata->{name};
my $apkname = map_cpan_to_apk $distdata->{metadata}{name};
mkdir $apkname;
chdir $apkname;
write_apkbuild($distdata);
write_apkbuild($distdata, undef, $moddata);
prepare_tree;
update_functions;
do_depends;
}
when ("recreate") {
my ($apkbuild, $distdata) = get_data;
write_apkbuild($distdata);
my ($apkbuild, $distdata, $moddata) = get_data;
write_apkbuild($distdata, $apkbuild->{authors}, $moddata);
prepare_tree;
update_functions;
do_depends;
}
when ("upgrade") {
my ($apkbuild, $distdata) = get_data;
my ($apkbuild, $distdata, $moddata) = get_data;
my $pkgver = $distdata->{releases}[0]->{version};
my $pkgver = $moddata->{version} =~ s/^[^0-9]+//r;
if ($pkgver != $apkbuild->{pkgver}) {
say "Upgrading CPAN module from $apkbuild->{pkgver} to $pkgver";
@ -346,8 +363,8 @@ given ( $ARGV[0] ) {
}
}
when ('check') {
my ($apkbuild, $distdata) = get_data;
my $pkgver = $distdata->{releases}[0]->{version};
my ($apkbuild, $distdata, $moddata) = get_data;
my $pkgver = $moddata->{version} =~ s/^[^0-9]+//r;
say "$apkbuild->{pkgname}: Latest version: $pkgver Packaged version: $apkbuild->{pkgver}";
if ($pkgver ne $apkbuild->{pkgver}) {
exit(1);

View File

@ -211,7 +211,7 @@ end
class Update
def initialize
def initialize
@gems = {}
@deps = []
end

View File

@ -13,37 +13,40 @@ my %pkgmap = ();
my %licenses = ();
my $template = <<'EOF';
# Contributor: [% contributor %]
# Maintainer: [% maintainer %]
[% authors %]
pkgname=[% pkgname %]
_pkgreal=[% pkgreal %]
pkgver=[% pkgver %]
pkgrel=0
pkgdesc=[% pkgdesc %]
pkgdesc="[% pkgdesc %]"
url="http://packages.python.org/pypi/[% pkgreal %]"
arch="noarch"
license="PSF"
license="[% license %]"
pydepends=""
pymakedepends=""
depends="python $pydepends"
makedepends="python-dev $pymakedepends"
subpackages="$pkgname-doc"
depends="python3 $pydepends"
checkdepends="python3-dev"
makedepends="py3-setuptools $pymakedepends"
subpackages=""
source="[% source %]"
builddir="$srcdir/$_pkgreal-$pkgver"
build() {
cd "$builddir"
python setup.py build || return 1
python3 setup.py build
}
package() {
cd "$builddir"
python setup.py install \
PYTHONPATH=$pkgdir`python3 -c "import site; print(site.getsitepackages()[0])"` \
python3 setup.py install \
--prefix=/usr \
--root="$pkgdir" \
--single-version-externally-managed \
|| return 1
--single-version-externally-managed
}
check() {
python3 setup.py test
}
EOF
my $ua = LWP::UserAgent->new();
@ -61,19 +64,22 @@ sub read_file {
sub read_assignments_from_file {
my ($filename) = @_;
return () if ( ! -e $filename );
my $text = read_file($filename);
my %sline = $text =~ /^(\w+)\s*=\s*([^\"\n]*)$/mg;
my %mline = $text =~ /^(\w+)\s*=\s*\"([^\"]*)\"$/mg;
my %hash = ( %sline, %mline );
my %temp = (%sline, %mline);
my $authors = join("\n", $text =~ /^# Contributor: .*$/mg, $text =~ /^# Maintainer: .*$/mg);
$hash{'authors'} = $authors if length($authors) > 1;
return \%temp;
return \%hash;
}
sub map_pypi_to_apk {
my ($pypi) = @_;
return $pkgmap{$pypi} unless !exists($pkgmap{$pypi});
return 'py-'.lc($pypi);
return 'py3-'.lc($pypi);
}
sub map_license {
@ -98,15 +104,16 @@ sub read_apkbuild {
}
sub write_apkbuild {
my ($distdata) = @_;
my ($distdata, $authors) = @_;
my %repl = (
packager => $packager,
authors => ($authors or "# Contributor: $packager\n# Maintainer: $packager"),
pkgname => map_pypi_to_apk($distdata->{info}{name}),
pkgreal => $distdata->{info}{name},
pkgver => $distdata->{info}{version},
source => get_source($distdata),
license => map_license($distdata->{info}{license}),
pkgdesc => $distdata->{info}{summary},
);
$template =~ s/\[% (.*?) %\]/$repl{$1}/g;
@ -125,7 +132,7 @@ sub prepare_tree {
sub get_data {
my ($package) = @_;
my $response = $ua->get("http://pypi.python.org/pypi/$package/json");
my $response = $ua->get("https://pypi.python.org/pypi/$package/json");
$response->is_success or die $response->status_line;
my $distdata = $json->decode($response->decoded_content);
@ -136,7 +143,7 @@ sub get_deps {
my ($data) = @_;
chdir "src/$data->{pkgreal}-$data->{pkgver}";
my $reqs = `python ./setup.py --requires`;
my $reqs = `python3 ./setup.py --requires`;
my @reqs = split /\n/, $reqs;
@ -163,6 +170,9 @@ sub get_deps {
my $abuild_conf = read_assignments_from_file('/etc/abuild.conf');
$packager = $abuild_conf->{PACKAGER} if $abuild_conf->{PACKAGER};
my $user_abuild_conf = read_assignments_from_file($ENV{"HOME"} . "/.abuild/abuild.conf");
$packager = $user_abuild_conf->{PACKAGER} if $user_abuild_conf->{PACKAGER};
sub usage {
say <<'EOF';
Usage: apkbuild-pypi [create <package> | check | recreate | upgrade | update]
@ -189,16 +199,17 @@ given ($ARGV[0]) {
mkdir $apkname;
chdir $apkname;
my $data = write_apkbuild($distdata);
my $data = write_apkbuild($distdata, undef);
prepare_tree;
get_deps($data);
} when ('recreate') {
my $apkbuild = read_apkbuild;
my $distdata = get_data($apkbuild->{_pkgreal});
my $data = write_apkbuild($distdata, $apkbuild->{authors});
prepare_tree;
get_deps;
get_deps($data);
} when ('upgrade') {
my $apkbuild = read_apkbuild;
my $distdata = get_data($apkbuild->{_pkgreal});

View File

@ -7,13 +7,13 @@
#
program_version=@VERSION@
datadir=@datadir@
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
if ! [ -f "$datadir/functions.sh" ]; then
echo "$datadir/functions.sh: not found" >&2
if ! [ -f "$sharedir/functions.sh" ]; then
echo "$sharedir/functions.sh: not found" >&2
exit 1
fi
. "$datadir/functions.sh"
. "$sharedir/functions.sh"
show_plain() {
@ -73,21 +73,21 @@ do_nothing() {
}
usage() {
cat >&2 <<__EOF__
$program $program_version - display or bump pkgrel in APKBUILDs
Usage: $program [-z|--zero] [-a|--add] [-g|--clean-git] [-s|--set NUM]
[-t|--test] [-f|--force] DIR or APKBUILD...
Options:
-z, --zero Set pkgrel to 0
-a, --add Add 1 to current pkgrel
-g, --clean-git Only operate on APKBUILDs with clean git status (implies
--add)
-s, --set NUM Set pkgrel to NUM
-t, --test Only verify that files have a valid pkgrel
-f, --force Operate on files without a valid pkgrel
-h, --help Show this help
cat >&2 <<-__EOF__
$program $program_version - display or bump pkgrel in APKBUILDs
Usage: $program [-z|--zero] [-a|--add] [-g|--clean-git] [-s|--set NUM]
[-t|--test] [-f|--force] DIR or APKBUILD...
Options:
-z, --zero Set pkgrel to 0
-a, --add Add 1 to current pkgrel
-g, --clean-git Only operate on APKBUILDs with clean git status (implies
--add)
-s, --set NUM Set pkgrel to NUM
-t, --test Only verify that files have a valid pkgrel
-f, --force Operate on files without a valid pkgrel
-h, --help Show this help
__EOF__
__EOF__
}
cmd=do_show
@ -95,8 +95,8 @@ force=
setto=
only_clean_git=
args=`getopt -o zags:tfqh --long zero,add,clean-git,set:,test,force,quiet,help \
-n "$program" -- "$@"`
args=$(getopt -o zags:tfqh --long zero,add,clean-git,set:,test,force,quiet,help \
-n "$program" -- "$@")
if [ $? -ne 0 ]; then
usage
exit 2
@ -130,10 +130,9 @@ fi
args=$(for a; do p=$(any_buildscript "$a") || die "can't find APKBUILD for $a"; echo "$p"; done)
[ $? -eq 0 ] || exit 1
oldifs=$IFS
IFS=$'\n'
IFS=$(printf '\n')
set -- $args
IFS=$oldifs
do_verify "$@" || exit 1
$cmd "$@"

View File

@ -178,7 +178,7 @@ stop-initfs)
cd "$LOGDIR"
mkdir "$NEWROOT$LOGDIR"
cp /sbin/bootchartd $NEWROOT/sbin
PID=`cat bootchart.pid`
PID=$(cat bootchart.pid)
kill -USR2 $PID
wait $PID
mv * "$NEWROOT$LOGDIR"

View File

@ -3,7 +3,7 @@
program_version=@VERSION@
sysconfdir=@sysconfdir@
abuildrepo=/var/lib/buildlab/result
datadir=@datadir@
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
BUILD_BASE="build-base"
SUDO=${SUDO:-"sudo"}
@ -15,32 +15,32 @@ ABUILD_CONF=${ABUILD_CONF:-"$sysconfdir/abuild.conf"}
[ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF"
default_colors() {
NORMAL="\033[1;0m"
STRONG="\033[1;1m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
NORMAL="\033[1;0m"
STRONG="\033[1;1m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
}
default_colors
is_local() {
case "$1" in
http://*|ftp://*|https://*|saveas-*://*)
return 1;;
esac
return 0
case "$1" in
http://*|ftp://*|https://*|saveas-*://*)
return 1;;
esac
return 0
}
msg() {
local prompt="$GREEN>>>${NORMAL}"
[ -z "$quiet" ] && printf "${prompt} $@\n" >&2
[ -z "$quiet" ] && printf "${prompt} $@\n" >&2
}
error() {
local prompt="$RED>>>${NORMAL}"
printf "${prompt} $@\n" >&2
printf "${prompt} $@\n" >&2
}
die() {
@ -49,9 +49,9 @@ die() {
}
runpart() {
local part=$1
local part=$1
msg "Running part $part"
$part || die "$part failed"
$part || die "$part failed"
}
is_vserver() {
@ -161,9 +161,9 @@ prepare_chroot() {
msg "Generating buildlab signing keys..."
do_chroot_action "$path" su abuild -c "'abuild-keygen -ai'"
msg "Setting up repository symlink..."
mkdir -p "$path"/home/abuild/.cache/apks
mkdir -p "$path"/home/abuild/.cache/apks
do_chroot_action "$path" chown abuild:abuild /home/abuild/${src}
do_chroot_action "$path" ln -sf .cache/apks /home/abuild/repo
@ -221,33 +221,35 @@ build_package() {
}
usage() {
echo "buildlab $program_version"
echo " "
echo "Common options:"
echo " "
echo " -q Quiet operation"
echo " -p Path to buildroot"
echo " "
echo "Creating build roots (buildlab -C):"
echo " "
echo " -m APK repository mirror"
echo " -v APK distribution version"
echo " -a APK repository architecture"
echo " -k Enable APK caching"
echo " "
echo "Updating build roots (buildlab -u):"
echo " "
echo " No special options."
echo " "
echo "Building packages (buildlab -b):"
echo " "
echo " -b APKBUILD file"
echo " "
echo "Examples:"
echo " "
echo "sudo ./buildlab -C -p /home/nenolod/buildroot -m dl-3.alpinelinux.org -v edge -a x86_64"
echo "sudo ./buildlab -b /home/nenolod/aports/main/gnome-panel/APKBUILD -p /home/nenolod/buildroot"
echo "sudo ./buildlab -u -p /home/nenolod/buildroot"
cat <<-EOF
buildlab $program_version
Common options:
-q Quiet operation
-p Path to buildroot
Creating build roots (buildlab -C):
-m APK repository mirror
-v APK distribution version
-a APK repository architecture
-k Enable APK caching
Updating build roots (buildlab -u):
No special options.
Building packages (buildlab -b):
-b APKBUILD file
Examples:
sudo ./buildlab -C -p /home/nenolod/buildroot -m dl-3.alpinelinux.org -v edge -a x86_64
sudo ./buildlab -b /home/nenolod/aports/main/gnome-panel/APKBUILD -p /home/nenolod/buildroot
sudo ./buildlab -u -p /home/nenolod/buildroot
EOF
}
unset force
@ -256,8 +258,8 @@ while getopts "chqCkp:v:m:a:b:u" opt; do
case $opt in
'c') default_colors
color_opt="-c";;
'h') usage;;
'q') quiet="-q";;
'h') usage;;
'q') quiet="-q";;
'C') create="-c";;
'p') buildpath="$OPTARG";;
'm') buildmirror="$OPTARG";;
@ -266,7 +268,7 @@ while getopts "chqCkp:v:m:a:b:u" opt; do
'k') enablecache=1;;
'b') buildpkg="$OPTARG";;
'u') update="-u";;
esac
esac
done
shift $(( $OPTIND - 1 ))

View File

@ -7,23 +7,23 @@
#
program_version=@VERSION@
datadir=@datadir@
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
if ! [ -f "$datadir/functions.sh" ]; then
echo "$datadir/functions.sh: not found" >&2
if ! [ -f "$sharedir/functions.sh" ]; then
echo "$sharedir/functions.sh: not found" >&2
exit 1
fi
. "$datadir/functions.sh"
. "$sharedir/functions.sh"
usage() {
cat >&2 <<__EOF__
$program $program_version - find ABI breakages in package upgrades
Usage: $program
cat >&2 <<-__EOF__
$program $program_version - find ABI breakages in package upgrades
Usage: $program
Run in the directory of a built package.
Run in the directory of a built package.
__EOF__
__EOF__
}
if [ $# -gt 0 ]; then
@ -47,6 +47,7 @@ fi
startdir="$PWD"
tmpdir=$(mktemp -d -t checkpkg-script.XXXXXX)
trap "rm -rf '$tmpdir'" INT EXIT
cd "$tmpdir" || die "failed to create temp dir"
for i in $pkgname $subpackages; do
@ -63,10 +64,10 @@ for i in $pkgname $subpackages; do
done
[ -f "$filepath" ] || die "can't find $pkgfile"
# generate a temp repositories file with only the http repos
grep ^http: /etc/apk/repositories > $tmpdir/repositories
# generate a temp repositories file with only the http(s) repos
grep -E "^https?:" /etc/apk/repositories > $tmpdir/repositories
oldpkg=$(apk fetch --repositories-file $tmpdir/repositories --simulate 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
@ -91,5 +92,3 @@ for i in $pkgname $subpackages; do
msg "No soname differences for $_pkgname."
fi
done
msg "Files saved to $tmpdir"

1456
config.guess vendored Normal file

File diff suppressed because it is too large Load Diff

91
config.sub vendored Executable file → Normal file
View File

@ -1,8 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2013 Free Software Foundation, Inc.
# Copyright 1992-2016 Free Software Foundation, Inc.
timestamp='2013-04-24'
timestamp='2016-06-20'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@ timestamp='2013-04-24'
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
# Please send patches to <config-patches@gnu.org>.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@ -33,7 +33,7 @@ timestamp='2013-04-24'
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
@ -53,8 +53,7 @@ timestamp='2013-04-24'
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
Canonicalize a configuration name.
@ -68,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright 1992-2013 Free Software Foundation, Inc.
Copyright 1992-2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -117,7 +116,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
@ -255,16 +254,18 @@ case $basic_machine in
| arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| ba \
| be32 | be64 \
| bfin \
| c4x | clipper \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
| e2k | epiphany \
| fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| k1om \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
@ -282,8 +283,10 @@ case $basic_machine in
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa32r6 | mipsisa32r6el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64r6 | mipsisa64r6el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
@ -295,14 +298,14 @@ case $basic_machine in
| nds32 | nds32le | nds32be \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 \
| or1k | or32 \
| open8 | or1k | or1knd | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
| riscv32 | riscv64 \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@ -310,6 +313,7 @@ case $basic_machine in
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| visium \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
@ -324,7 +328,10 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
leon|leon[3-9])
basic_machine=sparc-$basic_machine
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@ -369,18 +376,20 @@ case $basic_machine in
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| ba-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
| c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| e2k-* | elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| k1om-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
@ -400,8 +409,10 @@ case $basic_machine in
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa32r6-* | mipsisa32r6el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64r6-* | mipsisa64r6el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
@ -413,16 +424,18 @@ case $basic_machine in
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| or1k*-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
| riscv32-* | riscv64-* \
| rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile*-* \
@ -430,6 +443,7 @@ case $basic_machine in
| ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| visium-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@ -506,6 +520,9 @@ case $basic_machine in
basic_machine=i386-pc
os=-aros
;;
asmjs)
basic_machine=asmjs-unknown
;;
aux)
basic_machine=m68k-apple
os=-aux
@ -626,6 +643,14 @@ case $basic_machine in
basic_machine=m68k-bull
os=-sysv3
;;
e500v[12])
basic_machine=powerpc-unknown
os=$os"spe"
;;
e500v[12]-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
os=$os"spe"
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
@ -767,6 +792,9 @@ case $basic_machine in
basic_machine=m68k-isi
os=-sysv
;;
leon-*|leon[3-9]-*)
basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
@ -794,7 +822,7 @@ case $basic_machine in
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
@ -822,6 +850,10 @@ case $basic_machine in
basic_machine=powerpc-unknown
os=-morphos
;;
moxiebox)
basic_machine=moxie-unknown
os=-moxiebox
;;
msdos)
basic_machine=i386-pc
os=-msdos
@ -830,7 +862,7 @@ case $basic_machine in
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i386-pc
basic_machine=i686-pc
os=-msys
;;
mvs)
@ -1354,27 +1386,28 @@ case $os in
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -aos* | -aros* | -cloudabi* | -sortix* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -bitrig* | -openbsd* | -solidbsd* \
| -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
| -onefs* | -tirtos* | -phoenix*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@ -1506,6 +1539,8 @@ case $os in
;;
-nacl*)
;;
-ios)
;;
-none)
;;
*)
@ -1546,6 +1581,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;
@ -1589,9 +1627,6 @@ case $basic_machine in
mips*-*)
os=-elf
;;
or1k-*)
os=-elf
;;
or32-*)
os=-coff
;;

View File

@ -3,6 +3,26 @@
sysconfdir=@sysconfdir@
program=${0##*/}
arch_to_hostspec() {
case "$1" in
aarch64) echo "aarch64-azaezel-linux-musl" ;;
armel) echo "armv5-azaezel-linux-musleabi" ;;
armhf) echo "armv6-azaezel-linux-musleabihf" ;;
armv7) echo "armv7-azaezel-linux-musleabihf" ;;
mips) echo "mips-azaezel-linux-musl" ;;
mips64) echo "mips64-azaezel-linux-musl" ;;
mipsel) echo "mipsel-azaezel-linux-musl" ;;
mips64el) echo "mips64el-azaezel-linux-musl" ;;
ppc) echo "powerpc-azaezel-linux-musl" ;;
ppc64) echo "powerpc64-azaezel-linux-musl" ;;
ppc64le) echo "powerpc64le-azaezel-linux-musl" ;;
s390x) echo "s390x-azaezel-linux-musl" ;;
x86) echo "i586-azaezel-linux-musl" ;;
x86_64) echo "x86_64-azaezel-linux-musl" ;;
*) echo "unknown" ;;
esac
}
hostspec_to_arch() {
case "$1" in
aarch64*-*-*-*) echo "aarch64" ;;
@ -10,6 +30,14 @@ hostspec_to_arch() {
armv6*-*-*-*eabihf) echo "armhf" ;;
armv7*-*-*-*eabihf) echo "armv7" ;;
i[0-9]86-*-*-*) echo "x86" ;;
mips-*-*-*) echo "mips" ;;
mips64-*-*-*) echo "mips64" ;;
mipsel-*-*-*) echo "mipsel" ;;
mips64el-*-*-*) echo "mips64el" ;;
powerpc-*-*-*) echo "ppc" ;;
powerpc64-*-*-*) echo "ppc64" ;;
powerpc64le-*-*-*) echo "ppc64le" ;;
s390x-*-*-*) echo "s390x" ;;
x86_64-*-*-*) echo "x86_64" ;;
*) echo "unknown" ;;
esac
@ -27,7 +55,7 @@ hostspec_to_libc() {
readconfig() {
local _APORTSDIR _BUILDDIR _PKGDEST _SRCPKGDEST _REPODEST _SRCDEST
local _CARCH _CHOST _CTARGET _CPPFLAGS _CFLAGS _CXXFLAGS _LDFLAGS
local _JOBS _MAKEFLAGS _PACKAGER _USE_COLORS
local _JOBS _MAKEFLAGS _PACKAGER _USE_COLORS _USE_CCACHE
local gitbase=
[ -n "${APORTSDIR+x}" ] && _APORTSDIR=$APORTSDIR
[ -n "${BUILDDIR+x}" ] && _BUILDDIR=$BUILDDIR
@ -46,21 +74,23 @@ readconfig() {
[ -n "${MAKEFLAGS+x}" ] && _MAKEFLAGS=$MAKEFLAGS
[ -n "${PACKAGER+x}" ] && _PACKAGER=$PACKAGER
[ -n "${USE_COLORS+x}" ] && _USE_COLORS="$USE_COLORS"
[ -n "${USE_CCACHE+x}" ] && _USE_CCACHE="$USE_CCACHE"
: ${ABUILD_CONF:=$sysconfdir/abuild.conf}
: ${ABUILD_USERDIR:=$HOME/.abuild}
: ${ABUILD_USERCONF:=$ABUILD_USERDIR/abuild.conf}
[ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF"
[ -f "$ABUILD_USERCONF" ] && . "$ABUILD_USERCONF"
APORTSDIR=${_APORTSDIR-$APORTSDIR}
gitbase=$(git rev-parse --show-toplevel 2>/dev/null) # already is -P
gitbase=$(git rev-parse --show-toplevel 2>/dev/null) || true # already is -P
if [ -d "$APORTSDIR" ]; then
APORTSDIR=$(cd "$APORTSDIR"; pwd -P)
elif [ -z "$APORTSDIR" ] && [ -d "$HOME/aports" ]; then
APORTSDIR=$(cd "$HOME/aports"; pwd -P)
else
if [ -n "$gitbase" ]; then
case $(git config remote.origin.url) in
*/aports) APORTSDIR=$gitbase ;;
case $(git remote get-url origin) in
# '.git' for SSH URLs, and no suffix for HTTPS URLs
*/aports|*/aports.git) APORTSDIR=$gitbase ;;
*) APORTSDIR= ;;
esac
else
@ -85,15 +115,57 @@ readconfig() {
MAKEFLAGS=${_MAKEFLAGS-$MAKEFLAGS}
PACKAGER=${_PACKAGER-$PACKAGER}
USE_COLORS=${_USE_COLORS-$USE_COLORS}
USE_CCACHE=${_USE_CCACHE-$USE_CCACHE}
[ -z "$CBUILD" ] && CBUILD="$(gcc -dumpmachine)"
[ -z "$CBUILD" ] && CBUILD="$(${APK:-apk} --print-arch 2>/dev/null)"
[ -z "$CHOST" ] && CHOST="$CBUILD"
[ -z "$CTARGET" ] && CTARGET="$CHOST"
[ "$(arch_to_hostspec $CBUILD)" != "unknown" ] && CBUILD="$(arch_to_hostspec $CBUILD)"
[ "$(arch_to_hostspec $CHOST)" != "unknown" ] && CHOST="$(arch_to_hostspec $CHOST)"
[ "$(arch_to_hostspec $CTARGET)" != "unknown" ] && CTARGET="$(arch_to_hostspec $CTARGET)"
if [ -z "$CBUILD" ]; then
echo "Unable to deduce build architecture. Install apk-tools, or set CBUILD."
exit 1
fi
[ -z "$CARCH" ] && CARCH="$(hostspec_to_arch $CHOST)"
[ -z "$CLIBC" ] && CLIBC="$(hostspec_to_libc $CHOST)"
[ -z "$CBUILD_ARCH" ] && CBUILD_ARCH="$(hostspec_to_arch $CBUILD)"
[ -z "$CTARGET_ARCH" ] && CTARGET_ARCH="$(hostspec_to_arch $CTARGET)"
[ -z "$CTARGET_LIBC" ] && CTARGET_LIBC="$(hostspec_to_libc $CTARGET)"
if [ "$CHOST" != "$CTARGET" ]; then
# setup environment for creating cross compiler
[ -z "$CBUILDROOT" ] && export CBUILDROOT="$HOME/sysroot-$CTARGET_ARCH/"
elif [ "$CBUILD" != "$CHOST" ]; then
# setup build root
[ -z "$CBUILDROOT" ] && export CBUILDROOT="$HOME/sysroot-$CTARGET_ARCH/"
# prepare pkg-config for cross building
[ -z "$PKG_CONFIG_PATH" ] && export PKG_CONFIG_PATH="${CBUILDROOT}/usr/lib/pkgconfig/"
[ -z "$PKG_CONFIG_SYSROOT_DIR" ] && export PKG_CONFIG_SYSROOT_DIR="${CBUILDROOT}"
# libtool bug workaround for extra rpaths
[ -z "$lt_cv_sys_lib_dlsearch_path_spec" ] && \
export lt_cv_sys_lib_dlsearch_path_spec="${CBUILDROOT}/lib ${CBUILDROOT}/usr/lib /usr/lib /lib /usr/local/lib"
# setup cross-compiler
if [ -z "$CROSS_COMPILE" ]; then
export CROSS_COMPILE="${CHOST}-"
export HOSTCC="$CC"
export HOSTCXX="$CXX"
export HOSTLD="$LD"
export HOSTCPPFLAGS="$CPPFLAGS"
export HOSTCXXFLAGS="$CXXFLAGS"
export HOSTCFLAGS="$CFLAGS"
export HOSTLDFLAGS="$LDFLAGS"
export CC=${CROSS_COMPILE}gcc
export CXX=${CROSS_COMPILE}g++
export LD=${CROSS_COMPILE}ld
export CPPFLAGS="--sysroot=${CBUILDROOT} $CPPFLAGS"
export CXXFLAGS="--sysroot=${CBUILDROOT} $CXXFLAGS"
export CFLAGS="--sysroot=${CBUILDROOT} $CFLAGS"
export LDFLAGS="--sysroot=${CBUILDROOT} $LDFLAGS"
fi
fi
return 0
}
readconfig
@ -178,7 +250,9 @@ enable_colors() {
BLUE="\033[1;34m"
}
if [ -n "$USE_COLORS" ] && [ -t 1 ]; then
if [ "$USE_COLORS" = force ]; then
enable_colors
elif [ -n "$USE_COLORS" ] && [ -t 1 ]; then
enable_colors
else
disable_colors

175
newapkbuild.1 Normal file
View File

@ -0,0 +1,175 @@
.Dd November 4, 2017
.Dt NEWAPKBUILD 1 PRM
.Os "Alpine Linux"
.Sh NAME
.Nm newapkbuild
.Nd generate a new APKBUILD
.Sh SYNOPSIS
.Nm
.Op Fl n Ar NAME
.Op Fl d Ar DESC
.Op Fl l Ar LICENSE
.Op Fl u Ar URL
.Op Fl aCmpy
.Op Fl cfhs
.Op Ar pkgname Op Ar -pkgver
.Nm
.Op Fl n Ar NAME
.Op Fl d Ar DESC
.Op Fl l Ar LICENSE
.Op Fl u Ar URL
.Op Fl aCmpy
.Op Fl cfhs
.Op Ar source_url
.Sh DESCRIPTION
.Nm
generates a new APKBUILD for use with
.Xr abuild 1 .
.Bl -tag -width "pkgname-pkgver" -offset indent -compact
.It Fl n Ar NAME
Specifies the name of the new package.
A new directory called
.Ar NAME
will be created in the current directory, with the APKBUILD file.
.It Fl d Ar DESC
Specifies the description (pkgdesc=) for the new package.
.It Fl l Ar LICENSE
Specifies the license under which the new package is distributed.
This should match an SPDX Identifier.
.It Fl u Ar URL
Specifies the Web page (url=) for the new package.
This should
.Em not
be the source package URL; it should be the project's main Web page.
.It Fl c
Causes
.Nm
to additionally copy an init.d script, conf.d file, and sample pre- and post-
install scripts to the APKBUILD directory.
This allows you to have a quick start for daemon packages.
.It Fl f
Forces
.Nm
to overwrite an existing APKBUILD, if one already exists in the package
directory.
.It Fl h
Displays usage information.
.It Fl s
Create an automatic SourceForge URL for the package based on its name and
version.
This is only valid if
.Ar pkgname-pkgver
is specified on the command line.
.It Ar pkgname-pkgver
Specify the package name, if not already specified by
.Fl n .
If followed by a dash (-) and a valid version string, additionally specify the
package's version.
.El
.Ss Build system type
.Nm
will try to automatically detect the build system by inspecting the source
directory if
.Ar source_url
is specified, and write out typical build instructions for that build system.
If you do not specify the source URL, or you want to override auto-detection,
you may specify one of the following four flags:
.Bl -tag -width "-a" -offset indent -compact
.It Fl a
Specifies that the package uses autotools.
The APKBUILD will contain a typical invocation of ./configure, make, and make
install.
.It Fl C
Specifies that the package uses CMake.
CMake will be added to the makedepends and a typical CMake invocation will be
added to the APKBUILD.
.It Fl m
Specifies that the package uses Meson.
A typical Meson and Ninja invocation will be added to the APKBUILD.
.It Fl p
Specifies that the package uses a Perl Makefile.PL file.
The CPAN template will be used.
.It Fl y
Specifies that the package uses a Python setup.py build system.
Python will be added to the makedepends.
.El
If you do not specify any option, and you do not specify the source URL, the
generated APKBUILD file will not contain any build instructions.
.Sh FILES
All files generated will be placed in a
.Pa pkgname
directory inside the current working directory, with
.Pa pkgname
being created if it does not exist.
.Bl -tag -width "pkgname.post-install" -compact
.It Pa APKBUILD
.Nm
will create
.Pa APKBUILD
with the details gathered from the invocation of
.Nm ,
and introspection of the downloaded package source if
.Ar source_url
is provided.
For more information about APKBUILD and its format, see
.Xr APKBUILD 5 .
.It Pa pkgname.initd
If
.Fl c
is given,
.Nm
will create
.Pa pkgname.initd
with example data to assist in the creation of an init.d script for a daemon.
.It Pa pkgname.confd
If
.Fl c
is given,
.Nm
will create
.Pa pkgname.confd
to assist in the creation of a conf.d file for a daemon, used by init.d
scripts.
conf.d files are used to configure init.d scripts; for more information, see
.Xr openrc 8
and
.Xr rc_config 3 .
.It Pa pkgname.pre-install
If
.Fl c
is given,
.Nm
will create
.Pa pkgname.pre-install ,
the contents of which will be run by
.Xr apk 8
before the package is installed.
.It Pa pkgname.post-install
If
.Fl c
is given,
.Nm
will create
.Pa pkgname.post-install ,
the contents of which will be run by
.Xr apk 8
after the package is successfully installed.
For more information about apk install hooks, consult the
.Xr apk 8
manual.
.El
.Sh EXAMPLES
newapkbuild -n sharutils -d "Utilities for manipulating shell archives" \\
-l "GPL-3.0+" -u "https://www.gnu.org/software/sharutils/" -a \\
https://ftp.gnu.org/gnu/sharutils/sharutils-4.15.2.tar.xz
.Sh SEE ALSO
SPDX license reference (on the Web at <https://spdx.org/licenses/>),
.Xr abuild 1 ,
.Xr apk 8 ,
.Xr APKBUILD 5 .
.Sh AUTHORS
.Nm :
.An Natanael Copa Aq Mt ncopa@alpinelinux.org
.Pp
Documentation:
.An A. Wilcox Aq Mt awilfox@adelielinux.org

View File

@ -7,13 +7,13 @@
#
program_version=@VERSION@
datadir=@datadir@
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
if ! [ -f "$datadir/functions.sh" ]; then
echo "$datadir/functions.sh: not found" >&2
if ! [ -f "$sharedir/functions.sh" ]; then
echo "$sharedir/functions.sh: not found" >&2
exit 1
fi
. "$datadir/functions.sh"
. "$sharedir/functions.sh"
is_url() {
@ -33,7 +33,7 @@ is_github_url() {
# Build sections
build_make() {
cat >>APKBUILD<<__EOF__
make || return 1
make
__EOF__
}
@ -45,9 +45,8 @@ build_autotools() {
--prefix=/usr \\
--sysconfdir=/etc \\
--mandir=/usr/share/man \\
--localstatedir=/var \\
|| return 1
make || return 1
--localstatedir=/var
make
__EOF__
}
@ -58,42 +57,114 @@ build_cmake() {
# This is incomplete: CMAKE_{HOST_,}SYSTEM_PROCESSOR needs to be set,
# and likewise CMAKE_FIND_ROOT_PATH and a few other details.
sed -i -e 's/^\(makedepends="\)/\1cmake /' APKBUILD
cat >>APKBUILD<<__EOF__
if [ "$CBUILD" != "$CHOST" ]
then
if [ "\$CBUILD" != "\$CHOST" ]; then
CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
fi
cmake \\
cmake -B build \\
-DCMAKE_INSTALL_PREFIX=/usr \\
-DCMAKE_INSTALL_LIBDIR=lib \\
-DBUILD_SHARED_LIBS=True \\
-DCMAKE_BUILD_TYPE=Release \\
-DCMAKE_BUILD_TYPE=None \\
-DCMAKE_CXX_FLAGS="\$CXXFLAGS" \\
-DCMAKE_C_FLAGS="\$CFLAGS" \\
${CMAKE_CROSSOPTS} \\
|| return 1
make || return 1
\${CMAKE_CROSSOPTS} .
make -C build
__EOF__
}
build_meson() {
# References:
# http://mesonbuild.com/Reference-manual.html
# http://mesonbuild.com/Cross-compilation.html
# TODO For cross compilation a cross_file needs to be created.
cat >>APKBUILD<<__EOF__
meson \\
--prefix=/usr \\
--sysconfdir=/etc \\
--mandir=/usr/share/man \\
--localstatedir=/var \\
--buildtype=plain \\
. output
ninja -C output
__EOF__
}
build_perl() {
cat >>APKBUILD<<__EOF__
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
make || return 1
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
make
__EOF__
}
build_python() {
cat >>APKBUILD<<__EOF__
python setup.py build || return 1
python3 setup.py build
__EOF__
}
build_rust() {
cat >>APKBUILD<<__EOF__
cargo build --release --locked
__EOF__
}
build_empty() {
cat >>APKBUILD<<__EOF__
# Replace with proper build command(s)
:
__EOF__
}
# Check sections
check_make() {
cat >>APKBUILD<<__EOF__
make check
__EOF__
}
check_cmake() {
cat >>APKBUILD<<__EOF__
CTEST_OUTPUT_ON_FAILURE=1 make -C build check
__EOF__
}
check_python() {
cat >>APKBUILD<<__EOF__
python3 setup.py test
__EOF__
}
check_empty() {
cat >>APKBUILD<<__EOF__
# Replace with proper check command(s)
:
__EOF__
}
check_meson() {
cat >>APKBUILD<<__EOF__
ninja -C output test
__EOF__
}
check_rust() {
cat >>APKBUILD<<__EOF__
cargo test --release
__EOF__
}
# Package sections
package_make() {
cat >>APKBUILD<<__EOF__
make DESTDIR="\$pkgdir" install || return 1
make DESTDIR="\$pkgdir" install
__EOF__
}
package_cmake() {
cat >>APKBUILD<<__EOF__
make -C build DESTDIR="\$pkgdir" install
__EOF__
}
@ -101,16 +172,36 @@ package_autotools() {
package_make
}
package_meson() {
cat >>APKBUILD<<__EOF__
DESTDIR="\$pkgdir" ninja -C output install
__EOF__
}
package_perl() {
cat >>APKBUILD<<__EOF__
make DESTDIR="\$pkgdir" install || return 1
make DESTDIR="\$pkgdir" install
find "\$pkgdir" \\( -name perllocal.pod -o -name .packlist \\) -delete
__EOF__
}
package_python() {
cat >>APKBUILD<<__EOF__
python setup.py install --prefix=/usr --root="\$pkgdir" || return 1
python3 setup.py install --prefix=/usr --root="\$pkgdir"
__EOF__
}
package_empty() {
cat >>APKBUILD<<__EOF__
# Replace with proper package command(s)
:
__EOF__
}
package_rust() {
cat >>APKBUILD<<__EOF__
cargo install --path . --root="\$pkgdir/usr"
rm "\$pkgdir"/usr/.crates.toml
__EOF__
}
@ -129,7 +220,7 @@ newaport() {
fi
pv=${newname%.t*} #strip .tar.gz .tgz .tar.bz2 etc
pv=${pv#*[a-z]}
source="$pkgname-$pv.tar.gz::$source"
source="${source%.t*}/$pkgname-$pv.tar.gz"
elif [ "$pn" != "$newname" ]; then
pv=${newname#$pn-}
pv=${pv%.t*} #strip .tar.gz .tgz .tar.bz2 etc
@ -138,25 +229,27 @@ newaport() {
pkgname=$pn
fi
if [ -e "$pkgname"/APKBUILD ] && [ -z "$force" ]; then
error "$pkgname/APKBUILD already exist"
error "$pkgname/APKBUILD already exists"
return 1
fi
mkdir -p "$pkgname"
cd "$pkgname"
if [ -z "$source" ] && [ -n "$sourceforge" ]; then
source="http://downloads.sourceforge.net/$pn/$pn-$pv.tar.gz"
source="https://downloads.sourceforge.net/$pn/$pn-$pv.tar.gz"
fi
if [ -z "$depends" ] &&[ "$buildtype" = "python" ]; then
depends="python"
depends="python3"
fi
if [ -z "$makedepends" ] &&[ "$buildtype" = "python" ]; then
makedepends="python-dev"
else
makedepends="\$depends_dev"
fi
case "$buildtype" in
python) makedepends="py3-setuptools";;
cmake) makedepends="cmake";;
meson) makedepends="meson";;
rust) makedepends="cargo";;
*) makedepends="\$depends_dev";;
esac
# Replace pkgver in $source
if [ -n "$source" ]; then
@ -165,10 +258,10 @@ newaport() {
# Copy init.d scripts if requested
if [ -n "$cpinitd" ]; then
cp "$datadir"/sample.initd $pkgname.initd
cp "$datadir"/sample.confd $pkgname.confd
cp "$datadir"/sample.pre-install $pkgname.pre-install
cp "$datadir"/sample.post-install $pkgname.post-install
cp "$sharedir"/sample.initd $pkgname.initd
cp "$sharedir"/sample.confd $pkgname.confd
cp "$sharedir"/sample.pre-install $pkgname.pre-install
cp "$sharedir"/sample.post-install $pkgname.post-install
install="\$pkgname.pre-install \$pkgname.post-install"
source="$source
$pkgname.initd
@ -180,8 +273,8 @@ newaport() {
cat >APKBUILD<<__EOF__
# Contributor:${PACKAGER:+" "}${PACKAGER}
# Maintainer:${MAINTAINER:+" "}${MAINTAINER}
pkgname=$pkgname
pkgver=$pv
pkgname="$pkgname"
pkgver="$pv"
pkgrel=0
pkgdesc="$pkgdesc"
url="$url"
@ -195,7 +288,7 @@ subpackages="\$pkgname-dev \$pkgname-doc"
source="$source"
__EOF__
abuild -f fetch unpack
abuild -f fetch checksum unpack
# Figure out the builddir
for i in src/*; do
if [ -d "$i" ]; then
@ -211,7 +304,7 @@ __EOF__
| head -n 1 | grep -q ".*" \
|| sed -i -e '/^depends_dev=.*/d' -e 's/\$depends_dev\s*//' APKBUILD
# Check if its autotools
# Try to autodetect the buildtype
if [ -z "$buildtype" ]; then
if [ -x "$sdir"/configure ]; then
buildtype="autotools"
@ -219,19 +312,22 @@ __EOF__
buildtype="perl"
elif [ -r "$sdir"/waf ]; then
buildtype="waf"
elif [ -d "$sdir"/cmake ]; then
elif [ -r "$sdir"/meson.build ]; then
buildtype="meson"
elif [ -d "$sdir"/cmake ] || [ -r "$sdir/CMakeLists.txt" ]; then
buildtype="cmake"
elif [ -r "$sdir"/Makefile ]; then
buildtype="make"
elif [ -r "$sdir"/setup.py ]; then
buildtype="python"
elif [ -r "$sdir"/Cargo.toml ]; then
buildtype="rust"
fi
fi
# Create build() function
cat >>APKBUILD<<__EOF__
build() {
cd "\$builddir"
__EOF__
case "$buildtype" in
@ -239,12 +335,41 @@ __EOF__
build_make;;
cmake)
build_cmake;;
meson)
build_meson;;
autotools)
build_autotools;;
perl)
build_perl;;
python)
build_python;;
rust)
build_rust;;
*)
build_empty;;
esac
cat >>APKBUILD<<__EOF__
}
__EOF__
# Create check() function
cat >>APKBUILD<<__EOF__
check() {
__EOF__
case "$buildtype" in
make|autotools|perl)
check_make;;
cmake)
check_cmake;;
python)
check_python;;
rust)
check_rust;;
*)
check_empty;;
esac
cat >>APKBUILD<<__EOF__
@ -255,78 +380,117 @@ __EOF__
# Create package() function
cat >>APKBUILD<<__EOF__
package() {
cd "\$builddir"
__EOF__
case "$buildtype" in
make)
package_make;;
cmake)
package_cmake;;
autotools)
package_autotools;;
meson)
package_meson;;
perl)
package_perl;;
python)
package_python;;
rust)
package_rust;;
*)
package_empty;;
esac
if [ -n "$cpinitd" ]; then
cat >>APKBUILD<<__EOF__
install -m755 -D "\$srcdir"/\$pkgname.initd \\
"\$pkgdir"/etc/init.d/\$pkgname || return 1
"\$pkgdir"/etc/init.d/\$pkgname
install -m644 -D "\$srcdir"/\$pkgname.confd \\
"\$pkgdir"/etc/conf.d/\$pkgname || return 1
"\$pkgdir"/etc/conf.d/\$pkgname
__EOF__
fi
cat >>APKBUILD<<__EOF__
}
__EOF__
# regenerate checksum so they end last in APKBUILD
abuild -f checksum
}
usage() {
cat >&2 <<__EOF__
$program $program_version - generate a new APKBUILD
Usage: $program [-cfh] [-d DESC] [-l LICENSE] [-n NAME] [-u URL]
PKGNAME[-PKGVER]|SRCURL
Options:
-n Set package name to NAME
-d Set package description (pkgdesc) to DESC
-l Set package license to LICENSE
-u Set package URL
-a Create autotools (use ./configure ...)
-C Create CMake pakckage (Assume cmake/ is there)
-p Create perl package (Assume Makefile.PL is there)
-y Create python package (Assume setup.py is there)
-s Use sourceforge source URL
-c Copy a sample init.d, conf.d, and install script to new directory
-f Force even if directory already exist
-h Show this help
__EOF__
cat >&2 <<-__EOF__
$program $program_version - generate a new APKBUILD
Usage: $program [-n PKGNAME] [-d PKGDESC] [-l LICENSE] [-u URL]
[-a | -C | -m | -p | -y | -r] [-s] [-c] [-f] [-h]
PKGNAME[-PKGVER] | SRCURL
Options:
-n Set package name to PKGNAME (only use with SRCURL)
-d Set package description to PKGDESC
-l Set package license to LICENSE, use identifiers from:
<https://spdx.org/licenses/>
-u Set package URL
-a Create autotools package (use ./configure ...)
-C Create CMake package (Assume cmake/ is there)
-m Create meson package (Assume meson.build is there)
-p Create perl package (Assume Makefile.PL is there)
-y Create python package (Assume setup.py is there)
-r Crate rust package (Assume Cargo.toml is there)
-s Use sourceforge source URL
-c Copy a sample init.d, conf.d, and install script
-f Force even if directory already exists
-h Show this help
__EOF__
}
while getopts "acd:fhl:n:pyu:s" opt; do
set_buildtype() {
if [ -n "$buildtype" ]; then
error "More than one buildtype flag specified ($buildtype and $1)"
exit 1
fi
buildtype="$1"
}
check_arguments() {
if [ $# -eq 0 ]; then
error "Missing required argument: PKGNAME[-PKGVER] | SRCURL"
exit 1
fi
if [ $# -gt 1 ]; then
shift
error "Unrecognized arguments: $*"
exit 1
fi
if ! is_url "$1" && [ -n "$pkgname" ]; then
error "-n is only allowed when using SRCURL as last argument"
exit 1
fi
if is_url "$1" && [ -n "$sourceforge" ]; then
error "-s is only allowed when using PKGNAME as last argument"
exit 1
fi
}
while getopts "acCmd:fhl:n:pyu:sr" opt; do
case $opt in
'a') buildtype="autotools";;
'a') set_buildtype "autotools";;
'c') cpinitd=1;;
'C') buildtype="cmake";;
'C') set_buildtype "cmake";;
'm') set_buildtype "meson";;
'd') pkgdesc="$OPTARG";;
'f') force=1;;
'h') usage; exit;;
'l') license="$OPTARG";;
'n') pkgname="$OPTARG";;
'p') buildtype="perl";;
'y') buildtype="python";;
'p') set_buildtype "perl";;
'y') set_buildtype "python";;
'r') set_buildtype "rust";;
'u') url="$OPTARG";;
's') sourceforge=1;;
esac
done
shift $(( $OPTIND - 1 ))
while [ $# -gt 0 ]; do
newaport $1 || exit 1
shift
done
check_arguments "$@"
newaport $1

View File

@ -17,7 +17,7 @@ depends_dev=
makedepends="$depends_dev"
install=
subpackages="$pkgname-dev $pkgname-doc"
source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
source="https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
builddir="$srcdir"/$pkgname-$pkgver
@ -31,16 +31,23 @@ build() {
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info
make || return 1
make
}
package() {
cd "$builddir"
make DESTDIR="$pkgdir" install || return 1
make DESTDIR="$pkgdir" install
# remove the 2 lines below (and this) if there is no init.d script
# install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
# install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
}
check() {
# uncomment the 2 lines 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'

View File

@ -1,4 +1,4 @@
#!/bin/sh
# add something which happends after install
# add something which happens after install

View File

@ -1,4 +1,4 @@
#!/bin/sh
# add something which happends before install
# add something which happens before install

12
tests/abuild.bats Normal file
View File

@ -0,0 +1,12 @@
setup() {
export ABUILD=../abuild
export ABUILD_SHAREDIR=$PWD/..
}
@test "help text" {
$ABUILD -h
}
@test "version string" {
$ABUILD -V
}

11
tests/functions.bats Normal file
View File

@ -0,0 +1,11 @@
setup() {
export FUNCS=../functions.sh
}
@test "check if CBUILD is set" {
. $FUNCS && test -n "$CBUILD"
}
@test "check that missing gcc does not kill us" {
sh -e -c "CC=false; . $FUNCS && test -z \"$CBUILD\""
}

View File

@ -0,0 +1,34 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="pkg1"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
subpackages="$pkgname-dev $pkgname-doc"
source=""
builddir="$srcdir/pkg1-1.0"
prepare() {
mkdir -p "$builddir"
}
build() {
mkdir -p usr/include usr/bin usr/share/man/man1
touch usr/include/$pkgname.h
touch usr/bin/$pkgname
touch usr/share/man/man1/$pkgname.1
}
check() {
true
}
package() {
mkdir -p "$pkgdir"
cp -r * "$pkgdir"/
}