Commit Graph

792 Commits

Author SHA1 Message Date
Eli Schwartz 93dbb14ab9
archrelease: actually fail in failure conditions
When svn ls fails due to network timeouts, this currently results in
archrelease deleting all files, then committing this as the changeset.
This causes data loss...

With bash 4.4 and using wait $! we can get return the return code of the
last backgrounded command -- which process substitution qualifies as.
Key off of this to make sure that `svn ls` actually succeeded.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz 10c6efc440
archbuild: prefer repo/arch-specific configs if they exist
When mixing and matching different repos and architectures not present
in mainline archlinux, it is sometimes desirable to set up differing
presets with more granularity than devtools currently allows.

One example of this is when building for architectures that are only
supported by another project -- in order to coexist on a mainline
archlinux host, a different mirrorlist needs to be used.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz 8e4293034b
makechrootpkg: also downgrade packages when updating chroots
Packages should never be getting downgraded... unless a package is
pulled from testing, e.g. for example if gcc9 totally breaks the linux
kernel. In such cases, the master repo says there is a downgrade, so
we'd better go with that. Basically, ensure that packages match the repo
they are being built against. Consistency at all costs!

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz b7893a2ca8
makechrootpkg: when installing with -I, ensure package is installed
noconfirm is wrong here, as we don't want to accept the default answer
-- we want to install the new package, even if it conflicts and provides
an existing one. After all, we explicitly asked for it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz bec29e632b
arch-nspawn: unshare the gpg namespace to prevent zombie processes
gpg-agent is really annoying and leaves useless copies of itself around.
Using unshare ensures that all such processes are killed as soon as the
main gpg process dies.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz 70f3b8ddb8
finddeps: suppress error messages for unreadable directories
If the find command cannot descend into a directory in order to search
for a PKGBUILD, it is likely a "$pkgdir" which makepkg sets as
unreadable. As far as finddeps is concerned, this error message is not
needed.

Also convert to using null-delimited paths on general principle to
prevent read from splitting on odd paths.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz 5fcd90a212
makechrootpkg: accept arguments useful to verifysource
And pass them on to download_sources outside the chroot.

Fixes FS#35652

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz f6f4da26cb
makechrootpkg: fix breakage in makepkg option parsing
In commit bd826752c9, support for short
options was added to the heuristic for --noextract, but in the process,
we changed to loop over the set of user options plus the builtin
defaults for inside the chroot. This was wrong, as we only care about
the user options -- moreover, it prevents us from adding verifysource
support *outside* the chroot, for options that are also chroot options,
like --holdver.

Also remove uselessly duplicated line.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz 40a90e2cab
ensure that sane umask is used where needed
If a user umask is restrictive, a chroot may be created as root without the
ability for the user to read it, which then causes makepkg
--verifysource to fail.

Do not set this in lib/common.sh, where it would apply to all scripts,
as we do not want to override the user's policy for things like $SRCDEST
files, svn checkouts, etc.

Fixes FS#47625

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz 74a6641946
Escape paths with ":" that are passed to systemd-nspawn --bind
When parsing paths to automatically make available to the container, the
":" is used internally by systemd-nspawn to signify destinations in the
container. Replace automatically with "\:" for the mounts that we set
up, in order to safely handle a working directory etc. that contains
this character.

For bind options exposed to the user, it is assumed the user takes care
of passing systemd-nspawn compatible paths themselves.

Fixes FS#60845

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz 69112171e5
arch-nspawn: support bind-mounting custom file:/// repositories
Fixes FS#45882

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz c14338c0fe
checkpkg: implement comparison against alternative targets
This allows comparing the currently built set of packages against
targets named by filename, url, or pkgname. One example use is to
compare a package against a different version that was never in the
repos; another example use is to compare a *-git package against the
non-git version.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz 8dbf95cdd4
makechrootpkg: check truthiness using shell arithmetic
Using the literal strings "true" and "false" is inaccurate and may
result in uncertainty of whether it is set when doing string comparison,
or simply rely on the shell implementation of treating the string as a
command builtin, then executing the value as a shell command. Emulate
makepkg, which makes heavy use of shell arithmetic for this purpose.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz 46d614d91a
Revert "makechrootpkg: Have functions be more function-y."
This reverts (the bulk of) commit 2fd5931a8c.

