From 0d2edecb2be14c0ed92a33c7508358d648cd3d2f Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Wed, 3 Jul 2019 05:08:20 -0400 Subject: New upstream version 22 --- Makefile | 23 +++++- completion/_archinstallscripts.zsh | 163 ++++++++++++++++++++++++++++++++++++ completion/arch-chroot.bash | 27 ++++++ completion/genfstab.bash | 31 +++++++ completion/pacstrap.bash | 38 +++++++++ doc/arch-chroot.8.asciidoc | 46 +++++++++++ doc/asciidoc.conf | 37 +++++++++ doc/footer.asciidoc | 18 ++++ doc/genfstab.8.asciidoc | 50 +++++++++++ doc/pacstrap.8.asciidoc | 47 +++++++++++ genfstab.in | 4 +- pacstrap.in | 14 ++-- zsh-completion | 164 ------------------------------------- 13 files changed, 485 insertions(+), 177 deletions(-) create mode 100644 completion/_archinstallscripts.zsh create mode 100644 completion/arch-chroot.bash create mode 100644 completion/genfstab.bash create mode 100644 completion/pacstrap.bash create mode 100644 doc/arch-chroot.8.asciidoc create mode 100644 doc/asciidoc.conf create mode 100644 doc/footer.asciidoc create mode 100644 doc/genfstab.8.asciidoc create mode 100644 doc/pacstrap.8.asciidoc delete mode 100644 zsh-completion diff --git a/Makefile b/Makefile index 7fa638f..4d3cdb2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VER=21 +VER=22 PREFIX = /usr/local @@ -7,9 +7,15 @@ BINPROGS = \ genfstab \ pacstrap +MANS = \ + doc/arch-chroot.8 \ + doc/genfstab.8 \ + doc/pacstrap.8 + BASH = bash -all: $(BINPROGS) +all: $(BINPROGS) man +man: $(MANS) V_GEN = $(_v_GEN_$(V)) _v_GEN_ = $(_v_GEN_0) @@ -20,8 +26,11 @@ edit = $(V_GEN) m4 -P $@.in >$@ && chmod go-w,+x $@ %: %.in common $(edit) +doc/%: doc/%.asciidoc doc/asciidoc.conf doc/footer.asciidoc + $(V_GEN) a2x --no-xmllint --asciidoc-opts="-f doc/asciidoc.conf" -d manpage -f manpage -D doc $< + clean: - $(RM) $(BINPROGS) + $(RM) $(BINPROGS) $(MANS) check: all @for f in $(BINPROGS); do bash -O extglob -n $$f; done @@ -30,6 +39,12 @@ check: all install: all install -dm755 $(DESTDIR)$(PREFIX)/bin install -m755 $(BINPROGS) $(DESTDIR)$(PREFIX)/bin - install -Dm644 zsh-completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_archinstallscripts + install -Dm644 completion/_archinstallscripts.zsh $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_archinstallscripts + cd completion; for comp in *.bash; do \ + install -Dm644 $$comp $(DESTDIR)$(PREFIX)/share/bash-completion/completions/$${comp%%.*}; \ + done; + for manfile in $(MANS); do \ + install -Dm644 $$manfile -t $(DESTDIR)$(PREFIX)/share/man/man$${manfile##*.}; \ + done; .PHONY: all clean install uninstall diff --git a/completion/_archinstallscripts.zsh b/completion/_archinstallscripts.zsh new file mode 100644 index 0000000..d2c8c7b --- /dev/null +++ b/completion/_archinstallscripts.zsh @@ -0,0 +1,163 @@ +#compdef pacstrap genfstab arch-chroot + +_pacstrap_args=( + '-h[display help]' +) + +_pacstrap_args_nonh=( + '(-h --help)-c[Use the package cache on the host, rather than the target]' + '(--help -h)-i[Avoid auto-confirmation of package selections]' +) + + +# builds command for invoking pacman in a _call_program command - extracts +# relevant options already specified (config file, etc) +# $cmd must be declared by calling function +_pacman_get_command() { + # this is mostly nicked from _perforce + cmd=( "pacman" "2>/dev/null") + integer i + for (( i = 2; i < CURRENT - 1; i++ )); do + if [[ ${words[i]} = "--config" || ${words[i]} = "--root" ]]; then + cmd+=( ${words[i,i+1]} ) + fi + done +} + +# provides completions for packages available from repositories +# these can be specified as either 'package' or 'repository/package' +_pacman_completions_all_packages() { + local -a cmd packages repositories packages_long + _pacman_get_command + + if compset -P1 '*/*'; then + packages=( $(_call_program packages $cmd[@] -Sql ${words[CURRENT]%/*}) ) + typeset -U packages + _wanted repo_packages expl "repository/package" compadd ${(@)packages} + else + packages=( $(_call_program packages $cmd[@] -Sql) ) + typeset -U packages + _wanted packages expl "packages" compadd - "${(@)packages}" + + repositories=(${(o)${${${(M)${(f)"$( /dev/null; then + _completion_loader pacman +fi + +_pacstrap() { + compopt +o dirnames +o default + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-C -c -G -i -M -h" + + for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do + if [[ -d ${i} ]]; then + _pacman_pkg Slq + return 0 + fi + done + + case ${prev} in + -h) + return 0 + ;; + -C) + compopt -o default + return 0 + ;; + esac + + if [[ ${cur} = -* ]]; then + COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) + return 0 + fi + + compopt -o dirnames +} + +complete -F _pacstrap pacstrap diff --git a/doc/arch-chroot.8.asciidoc b/doc/arch-chroot.8.asciidoc new file mode 100644 index 0000000..ada7d40 --- /dev/null +++ b/doc/arch-chroot.8.asciidoc @@ -0,0 +1,46 @@ +arch-chroot(8) +============== + +Name +---- +arch-chroot - enhanced chroot command + +Synopsis +-------- +arch-chroot [options] chroot-dir [command] + +Description +----------- +arch-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*. + +[NOTE] +====== +The target chroot-dir *should* be a mountpoint. This ensures that tools such as +linkman:pacman[8] or linkman:findmnt[8] have an accurate hierarchy of the +mounted filesystems within the chroot. If your chroot target is not a +mountpoint, you can bind mount the directory on itself to make it a mountpoint, +i.e.: + +'mount --bind /your/chroot /your/chroot' +====== + + +Options +------- + +*-u [:group]*:: + Specify non-root user and optional group to use. + +*-h*:: + Output syntax and command line options. + +See Also +-------- + +linkman:pacman[1] + +include::footer.asciidoc[] diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf new file mode 100644 index 0000000..c675a20 --- /dev/null +++ b/doc/asciidoc.conf @@ -0,0 +1,37 @@ +## linkman: macro +# Inspired by/borrowed from the GIT source tree at Documentation/asciidoc.conf +# +# Usage: linkman:command[manpage-section] +# +# Note, {0} is the manpage section, while {target} is the command. +# +# Show man link as: (
); if section is defined, else just show +# the command. + +[macros] +(?su)[\\]?(?Plinkman):(?P\S*?)\[(?P.*?)\]= + +[attributes] +asterisk=* +plus=+ +caret=^ +startsb=[ +endsb=] +backslash=\ +tilde=~ +apostrophe=' +backtick=` +litdd=-- + +ifdef::backend-docbook[] +[linkman-inlinemacro] +{0%{target}} +{0#} +{0#{target}{0}} +{0#} +endif::backend-docbook[] + +ifdef::backend-xhtml11[] +[linkman-inlinemacro] +{target}{0?({0})} +endif::backend-xhtml11[] diff --git a/doc/footer.asciidoc b/doc/footer.asciidoc new file mode 100644 index 0000000..4445b0c --- /dev/null +++ b/doc/footer.asciidoc @@ -0,0 +1,18 @@ + +Bugs +---- +Bugs can be reported on the bug tracker 'https://bugs.archlinux.org' in the Arch +Linux category and title prefixed with [arch-install-scripts] or via +mailto:arch-projects@archlinux.org[]. + + +Authors +------- + +Maintainers: + +* Dave Reisner +* Eli Schwartz + +For additional contributors, use `git shortlog -s` on the arch-install-scripts.git +repository. diff --git a/doc/genfstab.8.asciidoc b/doc/genfstab.8.asciidoc new file mode 100644 index 0000000..73faa4e --- /dev/null +++ b/doc/genfstab.8.asciidoc @@ -0,0 +1,50 @@ +genfstab(8) +=========== + +Name +---- +genfstab - generate output suitable for addition to an fstab file + +Synopsis +-------- +genfstab [options] root + +Description +----------- +genfstab helps fill in an fstab file by autodetecting all the current mounts +below a given mountpoint and printing them in fstab-compatible format to +standard output. It can be used to persist a manually mounted filesystem +hierarchy and is often used during the initial install and configuration of an +OS. + +Options +------- + +*-f* :: + Restrict output to mountpoints matching the prefix 'filter'. + +*-L*:: + Use labels for source identifiers (shortcut for '-t LABEL'). + +*-p*:: + Exclude pseudofs mounts (default behavior). + +*-P*:: + Include pseudofs mounts. + +*-t* :: + Use 'tag' for source identifiers (should be one of: 'LABEL', 'UUID', + 'PARTLABEL', 'PARTUUID'). + +*-U*:: + Use UUIDs for source identifiers (shortcut for '-t UUID'). + +*-h*:: + Output syntax and command line options. + +See Also +-------- + +linkman:pacman[1] + +include::footer.asciidoc[] diff --git a/doc/pacstrap.8.asciidoc b/doc/pacstrap.8.asciidoc new file mode 100644 index 0000000..9f25792 --- /dev/null +++ b/doc/pacstrap.8.asciidoc @@ -0,0 +1,47 @@ +pacstrap(8) +=========== + +Name +---- +pacstrap - install packages to the specified new root directory + +Synopsis +-------- +pacstrap [options] root [packages...] + +Description +----------- +pacstrap is designed to create a new system installation from scratch. The +specified packages will be installed into a given directory after setting up +some basic mountpoints. By default, the host system's pacman signing keys +and mirrorlist will be used to seed the chroot. + +If no packages are specified to be installed, the 'base' group will be installed. + +Options +------- + +*-C* :: + Use an alternate config file for pacman. + +*-c*:: + Use the package cache on the host, rather than the target. + +*-G*:: + Avoid copying the host's pacman keyring to the target. + +*-i*:: + Prompt for package confirmation when needed (run interactively). + +*-M*:: + Avoid copying the host's mirrorlist to the target. + +*-h*:: + Output syntax and command line options. + +See Also +-------- + +linkman:pacman[1] + +include::footer.asciidoc[] diff --git a/genfstab.in b/genfstab.in index 3ff7a14..b8220ea 100644 --- a/genfstab.in +++ b/genfstab.in @@ -79,11 +79,11 @@ usage() { usage: ${0##*/} [options] root Options: - -f FILTER Restrict output to mountpoints matching the prefix FILTER + -f Restrict output to mountpoints matching the prefix FILTER -L Use labels for source identifiers (shortcut for -t LABEL) -p Exclude pseudofs mounts (default behavior) -P Include pseudofs mounts - -t TAG Use TAG for source identifiers (TAG should be one of: LABEL, + -t Use TAG for source identifiers (TAG should be one of: LABEL, UUID, PARTLABEL, PARTUUID) -U Use UUIDs for source identifiers (shortcut for -t UUID) diff --git a/pacstrap.in b/pacstrap.in index b0db8ce..231a154 100644 --- a/pacstrap.in +++ b/pacstrap.in @@ -21,7 +21,7 @@ usage() { usage: ${0##*/} [options] root [packages...] Options: - -C config Use an alternate config file for pacman + -C Use an alternate config file for pacman -c Use the package cache on the host, rather than the target -G Avoid copying the host's pacman keyring to the target -i Prompt for package confirmation when needed (run interactively) @@ -92,18 +92,13 @@ fi # create obligatory directories msg 'Creating install root at %s' "$newroot" -mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc} +mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc/pacman.d} mkdir -m 1777 -p "$newroot"/tmp mkdir -m 0555 -p "$newroot"/{sys,proc} # mount API filesystems chroot_setup "$newroot" || die "failed to setup chroot %s" "$newroot" -msg 'Installing packages to %s' "$newroot" -if ! pacman -r "$newroot" -Sy "${pacman_args[@]}"; then - die 'Failed to install packages to new root' -fi - if (( copykeyring )); then # if there's a keyring on the host, copy it into the new root, unless it exists already if [[ -d /etc/pacman.d/gnupg && ! -d $newroot/etc/pacman.d/gnupg ]]; then @@ -111,6 +106,11 @@ if (( copykeyring )); then fi fi +msg 'Installing packages to %s' "$newroot" +if ! pacman -r "$newroot" -Sy "${pacman_args[@]}"; then + die 'Failed to install packages to new root' +fi + if (( copymirrorlist )); then # install the host's mirrorlist onto the new root cp -a /etc/pacman.d/mirrorlist "$newroot/etc/pacman.d/" diff --git a/zsh-completion b/zsh-completion deleted file mode 100644 index bc4e4d3..0000000 --- a/zsh-completion +++ /dev/null @@ -1,164 +0,0 @@ -#compdef pacstrap genfstab arch-chroot - -_pacstrap_args=( - '-h[display help]' -) - -_pacstrap_args_nonh=( - '(-h --help)-c[Use the package cache on the host, rather than the target]' - '(-h --help)-d[Allow installation to a non-mountpoint directory]' - '(--help -h)-i[Avoid auto-confirmation of package selections]' -) - - -# builds command for invoking pacman in a _call_program command - extracts -# relevant options already specified (config file, etc) -# $cmd must be declared by calling function -_pacman_get_command() { - # this is mostly nicked from _perforce - cmd=( "pacman" "2>/dev/null") - integer i - for (( i = 2; i < CURRENT - 1; i++ )); do - if [[ ${words[i]} = "--config" || ${words[i]} = "--root" ]]; then - cmd+=( ${words[i,i+1]} ) - fi - done -} - -# provides completions for packages available from repositories -# these can be specified as either 'package' or 'repository/package' -_pacman_completions_all_packages() { - local -a cmd packages repositories packages_long - _pacman_get_command - - if compset -P1 '*/*'; then - packages=( $(_call_program packages $cmd[@] -Sql ${words[CURRENT]%/*}) ) - typeset -U packages - _wanted repo_packages expl "repository/package" compadd ${(@)packages} - else - packages=( $(_call_program packages $cmd[@] -Sql) ) - typeset -U packages - _wanted packages expl "packages" compadd - "${(@)packages}" - - repositories=(${(o)${${${(M)${(f)"$(