Commit Graph

229 Commits

Author SHA1 Message Date
Mike Yuan
05d231aff9
pacstrap: respect custom pacman.conf configs
If some core settings are changed in custom pacman.conf,
they won't be prepended with new rootdir automatically.
2023-03-03 19:27:04 +08:00
Mike Yuan
c21e56e88e
common: add check_root 2023-03-03 19:27:04 +08:00
Mike Yuan
e13ce65908
common: check is_pseudofs or has_fsck more reliably
There might be filesystems we can't cover in common,
e.g. out-of-tree ones. Use findmnt / check if the
fsck command exists to make it more reliable.
2023-03-03 19:27:03 +08:00
Mike Yuan
092226862b
genfstab: re-implement write_source 2023-03-03 19:27:03 +08:00
Mike Yuan
4be53d3488
common: several cleanup for *_setup
Use errexit instead of having to add '&&'
for every single mount.
2023-03-03 19:27:03 +08:00
Mike Yuan
e3f9cb6498
arch-chroot: move resolve_link and chroot_add_resolv_link to common
chroot_add_resolve_link is cleaned up to be simpler.
(We shouldn't need the complex symlink handling logic for target)
2023-03-03 19:27:03 +08:00
Mike Yuan
33cf482649
tree-wide: fix shellcheck warnings and style consistency 2023-03-03 19:27:03 +08:00
Morten Linderud
560c00c9c2
Merge remote-tracking branch 'origin/pull/37'
* origin/pull/37:
  Add shellcheck GitLab CI
  Add Differential ShellCheck GitHub Workflow
2023-03-02 21:03:24 +01:00
Morten Linderud
2d1d4904b9
Merge commit 'refs/pull/42/head' of github.com:archlinux/arch-install-scripts
* github.com:archlinux/arch-install-scripts:
  common: avoid variable name conflict with genfstab
2023-01-25 13:47:01 +01:00
Mike Yuan
4a83825a9d
common: avoid variable name conflict with genfstab 2023-01-21 22:58:25 +08:00
Mike Yuan
326153e211
Add shellcheck GitLab CI 2022-11-24 03:17:22 +08:00
Mike Yuan
f98c5d8268
Add Differential ShellCheck GitHub Workflow
It would run on pull requests only, so please avoid
pushing to master branch directly.
2022-11-24 02:08:19 +08:00
Morten Linderud
4802e1197e
Merge branch 'pr-36' 2022-11-20 14:59:40 +01:00
Morten Linderud
4457e31ee3
Merge branch 'pr-33' 2022-11-20 14:56:54 +01:00
Morten Linderud
a2ed5bb493
Merge branch 'pr-27' 2022-11-20 14:55:31 +01:00
Mike Yuan
added92801
genfstab: remove subvolid= from btrfs options if subvol= is set
Having only one of subvol= and subvolid= is enough for mounting a btrfs subvolume
And having subvolid= set prevents things like 'snapper rollback' to work, as it
updates the subvolume in-place, leaving subvol= unchanged with a different subvolid.
2022-11-20 18:08:23 +08:00
Mike Yuan
ef83a837fd
pacstrap: add option '-D' to skip pacman dependency checks
Closes #19
2022-10-28 18:28:30 +08:00
Morten Linderud
09952070ea
Merge branch 'pr-32' 2022-10-28 00:14:54 +02:00
Morten Linderud
ebf492335e
Merge branch 'pr-31' 2022-10-28 00:13:26 +02:00
Morten Linderud
ddafd7477e
Merge branch 'pr-30' 2022-10-28 00:12:27 +02:00
Morten Linderud
8f9725afc8
Merge branch 'pr-28' 2022-10-28 00:11:11 +02:00
Mike Yuan
c04c43a6ce
genfstab: fix src of bind mounts
Sources of bind mounts in fstab should be relative to the target's root
instead of the host one.
2022-10-27 13:18:01 +08:00
Mike Yuan
127a23ce73
pacstrap: update bash completion (added missing options) 2022-10-22 21:10:56 +08:00
Mike Yuan
91562aa99c
pacstrap: remove obsolete option '-d' completely
This has been obsolete for 4 years and I can hardly imagine people still using it (only to find that it doesn't actually work).
2022-10-22 21:07:27 +08:00
Mike Yuan
ddf3134077
pacstrap: add option '-P' to copy the host's pacman config to the target 2022-10-22 20:51:54 +08:00
Mike Yuan
58849024de
common: disable btrfs's fsck in fsck_types
btrfs doesn't need nor use a regular fsck utility.
This was wrongly added in b31a5d9f94 and made `genfstab` generate btrfs entries with `fs_passno` not
set to `0`.
2022-10-20 17:16:03 +08:00
Morten Linderud
acb8a7b9a7
prepare v27
Signed-off-by: Morten Linderud <morten@linderud.pw>
2022-09-28 18:48:20 +02:00
Morten Linderud
2aa70691e5
Merge commit 'refs/pull/20/head' of github.com:archlinux/arch-install-scripts 2022-08-28 14:57:52 +02:00
Morten Linderud
e6dd0455db
Merge commit 'refs/pull/23/head' of github.com:archlinux/arch-install-scripts 2022-08-28 14:57:23 +02:00
Mike Yuan
8be9340001
pacstrap: add option '-K' to initialize an empty keyring in the new root 2022-08-25 22:45:07 +08:00
éclairevoyant
405d60b462 update pseudofs list 2022-08-04 07:42:23 -04:00
éclairevoyant
b31a5d9f94 update fsck list 2022-08-04 07:42:23 -04:00
Morten Linderud
5ba7798f81
Merge commit 'refs/pull/22/head' of github.com:archlinux/arch-install-scripts 2022-07-30 00:50:36 +02:00
Sean Anderson
58ff428757 Use separate pid namespace for worker processes
As described in 2be79c6 ("run the chroot in a new PID namespace"), child
processes can hang around and keep various files open. This may prevent
filesystems from being unmounted (as they are still in-use).

When adding unshare mode, I did not quite understand this distinction
(and I wasn't testing with e.g. gnupg) so I didn't catch this. Fix this
by always using unshare to create a second pid namespace for "worker"
processes. This ensures that all children are dead when we start
unmounting things. As the top-level unshare is no longer always
necessary, convert the unshare variable to a binary value.

Fixes: ee9db7d ("Add unshare mode to pacstrap")
Closes: #21
2022-07-28 10:02:31 -04:00
Morten Linderud
8a56133926
common: Make run a tmpfs mount
Reverts aea51ba901
Fixes https://github.com/archlinux/arch-install-scripts/issues/15

Signed-off-by: Morten Linderud <morten@linderud.pw>
2022-07-03 14:01:26 +02:00
Morten Linderud
9ffd8bc6e3
common: include f2fs.fsck
Fixes FS#71760

Signed-off-by: Morten Linderud <morten@linderud.pw>
2022-06-28 10:56:35 +02:00
Pete Anderson
20616bacc5
add_resolve_conf: recursive host + target symlinks 2022-06-28 10:32:19 +02:00
Morten Linderud
d5d3da33c7
Merge commit 'refs/pull/14/head' of github.com:archlinux/arch-install-scripts 2022-06-28 09:57:06 +02:00
Morten Linderud
2052c61529
Merge commit 'refs/pull/13/head' of github.com:archlinux/arch-install-scripts 2022-06-02 22:24:27 +02:00
Morten Linderud
5852434999
Merge commit 'refs/pull/18/head' of github.com:archlinux/arch-install-scripts 2022-06-02 22:23:10 +02:00
Jelle van der Waa
516cc7116c
README: document asciidoc optional dependency
Closes #9
2022-05-28 21:36:47 +02:00
Richard Hajek
2569d70d4e Added info to docs and improved readability 2022-04-25 20:16:09 +02:00
Richard Hajek
6d85a16785 Added info to arch-chroot --help 2022-04-25 20:16:09 +02:00
Sean Anderson
2623f8d76f Add unshare mode to arch-chroot
This is effectively the same transformation as in the previous patch.
We move the mountpoint warning later to avoid warning when we are about
to bind-mount the chroot dir ourselves.
2021-12-08 17:49:09 -05:00
Sean Anderson
ee9db7d580 Add unshare mode to pacstrap
This adds an "unshare" mode to pacstrap. This mode lets a regular user
create a new arch root filesystem. We use -N because both -U and -u are
taken in pacstrap and arch-chroot, respectively. There are two major
changes to pacstrap: we need to run many commands in under unshare, and
the setup process for mounts is different.

Because unshare starts a new shell, it is difficult to run many commands
in sequence. To get around this, we create a function for the rest of
the commands we wish to run, and then declare all functions and
variables in the unshare'd shell. This is pretty convenient. An
alternative method would be to generate the shell script as a HERE
document, and pipe it to bash.

Because unshare starts a new shell, we can only communicate using
stdin/out and any command line arguments. And we need to defer some
setup until after we are root. To get around this, we create a function
for the rest of the commands we wish to run, and then declare all
functions and variables in the unshare'd shell. I also considered having
a separate helper script which would contain the contents of pacstrap().
But I think this would be confusing, because the logic would then live
in a separate file (instead of just a separate function). That method is
also tricky because every variable has to be passed in through the
command-line arguments. One last method would be to generate a script on
the fly (e.g. using a HERE doc). I think that method could work as well.

The primary difference to the setup process is that we need to mount
filesystems in a different manner:
- We bind-mount the root directory. This is so commands which want to
  determine how much free space there is (or otherwise work with mounts)
  expect a mount on /. We unmount it with --lazy, since otherwise sys
  will cause an error (see below).
- proc can be mounted multiple times and is mounted in the same way
- sys cannot be mounted again, but we can recursively bind-mount it.
  When mounted this way, we can't unmount it until the mount namespace
  is deleted (likely because sys has a number of sub-mounts), so we have
  to use --lazy when unmounting it.
- dev can be bind-mounted, but this results in errors because some
  packages try and modify files in /dev if they exist. Since we don't
  have permission to do that on the host system, this fails. Instead, we
  just bind-mount a minimal set of files.
- run is not bind-mounted, but is instead created as a new tmpfs.
  According to aea51ba ("Bind mount /run from host into new root"), the
  reason this was done was to avoid lengthy timeouts when scanning for
  lvm devices. Because unshare does not (and cannot) use lvm devices, we
  don't need to bind-mount.
- tmp is created as usual.

Closes: #8
2021-12-08 17:44:51 -05:00
Sean Anderson
88c0c9db0b Don't warn if ownership changes when copying /etc/pacman.d/gnupg
In an unshare environment, /etc/pacman.d/gnupg is owned by the original
root, who is now "nobody". cp will warn about this, since we can't
create files owned by the original root, and it instead creates them as
the unshare'd root (the original user). This is benign, so ignore it.
2021-11-17 13:47:54 -05:00
Lara
bb04ab435a
Fix a typo in common 2021-09-06 17:40:43 +02:00
Tom Yan
ab30883f8a Bind mount /run read-only
Avoid e.g. systemd-tmpfiles from tampering /run (of the host):

fchownat() of /run/systemd/netif failed: Read-only file system
fchownat() of /run/systemd/netif/links failed: Read-only file system
fchownat() of /run/systemd/netif/leases failed: Read-only file system
fchownat() of /run/systemd/netif/lldp failed: Read-only file system

In this particular case, it could cause unexpected (and unnecessary)
change of ownership to these directories (because of automatic uid/gid
allocation), which could prevent systemd-networkd from working.

Besides, the chroot should under no circumstances (actually) need any
(read-)write access to /run. If there's such need, we should not bind
mount.

Ref.: https://bugs.archlinux.org/task/61808
2021-09-06 20:39:14 +08:00
Eli Schwartz
eef029adcc
prepare v24 2021-04-22 14:52:37 -04:00
Eli Schwartz
f3641171d9
doc: fix dumb typo, the pacman manpage is section 8 not 1
Fixes FS#70548
2021-04-22 14:02:27 -04:00