summaryrefslogtreecommitdiff
path: root/scripts/libmakepkg
AgeCommit message (Collapse)Author
2019-05-08makepkg: correctly handle hg sources with updates on a non-default branchEli Schwartz
The "tip" ref actually signifies the most recently updated branch. hg does not support a default branch named anything other than "default", except by creating a "@" bookmark. The correct way to explicitly update to the default clone ref, is therefore to use one of these, rather than "tip". Fixes FS#62092 Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-05-08libmakepkg: fix migration to schema.sh for integsumsEli Schwartz
One of the callers was changed to use known_hash_algos, one was not. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-19libmakepkg: fix reporting of invalid archive extensions in compress.shEli Schwartz
In commit 1825bd6716c2a51c92642e8b96beac0101e83805 this was split out from makepkg, but the warning was not properly migrated; $ext did not ever exist. As a result, no matter what you did, the only possible warning was: ==> WARNING: '' is not a valid archive extension. Fix to filter based on the presence of .tar in the argument, and building the $ext variable for all checking and messaging purposes within the function. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-19makepkg: use "shared" git clones when checking out sourcesEli Schwartz
In order to cache sources offline, makepkg creates *two* copies of every git repo. This is a useful tradeoff for network time, but comes at the cost of increased disk space. Normally, git can smooth this over automagically. Whenever possible, git objects are hardlinked to save space, but this does not work when SRCDEST and BUILDDIR are on separate filesystems. When the repo in question is both very large (linux.git for example is 2.2 GB) and crosses filesystem boundaries, this results in a lot of extra disk space being used; the most likely scenario is where BUILDDIR is a tmpfs for bonus ouch. git(1) has a builtin feature which serves this case handily: the --shared flag will create the info/alternates file instructing git to not copy or hardlink or create objects/packs at all, but merely look for them in an external location (that being the source of the clone). The downside of using shared clones, is that if you modify and drop commits from the original repo, or simply delete the whole repo altogether, you break the copy. But we don't care about that here, because 1) the BUILDDIR copy is meant to be a temporary copy strictly derived via PKGBUILD syntax from the SRCDEST, and must be able to be recreated at any time, 2) if the SRCDEST disappears, makepkg will redownload it, thus restoring the objects needed by the BUILDDIR clone, 3) if the user does non-default things like hacking on the BUILDDIR copy then deleting and re-cloning the SRCDEST may result in momentary breakage, but ultimately should be fine -- the unique objects they created will be stored in the BUILDDIR copy. While it's theoretically possible that upstream will force-push to overwrite the base tree from which makepkg is building (which they should not do), *and* the user deleted their SRCDEST which they should not do, *and* they saved work in makepkg's working directory which they should not do either... ... this is an unlikely chain of events for which we should not care. Using --shared is therefore helpful in immediately useful ways and IMHO has no actual downsides; we should use it. An alternative implementation would be to use worktrees. I've rejected this since it is essentially the same as shared clones, except adding additional restrictions on the branch namespace, and could potentially break existing use cases such as manually handling the SRCDEST in order to share repositories with normal working copies. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-07makepkg: add new checksum algorithm via coreutils b2sumEli Schwartz
coreutils 8.26 in December 2016 added this new hashing method which is compatible with the existing md5sum and sha*sum tool usage, while using the blake2 hash algorithm. makepkg uses coreutils to provide source file integrity checks via ${integ}sum binaries and it makes sense to offer this as an additional option. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-21libmakepkg: migrate to schema.sh for integsumsEli Schwartz
We cannot use most of the arrays defined in schema.sh as srcinfo is dependent on the order, but migrate the hashes for now. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-02-04fix various typosmorganamilo
Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-31libmakepkg: lint disallowed architecture specific variablesmorganamilo
Variables such as 'pkgdesc_x86_64' are invalid, instead of ignoring them raise an error. This also disallows using 'any' as an architecture specific variable Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-31libmakepkg: lint disallowed variables in package()morganamilo
makepkg will now error if disallowed variables are set inside of the package function. Disallowed variables are variables that do exist, like 'makedepends' and 'pkgver' but can not be set inside of a package function. Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-31libmakepkg: centralise random arrays of pkgbuild variablesmorganamilo
Refactor many of the different arrays of pkgbuild variables into scripts/libmakepkg/util/schema.sh.in. Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-30libmakepkg: Add lzip ext supportChloe Kudryavtsev
lzip is a lossless data compressor designed to replace gzip and bzip2 as the standard general-purpose compressed format. - add .lz (lzip) support to libmakepkg/util/compress.sh:compress_as - add COMPRESSLZ to makepkg.conf.in - document COMPRESSLZ - document PKGEXT with `.tar.lz` Signed-off-by: Chloe Kudryavtsev <toast@toastin.space> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22libmakepkg: move checkdepends to the correct arraymorganamilo
Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22libmakepkg: Implement extendable signature verificationEli Schwartz
Lookup the existence of matching functions for each protocol, and fallback on the generic file handler. New verification protocols can then be added via thirdparty libmakepkg drop-ins without requiring modifications to verify_signature.sh Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22libmakepkg: implement extendable source protocolsEli Schwartz
Lookup the existence of matching functions for each protocol, and fallback on the generic file handler. New source protocols can then be added via thirdparty libmakepkg drop-ins without requiring modifications to source.sh Fixes FS#49076 Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22libmakepkg: optimize get_protocol to always return proto, not proto+uriEli Schwartz
e.g. git+https:// is commonly used for git repositories cloned over HTTPS, but we assume a proto with a plus in it is actually a protocol followed by some URI handler. So we might as well simplify the return value and not have to always add glob matching everywhere when checking the proto in use. This is required in order to use the proto directly in function calls, which will be used in a followup patch. Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-22libmakepkg: make gettext replacements more templatedEli Schwartz
Making the undescore be translated is probably not something we need translators to think about. Additionally, a number of places which use the same text differ only by the variable being referenced, so simplifying the string means we can drop a redundant translation. Bonus: we save a few bytes here and there. \o/ Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-16libmakepkg: disallow using 'any' with other archesmorganamilo
Error if the arch array contains any and any other values. This also fixes a bug where the check for `$arch == 'any'` which only evaluated the first value in the array, meaning the rest of the values would not be linted. Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-14meson: fix regression that broke building libmakepkgEli Schwartz
In commit f7efa6a93d5361af610827d41045d87c7a72f2b5 we added a new file, and also wired it up to the build systems, but it got added under the wrong name in meson.build Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10libmakepkg: simplify splitting command output into arrayEli Schwartz
Use mapfile instead of hacking around read -a with the $IFS. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10libmakepkg: add routine for linting $SOURCE_DATE_EPOCHEli Schwartz
This can only ever be an int, and the specification states that a malformed timestamp should be considered a fatal error. https://reproducible-builds.org/specs/source-date-epoch/ Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10makepkg: check_pkgrel: Don't say "decimal" in the error messageLuke Shumaker
If you have a malformed pkgrel, the error message says that it must be a "decimal". That isn't quite true, as that would mean that `1.1 == 1.10`. Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10makepkg: Better error messages for versions in (check, make, ↵Luke Shumaker
opt)depends/provides/conflicts Given the depends depends=('foo>=1.2-1.par2') and the error message ==> ERROR: pkgver in depends is not allowed to contain colons, forward slashes, hyphens or whitespace. One would be lead to believe that the problem is that they gave a pkgrel in depends at all, not that the pkgrel contains letters. Each of the (check,make,opt)depends, conflicts, and provides linters use a glob to trim off properly formed epoch an rel from the full version string, and pass the remainder to check_pkgver(). This does a good job of accepting/rejecting full versions, but doesn't do a good job of generating good error messages when rejecting if it's because of the epoch or rel. 1. Factor out check_epoch() and check_pkgrel() from lint_epoch() and lint_pkgrel(), similarly to check_pkgver(). 2. Add a check_fullpkgver() that takes a full [epoch:]ver[-rel] string and splits it in to epoch/ver/rel, and calls the appropriate check_ function on each. 3. Use check_fullpkgver() in the {,check,make,opt}depends, conflicts, and provides linters. Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10libmakepkg/lint_pkgbuild: check for invalid variables even if they're emptyEli Schwartz
Checking the length of the variable to be non-zero before considering it an error is inconsistent; license=() and depends='' and `declare arch` should be considered just as wrong. In fact the current check detects depends='' as non-zero and returns an error, but happily considers the others to be perfectly okay. A more reliable check is to simply see if the name has been declared (whether it is set or not), and then enforce that it's been declared to the right type. As an added benefit, avoiding the creation of proxy-evaled variables to count the number of indexes results in simpler code. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-10makepkg: fix broken check for the fakeroot binaryEli Schwartz
In commit d8ee8d0c99c3820951e2e49dbdb71a5390bd1dc4 we made use of fakeroot absolutely mandatory, and disabled a lot of the code which checked to see if this now-defunct BUILDENV option was set, before setting up the environment to use fakeroot. Unfortunately, we missed one spot. The check_software routine still checked to see if fakeroot was enabled, but due to the option being removed, thought that it was in fact disabled, and as a result this check would never run. Fix by checking to see if we are trying to build either a package or a source package, and if so, checking for fakeroot. These are the only two situations where fakeroot is needed. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-12-12meson: remove useless mkdir -pEli Schwartz
directories are created by install_dir within the subdir custom_target installation targets. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-12-04libmakepkg/executable: don't rely on scoped value of $ret to flag outcomesEli Schwartz
Elsewhere, we return 1 if a library dropin fails, and when running functions in a loop, we use `|| ret=1` to preserve scope. This ensures the return value of the function remains useful in isolation. Do the same thing here as well. Drop trivial function which wraps a dropin that also uses $ret, since it's no longer needed. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-11-27Split prepare_buildenv() to libmakepkgQue Quotion
This opens the door for third parties to provide libmakepkg extentions for the purpose of altering the build environment. Signed-off-by: Que Quotion <quequotion@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-11-27Split check_software() to libmakepkgQue Quotion
This opens the door for third parties who provide extensions to libmakepkg to supply scripts that confirm the presence of their dependant executables. Signed-off-by: Que Quotion <quequotion@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-11-02Add meson.build files to build with mesonDave Reisner
Provide both build systems in parallel for now, to ensure that we work out all the differences between the two. Some time from now, we'll give up on autotools. Meson tends to be faster and probably easier to read/maintain. On my machine, the full meson configure+build+install takes a little under half as long as a similar autotools-based invocation. Building with meson is a two step process. First, configure the build: meson build Then, compile the project: ninja -C build There's some mild differences in functionality between meson and autotools. specifically: 1) No singular update-po target. meson only generates individual update-po targets for each textdomain (of which we have 3). To make this easier, there's a build-aux/update-po script which finds all update-po targets and runs them. 2) No 'make dist' equivalent. Just run 'git archive' to generate a suitable tarball for distribution.
2018-10-21message.sh: add modifications from output_format.shEli Schwartz
In the spirit of making libmakepkg more useful as a library, and, critically, *using* that library for additional pacman scripts, we should include all of output_format.sh and term_colors.sh directly in libmakepkg and hopefully stop having to embed additional copies in e.g. repo-add via m4 macros. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-10-21makepkg: send messages to stdout rather than stderrEli Schwartz
This behavior is confusing, since it means absolutely everything goes to stderr and makepkg itself is a quiet program that produces no expected output??? The only situation where messages should go to stderr rather than stdout, is with --geninteg which is meant to return the checksums on stdout (but we don't want to totally get rid of status messages when redirecting the results elsewhere, or, worse, redirect status messages to a PKGBUILD). For this specific case, redirect message output to stderr in the --geninteg callers directly. Implements FS#17173 Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-10-21libmakepkg: fix linting arrays of empty stringsmorganamilo
[[ ${array[@]} ]] will resolve to false if array only contains empty strings. This means that values such as "depends=('')" can be inserted into a pkgbuild and bypass the linting. This causes makepkg to successfully build the package while pacman refuses to install it because of the unmet dependency on ''. Instead check the length of the array. Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-09-19makepkg: add support for the zst formatEli Schwartz
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-09-19makepkg: lint_pkgver: Run even if PKGVERFUNCLuke Shumaker
lint_pkgver returns 0 if PKGVERFUNC, since it's likely that update_pkgver() will change the value of pkgver anyway, and there's no point in linting the old value. update_pkgver() will call check_pkgver() itself to validate the new value. However, that "optimization" only holds if we're definitely going to call update_pkgver() later; and that's way more complicated than if (( PKGVERFUNC )); then it's more like: if (( !GENINTEG && !PACKAGELIST && !PRINTSRCINFO && !SOURCEONLY && !REPKG && PKGVERFUNC )); then Which is to say: If I have a PKGBUILD with pkgver(): * if I run `makepkg -g` I expect it to lint pkgver, but it won't * if I run `makepkg -R` I expect it to lint pkgver, but it won't * ... So let's fix that. Rather than try to keep a huge list of conditions in sync with the flow of makepkg.sh.in, let's just drop it. As far as I can tell, the only thing that skipping lint_pkgver() really enables is letting the PKGBUILD author write `pkgver=` in the initial version, and letting pkgver() fill it in. They can just start writing `pkgver=0` for that workflow. Signed-off-by: Allan McRae <allan@archlinux.org>
2018-09-19makepkg: reject PKGBUILDs with both split and non-split package functionsEli Schwartz
We accept package_foo() in non-split packages, because it's easier to switch to/from a split package just by removing a pkgname element. But it makes no sense to have both in one PKGBUILD. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-09-19libmakepkg/lint_config: fix lint_variable actually running the PKGBUILD lintEli Schwartz
Due to a copy-paste error when initially implementing this, it actually uses a duplicate function name, usually resulting in lint_pkgbuild overwriting the function definition. Then the PKGBUILD lint gets run twice, one time before the PKGBUILD is even sourced -- to potentially surprising results, like erroring out on a pre-existing shell definition that doesn't match our expectations. Seen in the wild with lint_config triggering an error for 'declare -x arch="foo"' Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-08-10scripts: Remove trailing semicolonsJan Alexander Steffens (heftig)
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-08-10libmakepkg/util/option: Refactor checking to reduce code duplicationJan Alexander Steffens (heftig)
Pull out the expected=y/n check into a separate function and make use of the fact we can just prepend the fallback arrays to get the same result. Signed-off-by: Allan McRae <allan@archlinux.org>
2018-08-10libmakepkg/util: use parameter transformation when checking variable typeEli Schwartz
Now that we require bash 4.4 this is "more correct" than analyzing the output of declare -p to see if it compares favorably with -a. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-08-10makepkg: when signing packages, report package filename on failureEli Schwartz
In commit c6b04c04653ba9933fe978829148312e412a9ea7 the signing function was moved out of fakeroot, and thus out of the create_package loop. This meant that if package signing failed, it was no longer possible to tell which package it failed on by checking which package creation is currently running. Successful signing attempts do not have this problem as we already printed the name of the signature file. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-08-10libmakepkg: add pkgbase to linted variablesmorganamilo
Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-08-10Add lz4 compression support to makepkgAlex Butler
Adds opt-in lz4 compression of *pkg.tar files with makepkg. This is nice to have as an option for very fast compression and is already installed with libarchive. Signed-off-by: Alex Butler<alexheretic@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-07-27makepkg: reduce strictness of pkgver in depends lintingEli Schwartz
This change was introduced to prevent entries like depends=('foo>'). However, it had the unintended side effect of causing a number of working PKGBUILDs to fail to build. This happened when a PKGBUILD defined one variable through calling a "complex" statement within the PKGBUILD's package function (e.g. a function or evaluating in a subshell), then used it to define the package metadata variable. extract_function_variable() cannot execute the package function in order to retrieve this information, so it performs a simple grep + eval instead and in the process misses the contextual awareness of running within the package function. While not catching these "issues" can result in incorrect SRCINFO, the resulting packages are fine. Stop aborting on the common case where the pkgver of a dependency is dynamically set during the package function until the large number of broken PKGBUILDs are fixed, and the restrictions of the PKGBUILD format are documented. "Fixes" FS#58776 Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-07-19libmakepkg: remove accidentally added fileAllan McRae
A blank file slipped into libmakepkg in commit 2c94118d. Signed-off-by: Allan McRae <allan@archlinux.org>
2018-07-19libmakepkg/tidy: fix debug sources not being properly detected sometimesEli Schwartz
DW_AT_comp_dir is meant to contain the directory in which the compiler was run DW_AT_name contains the source file the compiler was told to use. In the event that DW_AT_name is an absolute path, it is (obviously) not meant to be computed relative to DW_AT_comp_dir. However, we did not handle this correctly, and as a result tried to copy source files using doubled-up filepaths. The correct approach should be to use DW_AT_name on its own, in the event that it is an absolute path. See http://wiki.dwarfstd.org/index.php?title=Best_Practices. This fixes debug package generation for many packages that use absolute paths in their build systems... like CMake. Reported-by: Jagannathan Tiruvallur Eachambadi <jagannathante@gmail.com> Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-06-18makepkg: don't print per-pkgname debug packagesEli Schwartz
In commit 9a4d61622066d5d30c649f1c958b26526a4ceddf debug packages were merged into one exclusive pkgbase-debug, but the print_all_package_names function did not get updated to match this logic. Signed-off-by: Allan McRae <allan@archlinux.org>
2018-06-18Fix signing of debug packagesAllan McRae
Commit 9c8d7a80 broke the signing of debug packages by merging code up but not changing the test condition. Signed-off-by: Allan McRae <allan@archlinux.org>
2018-06-18makepkg: fix initialization when extracting arraysDave Reisner
Assuming that everything is a string leads to code which is effectively: a= a+=('bar') This creates an array with 2 elements instead of one. Using proper array initialization fixes this. https://lists.archlinux.org/pipermail/pacman-dev/2018-June/022591.html Signed-off-by: Allan McRae <allan@archlinux.org>
2018-06-18Add missing sha224 sums in man page and lintingmorganamilo
Signed-off-by: morganamilo <morganamilo@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-06-18libmakepkg/lint_pkgbuild: squelch syntax error when a pkgname is emptyEli Schwartz
We fail with an error, but then we also fail with: ==> ERROR: depends is not allowed to be empty. /usr/share/makepkg/lint_pkgbuild/pkgname.sh: line 39: continue: only meaningful in a `for', `while', or `until' loop During the refactor to provide enhanced pkgname=pkgver linting, this was moved out of the ${pkgname[@]} loop to a distinct function, at which time it should have been modified to return rather than continue. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>