Modify Arch Install Scripts to work with Future Linux Install Scripts

This commit is contained in:
xhaa123 2024-10-29 12:28:58 +08:00
parent a60ad80361
commit b53d472be3
7 changed files with 33 additions and 32 deletions

View File

@ -1,14 +1,14 @@
VER=26
PREFIX = /usr/local
PREFIX = /usr
BINPROGS = \
arch-chroot \
future-chroot \
genfstab \
pacstrap
MANS = \
doc/arch-chroot.8 \
doc/future-chroot.8 \
doc/genfstab.8 \
doc/pacstrap.8
@ -25,7 +25,7 @@ _v_GEN_0 = @echo " GEN " $@;
edit = $(V_GEN) m4 -P $@.in >$@ && chmod go-w,+x $@
arch-chroot: arch-chroot.in common
future-chroot: future-chroot.in common
$(edit)
genfstab: genfstab.in fstab-helpers
@ -49,8 +49,8 @@ shellcheck: $(BINPROGS)
shellcheck -W 99 --color -x test/test_*
install: all
install -d $(DESTDIR)$(PREFIX)/bin
install -m 0755 $(BINPROGS) $(DESTDIR)$(PREFIX)/bin
install -d $(DESTDIR)$(PREFIX)/sbin
install -m 0755 $(BINPROGS) $(DESTDIR)$(PREFIX)/sbin
install -d $(DESTDIR)$(PREFIX)/share/zsh/site-functions
install -m 0644 $(ZSHCOMP) $(DESTDIR)$(PREFIX)/share/zsh/site-functions
install -d $(DESTDIR)$(PREFIX)/share/bash-completion/completions

View File

@ -1,7 +1,9 @@
# Arch Install Scripts
# Modify Arch Install Scripts
# Future Install Scripts
This is a small suite of scripts aimed at automating some menial
tasks when installing [Arch Linux](https://www.archlinux.org).
tasks when installing [Future Linux](https://www.futurelinux.xyz).
## Requirements

23
common
View File

@ -29,15 +29,15 @@ chroot_setup() {
[[ $(trap -p EXIT) ]] && die '(BUG): attempting to overwrite existing EXIT trap'
trap 'chroot_teardown' EXIT
chroot_add_mount proc "$1/proc" -t proc -o nosuid,noexec,nodev &&
chroot_add_mount sys "$1/sys" -t sysfs -o nosuid,noexec,nodev,ro &&
chroot_add_mount --bind /dev "$1/dev" &&
chroot_add_mount devpts "$1/dev/pts" -t devpts -o gid=5,mode=0620 &&
chroot_add_mount proc $1/proc -t proc &&
chroot_add_mount sysfs $1/sys -t sysfs &&
chroot_add_mount tmpfs "$1/run" -t tmpfs &&
chroot_add_mount tmpfs "$1/dev/shm" -t tmpfs -o nosuid,nodev &&
ignore_error chroot_maybe_add_mount "[[ -d '$1/sys/firmware/efi/efivars' ]]" \
efivarfs "$1/sys/firmware/efi/efivars" -t efivarfs -o nosuid,noexec,nodev &&
chroot_add_mount udev "$1/dev" -t devtmpfs -o mode=0755,nosuid &&
chroot_add_mount devpts "$1/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec &&
chroot_add_mount shm "$1/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev &&
chroot_add_mount /run "$1/run" --bind --make-private &&
chroot_add_mount tmp "$1/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid
efivarfs "$1/sys/firmware/efi/efivars" -t efivarfs
}
chroot_teardown() {
@ -68,8 +68,8 @@ unshare_setup() {
trap 'unshare_teardown' EXIT
chroot_add_mount_lazy "$1" "$1" --bind &&
chroot_add_mount proc "$1/proc" -t proc -o nosuid,noexec,nodev &&
chroot_add_mount_lazy /sys "$1/sys" --rbind &&
chroot_add_mount proc "$1/proc" -t proc &&
chroot_add_mount sysfs "$1/sys" -t sysfs &&
chroot_add_link /proc/self/fd "$1/dev/fd" &&
chroot_add_link /proc/self/fd/0 "$1/dev/stdin" &&
chroot_add_link /proc/self/fd/1 "$1/dev/stdout" &&
@ -80,8 +80,7 @@ unshare_setup() {
chroot_bind_device /dev/tty "$1/dev/tty" &&
chroot_bind_device /dev/urandom "$1/dev/urandom" &&
chroot_bind_device /dev/zero "$1/dev/zero" &&
chroot_add_mount run "$1/run" -t tmpfs -o nosuid,nodev,mode=0755 &&
chroot_add_mount tmp "$1/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid
chroot_add_mount tmpfs "$1/run" -t tmpfs
}
unshare_teardown() {

View File

@ -1,4 +1,4 @@
_arch_chroot() {
_future_chroot() {
compopt +o dirnames
local cur prev opts i
_init_completion -n : || return
@ -22,4 +22,4 @@ _arch_chroot() {
compopt -o dirnames
}
complete -F _arch_chroot arch-chroot
complete -F _future_chroot future-chroot

View File

@ -1,4 +1,4 @@
#compdef arch-chroot
#compdef future-chroot
# NOTE: nearly everything here is borrowed from the chroot completion
local -a args=(

View File

@ -1,21 +1,21 @@
arch-chroot(8)
future-chroot(8)
==============
Name
----
arch-chroot - enhanced chroot command
future-chroot - enhanced chroot command
Synopsis
--------
arch-chroot [options] chroot-dir [command] [arguments...]
future-chroot [options] chroot-dir [command] [arguments...]
Description
-----------
arch-chroot wraps the linkman:chroot[1] command while ensuring that important
future-chroot wraps the linkman:chroot[1] command while ensuring that important
functionality is available, e.g. mounting '/dev/', '/proc' and other API
filesystems, or exposing linkman:resolv.conf[5] to the chroot.
If 'command' is unspecified, arch-chroot will launch */bin/bash*.
If 'command' is unspecified, future-chroot will launch */bin/bash*.
[NOTE]
======

View File

@ -19,7 +19,7 @@ usage: ${0##*/} chroot-dir [command] [arguments...]
If 'command' is unspecified, ${0##*/} will launch /bin/bash.
Note that when using arch-chroot, the target chroot directory *should* be a
Note that when using future-chroot, the target chroot directory *should* be a
mountpoint. This ensures that tools such as pacman(8) or findmnt(8) have an
accurate hierarchy of the mounted filesystems within the chroot.
@ -65,7 +65,7 @@ chroot_add_resolv_conf() {
chroot_add_mount "$src" "$dest" -c --bind
}
arch-chroot() {
future-chroot() {
(( EUID == 0 )) || die 'This script must be run with root privileges'
[[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir"
@ -117,8 +117,8 @@ shift
args=("$@")
if (( unshare )); then
setup=unshare_setup
$mount_unshare bash -c "$(declare_all); arch-chroot"
$mount_unshare bash -c "$(declare_all); future-chroot"
else
setup=chroot_setup
arch-chroot
future-chroot
fi