Commit Graph

50 Commits

Author SHA1 Message Date
Martchus 401609212e Log systemd-nspawn invocation parameters
When debugging it is useful to know what parameters where
used.
2021-07-20 18:26:04 +02:00
Martchus 78de2a3759 Adjust systemd-nspawn flags
* Remove --keep-unit since it causes sometimes errors and does not seem
  to be required
* Increase maximum number of open files (the default of 1000 is too less
  for some packages)
* Use /etc/resolv.conf from host (otherwise systemd-nspawn uses a config
  which does not work on my host setup)
2021-02-20 18:37:38 +01:00
Kevin Mihelich d508ffe8a4 arch-nspawn: arm fix 2021-02-20 18:37:38 +01:00
Kevin Mihelich f8f0140220 arch-nspawn: keep mirrorlist 2021-02-20 18:37:38 +01:00
Eli Schwartz 94b0413e13
arch-nspawn: fix up host_mirrors cachedir handling
This was incorrectly implemented in commit
0067176529, which added the host_mirrors
root directory as a cachedir, when we actually want to use the pool/*
subdirectories (the same ones installed on the build server's
/etc/pacman.conf).

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2020-02-27 14:50:27 +01:00
Eli Schwartz f85a58a0a6
arch-nspawn: rely on deduplication to avoid making multiple host_mirror mounts
Instead of comparing exact mirror urls to see if they are in
host_mirrors in order to "skip" the official mirrors

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-11-30 13:21:23 +01:00
Eli Schwartz f43a86ee8a
arch-nspawn: simplify cachedir/host_mirror parsing
consolidate logic flows in the same area for parsing and building
arrays. Don't bother having a special function just to build the
mount_args array, since we now use the same handling for adding any
cachedir (including host mirrors) to the mount arguments, this becomes a
trivial for loop -- and it really did not need to be delayed until after
the sanity check, anyway.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-11-07 21:28:20 +01:00
Eli Schwartz 0067176529
arch-nspawn: restore cachedir handling for host_mirrors
In commit 27ff286ee7, we moved from
sourcing the primary cachedir via /etc/pacman.conf, to using the
pacman.conf in the workdir. One unanticipated side effect of this was
breaking the special host mirrors magic we used to turn a host mirror
into a cachedir. It was still processed as a server, but we relied on it
being in the host's cachedirs in order to be persisted, and this no
longer occurred.

Solve this by explicitly adding each host mirror root as a cachedir.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-11-07 21:28:19 +01: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 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
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 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
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
Eli Schwartz 5b3c14454a Proper fix for pacman-git returning file urls from the cache
It is much nicer to use a proper configuration parser to retrieve the
primary mirror, rather than clever hacks using undocumented APIs,
especially when their behavior as used then breaks in later releases.

Fortunately, pacutils exists now and pacconf handles this quite
elegantly. It has since been moved to pacman-git proper.

Check if pacman-conf from a new enough version of pacman exists and
fallback on pacconf from pacutils.
2018-05-13 09:16:20 -04:00
Eli Schwartz 4408bb2a15 Revert "arch-nspawn: Work around pacman master returning file-URLs from the cache"
This reverts commit eb6b0e3f11.

This never worked, as pacman-git returns file urls from the cache anyway
and pacman stable doesn't have any problem at all. Having useless code
which makes people think the issue is solved when it really isn't, is
bloat, so remove it.
2018-05-13 09:16:20 -04:00
Luke Shumaker 5ab8f8430a arch-nspawn: Remove pointless $(echo ...) subshell 2018-01-21 14:16:10 +01:00
Luke Shumaker c9e287e845 arch-nspawn: make sure that makepkg.conf is always parsed as text
https://lists.parabola.nu/pipermail/dev/2017-June/005576.html
2018-01-21 14:16:10 +01:00
Jan Alexander Steffens (heftig) 6b55282bd7
Revert "arch-nspawn: Hack to give the inner process a controlling terminal"
Whoops, this will of course mess with nspawn arguments passed to
arch-nspawn.
2017-09-13 00:25:06 +02:00
Jan Alexander Steffens (heftig) 6a7dcdeff9
arch-nspawn: Hack to give the inner process a controlling terminal
This was lost at some point.
2017-09-13 00:17:49 +02:00
Jan Alexander Steffens (heftig) cd500d161f
arch-nspawn: Pass --as-pid2
As not all commands we run are capable of reaping processes correctly.
For example, pacman is not.
2017-09-12 23:27:07 +02:00
Sébastien Luttringer fecf107c37 arch-nspawn: Force PATH to be the Arch default
systemd-nspawn use a default environ PATH value of:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Since filesystem 2017.08, this is no more overrided by /etc/profile
to the Arch default:
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
2017-09-11 21:21:51 +02:00
Jan Alexander Steffens (heftig) 000ea6c7bb
arch-nspawn: Add --keep-unit to prevent scope conflicts 2017-08-24 17:03:32 +02:00
Luke Shumaker a9dab95334
Add `# shellcheck` directives to quiet shellcheck, add PKGBUILD.proto
The added PKGBUILD.proto file is so that shellcheck can know know what
to expect that a PKGBUILD sets.
2017-07-05 18:21:56 +02:00
Luke Shumaker 78fabcfa06
Quote strings that shellcheck warns about.
These changes are all strictly "slap some double-quotes in there".
Anything more than that is not included in this commit.
2017-07-05 18:21:56 +02:00
Luke Shumaker 3f72579b28
Make purely stylistic changes to make shellcheck happier.
These are purely stylistic changes that make shellcheck complain less.

This does NOT include things like quoting currently unquoted variables.
2017-07-05 18:21:55 +02:00
Luke Shumaker 5b9c06d275
mkarchroot, arch-nspawn: Add an `-s` flag to inhibit `setarch`.
This allows us to run an ARM chroot on an x86 box; as the binfmt
runner will set the architecture for us, and the x86
`/usr/bin/setarch` program won't know about the ARM architecture
string.
2017-04-05 22:17:51 +02:00
Luke Shumaker 82e6bfcd7a
mkarchroot, arch-nspawn: Add an `-f` flag to add files to copy.
This allows us to copy in files like `qemu-arm-static`, which is
necessary for running an ARM chroot on an x86 box.
2017-04-05 22:17:51 +02:00
Luke Shumaker cb35d74f8c
Avoid using string interpolation; use printf format strings instead.
This involves extending the signature of lib/common.sh's `stat_busy()`,
`lock()`, and `slock()`. The `mesg=$1; shift` in stat_busy even suggests
that this is what was originally intended from it.
2017-04-05 22:11:16 +02:00
Luke Shumaker 14d5e1c21b
Add a "License:" tag to all code files.
In cases where there is no license specified, the file is tagged as
"License: Unspecified".  Obviously, that is not ideal, but it
highlights the fact, and I hope that it encourages whoever has the
authority to specify the license to do so.

On that note, to anyone who may have the authority to specify the
license of files in devtools: the current licence of many files is
GPLv2 with no option for later versions; I impore you to re-license
them to have the "or any later version" option.
2017-04-05 22:10:03 +02:00
Jan Alexander Steffens (heftig) 45f87aa9d5
lib/archroot.sh: Simplify check_root
Move the function and save the orig_argv right along it.
2017-03-07 19:35:09 +01:00
Jan Alexander Steffens (heftig) 66553e7e07
lib/archroot.sh: Move CHROOT_VERSION to a common file 2017-03-07 19:35:09 +01:00
Jan Alexander Steffens (heftig) c8147a3512
mkarchroot: Set LANG=en_US.UTF-8
In order to have an UTF-8 locale in the build root. This is something
normally set on real machines but is not set from our chroots. Meson,
for example, loudly complains when the locale charset is not UTF-8.

I'd like to have C.UTF-8, as most other distributions do. Unfortunately,
it's not part of vanilla glibc; en_US.UTF-8 will have to do.

mkarchroot already creates roots with both en_US.UTF-8 and de_DE.UTF-8,
the latter because builds of gcc (perhaps used to) require it.

Bump the CHROOT_VERSION due to the setting change.
2017-02-17 19:51:56 +01:00
Jan Alexander Steffens (heftig) eb6b0e3f11 arch-nspawn: Work around pacman master returning file-URLs from the cache 2016-05-28 12:33:00 +02:00
Evangelos Foutras 5a7890f076 arch-nspawn: preserve systemd-nspawn's stderr
It is passed down to the container when stdin/stdout is not a tty; this
is the case when archbuild's output is redirected to a pipe or file.
2015-11-29 12:01:34 +02:00
Dave Reisner bf7dc83bab save and reuse original argv when auto-elevating
Fixes FS#42277.
2014-10-19 16:48:03 -04:00
Luke Shumaker 651f8f834f arch-nspawn: Fix a grammar mistake (a/an) in an error message. 2014-09-22 08:25:43 -04:00
Dave Reisner d83805bc54 nspawn: skip machine registration
No need to do this since we don't run an init system in the build root.
2014-09-22 08:25:43 -04:00
Sébastien Luttringer 03611dc63e Switch to root when started as regular user
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-10 08:05:08 +02:00
Dave Reisner 7267664ed8 arch-nspawn: allow oddly named directories
This fixes various errors one might encounter when trying to use a
build root or cachedir with whitespace in it.

Note that the cachedir fix is not a complete one, as pacman's output is
unreliable (and not meant for parsing here).

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-08-18 18:17:05 +02:00
Dave Reisner e0f7c21a68 arch-nspawn: avoid escaping mount_args
eval is no longer involved in the execution of systemd-nspawn, so we no
longer need a layer of escaping on the arguments.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-08-18 18:16:59 +02:00
Dave Reisner be3c71fa81 avoid injecting code into the format string
Now that die() properly forwards arguments to error(), we can expect
that the first arg is a format string and not the entirety of the
output.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-08-08 21:28:10 +02:00
Florian Pritz 29e62278a7 arch-nspawn: remove leading - from the machine name/hostname
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-08-08 21:24:55 +02:00
Jan Alexander Steffens (heftig) a5bc6acf32 arch-nspawn: Quiet systemd-nspawn again
systemd-nspawn always outputs some debug messages over stderr.
Both stdout and stderr from inside the chroot are sent through
a pty to stdout.
2013-05-11 12:26:20 +02:00
Jan Alexander Steffens (heftig) 1489f75419 arch-nspawn: setarch to CARCH
Allows calling makechrootpkg without worrying about the architecture
2013-05-06 01:50:05 +02:00
Jan Alexander Steffens (heftig) 0e98bd8c48 arch-nspawn: Set machine name
Recent changes to systemd-nspawn have it take the machine name from
the chroot dir name, which isn't unique enough for our setup.
2013-05-03 04:34:29 +02:00
Jan Alexander Steffens (heftig) 453558c4bb mkarchroot: Refactor chroot running into a new script
Separates the two features of mkarchroot. Provides users of the new
arch-nspawn with the full feature set of systemd-nspawn.

For example, this can be used to bind custom directories into the chroot.
2013-05-02 10:33:24 +02:00