summaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2017-04-05lib/common.sh: lock, slock: Create directories for locks if necessary.Luke Shumaker1-0/+2
2017-04-05lib/common.sh: lock, slock: Allow locks to be inherited.Luke Shumaker1-2/+10
Allow for locks to be inherited. Inheriting the lock is something that mkarchroot could do previously, but has since lost the ability to do. This allows for the programs to be more compos-able. Do this by instead of unconditionally opening $file on $fd, first check if $file is already open on $fd; and go ahead use it if it is. The naive way of doing this would be to `$(readlink /dev/fd/$fd)` and compare that to `$file`. However, if `$file` is itself a symlink; or there is a symlink somewhere in the path to `$file`, then this could easily fail. Instead, check `[[ "/dev/fd/$fd" -ef "$file" ]]`. Even though the Bash documentation (`help test`) says that `-ef` checks for if the two files are hard links to eachother, because it uses stat(3) (which resolves symlinks) to do this check, it also works with the /dev/fd/ soft links.
2017-04-05lib/common.sh: add 'lock_close'; use it as appropriate.Luke Shumaker1-0/+8
`lock_close FD` is easier to remember than 'exec FD>&-`; and is especially easier if FD is a variable (though that isn't actually taken advantage of here). This uses Bash 4.1+ `exec {var}>&-`, rather than the clunkier `eval exec "$var>&-"` that was necessary in older versions of Bash. Thanks to Dave Reisner for pointing this new bit of syntax out to me the last time I submitted this (back in 2014, 4.1 had just come out).
2017-03-07archbuild/makechrootpkg: Delete subvolumes in rootsJan Alexander Steffens (heftig)1-0/+20
The systemd package creates a subvolume at /var/lib/machines (through tmpfiles), if it can. We need to delete this subvolume before we can delete the parent subvolume. Look through the root for inodes with the number 256. These identify subvolume roots.
2017-03-07lib/archroot.sh: Add is_btrfs helperJan Alexander Steffens (heftig)1-0/+8
2017-03-07lib/archroot.sh: Simplify check_rootJan Alexander Steffens (heftig)2-12/+13
Move the function and save the orig_argv right along it.
2017-03-07lib/archroot.sh: Move CHROOT_VERSION to a common fileJan Alexander Steffens (heftig)1-0/+1
2017-03-04lib: remove unused version, pkgpartsJelle van der Waa1-1/+1
2017-03-04lib: remove unused left, rightJelle van der Waa1-2/+0
2014-09-22common: remove unreachable statementDave Reisner1-2/+1
We run from a non-interactive shell, so the exec which is inevitably called will replace the current process and 'die' will never run under any circumstances. This also fixes a bug with the su fallback which would cause multiple arguments to be concatenated without any whitespace between them.
2014-09-22common.sh: propagate error through trap_exitDave Reisner1-1/+2
Fixes a breakage introduced in 6db31cc16a80442 which leads to errors being masked from makechrootpkg.
2014-05-10Switch to root when started as regular userSébastien Luttringer1-0/+13
In collaborative builder machine, these scripts are often allowed to become root via sudo. This patch avoid to prefix them by sudo each time or call su. Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2014-05-10get_full_version :: remove duplicated epoch checkBlackEagle1-1/+1
Signed-off-by: BlackEagle <ike.devolder@gmail.com> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2014-05-10when cleanup is called without code exit with 0BlackEagle1-1/+1
Signed-off-by: BlackEagle <ike.devolder@gmail.com> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2014-05-10abort and die are serious errors so throw 255 outBlackEagle1-3/+3
Signed-off-by: BlackEagle <ike.devolder@gmail.com> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-11-04find_cached_package: avoid adding duplicatesDave Reisner1-2/+7
If PKGDEST is set when makepkg was run, the package will be present in find_cached_package's search path by default, causing an error. This also fixes a display bug which causes no output to be shown when multiple packages are found. Fixes FS#37626. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-11-01common: implement find_cached_packageDave Reisner1-0/+69
This function (currently) searches through $PWD and $PKGDEST looking for a tarball matching the requested package name, architecture, and pkgver. If found, it writes the full path to the located package to stdout and returns 0, else 1. If more than 1 match is found, it's treated as an error and the user will need to figure out what to do. Use this in checkpkg and commitpkg, which previously implemented their own less complete logic, to locate the build artifacts they rely on. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-08-08common: Properly forward arguments from die to errorDave Reisner1-1/+1
Also allow this function to be called without arguments, in which case, don't call error at all. Some uses of this function wrongly assumed that this was already allowed. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-05-03lib/common.sh: Introduce locking helper functionsJan Alexander Steffens (heftig)1-0/+24
Reduces code duplication. With makechrootpkg not calling mkarchroot anymore, the lock handover protocol is unneeded. arch-nspawn does not do any locking, so add protection to archbuild.
2012-10-27Fix return code handlingJan Alexander Steffens (heftig)1-1/+1
Stop trap_exit from forcing a 0 exit code. This fixes makechrootpkg, which used to always return success, even if the build failed. Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-10-03Use dedicated trap functions to avoid unsetting the trap when e.g. cleanup ↵Pierre Schmitz1-4/+12
is called
2012-06-16mkarchroot: reset trap so it wont be called twicePierre Schmitz1-1/+1
2012-02-12archrelease: Validate tags before releasingLukas Fleischer1-0/+20
Compare every single tag with a list of valid tags. This prevents broken releases which occurred whenever someone made a typo on the command line: $ ./archrelease community i686 ==> ERROR: archrelease: Invalid tag: "community" (use -f to force release) Since the list is used in the ZSH completion as well, break it out to a separate file and move it to "lib/". Also, add a command line parameter to allow for releasing to an unknown repository when necessary. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2011-11-04lib/common.sh: Revise setup_workdir()Lukas Fleischer1-1/+1
* Honor TMPDIR variable (just like we did in commit a0c6bf45). * Quote path properly. * Avoid unnecessary use of basename(1). Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2011-11-04lib/common.sh: Use double bracketsLukas Fleischer1-3/+3
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2011-11-01Move common functions to a shared filePierre Schmitz1-0/+124
* common.sh is included on build time * most functions are copied from makepkg