Reducing globals makes little sense in in a oneshot bash script, but
reduces code clarity and in fact resulted in bugs because even the
commit author couldn't keep track of the script state.

An exit was changed to a return, even though that made no sense outside
of a function, and has been duly returned to being an exit. This was
never tested and later papered over by wrapping the entire script in a
main() function and then calling the function for hysterical raisins.

The functiony nature of sync_chroot/delete_chroot is preserved, as those
functions demonstrate meaningfully standalone functionality -- who
knows? we may want to reuse this. Everything else is tightly bound to
the internal logic of makechrootpkg.

Completely separate functionality that was silently implemented in the
original commit is also preserved:
- declare a couple of variables as locals
- move the abort-on-no-PKGBUILD outside the install_packages function

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz df0d6b867b
Revert "makechrootpkg: Avoid having code floating around outside of a function."
This reverts commit 49088b0860.

The fundamental intention was flawed and broken, it caused annoying
issues and regressions, and the self-avowed sole purpose of the change
was so that a downstream project could *post-modify the script and
source it as a library*.

That is not okay. You don't wrap non-factorable code in a function
called main() and call it a library. The only possible use for this is
to treat makechrootpkg *internals* as a library, which is not supported.

Downstream projects that wish to use the functionality of makechrootpkg
should treat makepkg as a command with a public API in the form of
command line options. That is kind of how commands of all kinds work,
since forever. That is how all users of makechrootpkg *except for
parabola* use it.

Arguments that "it saves us the cost of fork+exec to bash" are simply
invalid.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz 8f5a02b23d
Don't rely on $0 to determine script names.
Programs can freely define the value of argv0 and thus it means nothing.
Instead, use the bash-specific variable explicitly designed to safely
and accurately reference the name of the currently sourced file.

This also fixes the case where simple debugging mechanisms like using
"bash -x foo" tried to treat "foo" as the unqualified $0 and therefore
broke horribly due to lack of pathnames.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz e76d560477
Revert "mkarchroot: Don't let the environment affect pacstrap (sans proxy settings)."
This reverts commit 578a62f1e0.

mkarchroot is run as root (via check_root if needed) so the environment
should already be clean. If not, the user has broken their root
environment, and we cannot support this. It's unclear what environment
settings may or may not be messing with anything, ever, but the original
bug report happened on Parabola who perform extensive patching to
"libretools" such that the code no longer resembles devtools at all.
It's therefore likely any such bug is parabola specific, but we will
never know since the original commit message states that they don't know
why they do it either.

Parsing the user's entire exported environment via both sed and grep is
overkill for a non-bug, especially when it doesn't work for variables
declared -rx and doesn't work for things like:

export fooled_you=$'wow such hax\ndeclare -x http_proxy=lol'

Also if done properly this would rely on compgen -e to print all
exported shell variables. Or even better, loop through /proc/$$/environ
which is both null-delimited and easily parsed with the read builtin and
[[ ]]

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Brian Bidulock 27ff286ee7
arch-nspawn should not take pacman cache from host
Previously, arch-nspawn was using the hosts' pacman cache in
the chroot even when the chroot was set up with a different
cache by mkarchroot, unless specified with the -c flag.
Problem is that makechrootpkg passes no -C, -M nor -c flags
to arch-nspawn, so all values must be obtained from the
working directory.

This change take the cache directories from the pacman.conf
specified with the -C option unless the -c option was given
(as is the case when the chroot is set up with mkarchroot),
and, when neither -C nor -c is given (as is the case when
invoked by makechrootpkg), the cache directory is taken
from the pacman.conf in the working directory.

This wasn't such an issue when i686 was mainline, however,
which building packages in a chroot against archlinux32 on
an x86_64 platform, the cache of the host should _never_ be
used.

Rebased by eschwartz on top of cachedir reworking.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz 2180aabc81
arch-nspawn: don't delete the guest gpg configuration
It's important to ensure the guest has up to date data because updating
a chroot after quite some time can potentially rely on updated
archlinux-keyring, something which the host machine either kept up to
date on or manually fixed, but it kills automation to mess around with
chroot configs like that. Alternatively, signed packages added with -I
need to work, and we assume the host is configured to accept these.

That is *not* a good reason to completely nuke whatever is in the guest,
though. A guest might have been manually configured to accept keys which
aren't accepted by the host; one example of this happening in practice,
is archlinux32 when building 32-bit packages from an archlinux host.

The right solution is to append to, rather thna overwrite, the chrooted
guest's pacman keyring.

To do this, we will use gpg's native facility to dump the keyring from
one GNUPGHOME and import it into another. We'd use pacman-key's --import
option directly, but this doesn't support passing custom options like
--import-options import-local-sigs
Finally use pacman-key's native facility to import the trust status from
the host.

While we are at it, fix a bug where we didn't respect the host's
pacman.conf settings for the GpgDir. While it isn't wildly likely a user
will choose to customize this, it is a valid and supported use case and
we must think about this ourselves.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz 2f929c961f
fixup commit "arch-nspawn: get all mirrors from host"
In commit d9b7350448, a line was deleted
that had a shellcheck ignore marker, but the marker itself was left in
(and had nothing to do). So, remove it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz c2bbcbed64
mkarchroot: don't create a broken chroot by default
It's incorrect to make pacman completely useless inside the chroot by
starting off with no pacman keyring. Assuming that the only consumers of
a new chroot will be arch-nspawn (which copies over the hostconf) is
bad design, and furthermore makes it impossible to fix other issues in
arch-nspawn itself.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz b7ce90fefc
makechrootpkg: load makepkg.conf variables correctly
Since makepkg.conf is a bash-compatible configuration file, it must be
sourced.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz f52002955c
Makefile: don't inject DESTDIR into the pkgdatadir
In commit 46c4def073, we added support for
nonstandard PREFIX installations, but DESTDIR was and is never supposed
to be a part of that. While DESTDIR isn't terribly likely to be used
during `make all` invocations, that's no reason to break horribly if it
is used for some reason.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz 58374246c4
Migrate pacman.conf CacheDir parsing to pacman-conf
And while we're at it, make this more consistent. Currently we
unnecessarily support only one -c /path/to/cachedir option.

This requires slightly more thorough handling in mkarchroot to ensure
all custom cachedirs are passed on to arch-nspawn. Rework
to simply forward all arguments to arch-nspawn (minus final arguments
used for pacman -Sy packagelist).

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:39:45 +02:00
Levente Polyak f522ce2277
offload-build: disable shellcheck false-positive for shell-escape 2019-06-13 00:17:11 +02:00
Eli Schwartz via arch-projects 7747749610
doc: add manpage for the new offload-build tool
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-06-12 23:42:10 +02:00
Eli Schwartz via arch-projects 25b4ef2799
Add new tool: offload-build
This tool is useful for running makechrootpkg on a remote build server,
and is by default hooked up to send a PKGBUILD and initiate a build on
our shiny new build server "dragon".

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-06-12 23:42:10 +02:00
Eli Schwartz via arch-projects ad4b66830a
Revert "makechrootpkg: sync_chroot: Make more general."
This reverts commit 6d1992909c.

It has never worked. In commit c86823a2d4
it was noted that it compared the device numbers for [[ $1 = $1 ]] which
was a useless check and always returned true, for *any* btrfs
filesystem. Now that the function is corrected to compare [[ $1 = $2 ]]
the check is still useless, but this time because it always returns
false -- btrfs subvolumes on the same filesystem do *not* share device
numbers.

So let's go back to the original working implementation that only
matters in terms of makechrootpkg, and just checks if makechrootpkg's
root working directory is btrfs (in which case we know it will be a
subvolume because mkarchroot will create it that way).

This restores our special support for the btrfs filesystem.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-06-12 23:42:05 +02:00
Erich Eckner 321e998020
fix whitespace/indentation errors
Some lines are indented by spaces, while adjacent lines are indentet by tabs.
We should use tabs on both.

Signed-off-by: Erich Eckner <git@eckner.net>
2019-04-20 17:58:55 +02:00
Erich Eckner c86823a2d4
is_same_fs() in lib/archroot.sh should use $1 and $2, not $1 and $1
The old behaviour would always evaluate to true - this is certainly not
what that function should do.

Signed-off-by: Erich Eckner <git@eckner.net>
2019-04-20 17:55:31 +02:00
Levente Polyak a49f55cbed
Version 20190329 2019-03-29 21:40:28 +01:00
Levente Polyak 5c016c38f2
readme: fix faulty whitespace in release commands 2019-03-29 21:40:28 +01:00
Levente Polyak 1d4a60874b
make: fix faulty install targets
This fixes a regression introduced in eeb1c0e59e
2019-03-29 21:40:28 +01:00
Eli Schwartz via arch-projects b66ce081e7
fix up sogrep manpage to correspond with current sogrep command
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-03-28 21:17:55 +01:00
Eli Schwartz via arch-projects 1ab9b34c4c
add sogrep command
This is the new and improved, canonical sogrep command, now with a valid
license.

The previous version of sogrep had several issues and inefficiencies,
and ultimately wasn't really the finished project I wanted it to be. Due
to a mistake in communication, I was totally unaware it was in the
process of being merged at all, nor that there was a licensing issue, or
I would have recommended waiting for both further improvements, and a
declaration of license intent; nevertheless, here it is now, and I
formally give this over into the GPLv2+ domain.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-03-28 21:17:55 +01:00
Eli Schwartz via arch-projects ebba5a5885
sogrep: don't be templated when it is not templated
Partition the Makefile targets to only clean configured files, and make
the configured files be a subset of the bin programs.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-03-28 21:17:50 +01:00
Jelle van der Waa c9b6f58f8e
Create a general README
Introduce a README which describes where to send patches and how to
release a new version of devtools.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-25 23:32:16 +01:00
Matt Robinson 155798b8b1
makechrootpkg: keep *DEST, MAKEFLAGS & PACKAGER
If makechrootpkg is called as non-root, the {SRC,SRCPKG,PKG,LOG}DEST,
MAKEFLAGS and PACKAGER environment variables are lost in the call to
check_root().

Add these to the passed keepenv list so that they are preserved instead.
2019-03-25 23:32:13 +01:00
Christian Hesse d9b7350448
arch-nspawn: get all mirrors from host
Now that pacconf gives us all mirrors we can use them, instead of just
the first one.

Signed-off-by: Christian Hesse <mail@eworm.de>
2019-03-25 23:32:04 +01:00
Jelle van der Waa 6645701cb1 sogrep: remove duplicate sogrep
The rename of sogrep to sogrep.in failed to remove sogrep and adding it
to .gitignore.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
2019-03-17 14:51:19 +01:00
Jelle van der Waa 657497c91a doc: Add myself as maintainer
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:35:21 +01:00
Jelle van der Waa 90bb423304 sogrep: rename to sogrep.in so make clean works
make clean removes all .in converted files to a file without .in which
in the make clean step is removed. So running make clean will remove
sogrep since it's specified as BINPROGS. In the future this steps should
be removed for sogrep since it is a standalone script.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:29:56 +01:00
Jelle van der Waa 23f248ccfb find-libdeps: fix indentation in case
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:27:13 +01:00
Jelle van der Waa eeb1c0e59e doc: add man pages for find-{libdeps,libprovides}
Add a simple man page for find-libdeps and find-libprovides.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:25:55 +01:00
Jelle van der Waa 936ff8da2f doc: add Environment variables section to sogrep
Add a section about environment variables which influence sogrep's
behaviour.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-13 22:17:35 +01:00
Jelle van der Waa d123fee8ec doc: add man page for mkarchroot 2019-03-13 22:13:51 +01:00
Jelle van der Waa 4a532e38e7 crossrepomove: do not set svn propset
svn propset's where determined to be non-reproducible and therefore
where removed from svn. Don't introduce them when moving packages
between repos.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-13 22:06:00 +01:00
Sven-Hendrik Haase f61421a3f5 Add sogrep
This is from Eli's dotfiles after he'd cleaned it up but never actually went ahead and made this PR.
I figure it's time to add it.
2019-03-13 09:16:32 +01:00
Jelle van der Waa 26b2ffc665 remove arch rm as it's not really useful
archrm is a not much more fancy rm -rf and therefore not really useful
to ship.
2019-02-24 13:37:37 +01:00
Levente Polyak 62306018f2
conf: sync makepkg.conf with latest version from pacman package 2019-02-09 14:27:31 +01:00