From a1e50f04b89ff042baf91a403a6df0cbd1e3cec2 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 26 Nov 2013 11:09:49 -0500 Subject: move a bunch of stuff to subdirs Signed-off-by: Dave Reisner --- 01-memdisk.rules | 11 --- Makefile | 9 +-- bash-completion | 84 ---------------------- mkinitcpio-generate-shutdown-ramfs.service | 15 ---- shell/bash-completion | 84 ++++++++++++++++++++++ shell/zsh-completion | 63 ++++++++++++++++ systemd/mkinitcpio-generate-shutdown-ramfs.service | 15 ++++ udev/01-memdisk.rules | 11 +++ zsh-completion | 63 ---------------- 9 files changed, 178 insertions(+), 177 deletions(-) delete mode 100644 01-memdisk.rules delete mode 100644 bash-completion delete mode 100644 mkinitcpio-generate-shutdown-ramfs.service create mode 100644 shell/bash-completion create mode 100644 shell/zsh-completion create mode 100644 systemd/mkinitcpio-generate-shutdown-ramfs.service create mode 100644 udev/01-memdisk.rules delete mode 100644 zsh-completion diff --git a/01-memdisk.rules b/01-memdisk.rules deleted file mode 100644 index 0a8fd7b..0000000 --- a/01-memdisk.rules +++ /dev/null @@ -1,11 +0,0 @@ -ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="mtdblock*", ATTRS{name}=="memdisk", ATTRS{type}=="ram", GOTO="memdisk_start" -GOTO="memdisk_end" - -LABEL="memdisk_start" - -SYMLINK+="memdisk" -IMPORT{builtin}="blkid" -ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" -ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" - -LABEL="memdisk_end" diff --git a/Makefile b/Makefile index 38a7111..66b1960 100644 --- a/Makefile +++ b/Makefile @@ -45,20 +45,21 @@ install: all install -m644 mkinitcpio.conf $(DESTDIR)/etc/mkinitcpio.conf install -m755 -t $(DESTDIR)/usr/lib/initcpio init shutdown install -m644 -t $(DESTDIR)/usr/lib/initcpio init_functions functions - install -m644 01-memdisk.rules $(DESTDIR)/usr/lib/initcpio/udev/01-memdisk.rules + install -m644 udev/01-memdisk.rules $(DESTDIR)/usr/lib/initcpio/udev/01-memdisk.rules cp -at $(DESTDIR)/usr/lib/initcpio hooks install install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/* - install -m644 mkinitcpio-generate-shutdown-ramfs.service $(DESTDIR)/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service + install -m644 systemd/mkinitcpio-generate-shutdown-ramfs.service \ + $(DESTDIR)/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service install -m755 50-mkinitcpio.install $(DESTDIR)/usr/lib/kernel/install.d/50-mkinitcpio.install install -m644 man/mkinitcpio.8 $(DESTDIR)/usr/share/man/man8/mkinitcpio.8 install -m644 man/mkinitcpio.conf.5 $(DESTDIR)/usr/share/man/man5/mkinitcpio.conf.5 install -m644 man/lsinitcpio.1 $(DESTDIR)/usr/share/man/man1/lsinitcpio.1 - install -m644 bash-completion $(DESTDIR)/usr/share/bash-completion/completions/mkinitcpio + install -m644 shell/bash-completion $(DESTDIR)/usr/share/bash-completion/completions/mkinitcpio ln -s mkinitcpio $(DESTDIR)/usr/share/bash-completion/completions/lsinitcpio - install -m644 zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_mkinitcpio + install -m644 shell/zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_mkinitcpio doc: $(MANPAGES) man/%: man/%.txt Makefile diff --git a/bash-completion b/bash-completion deleted file mode 100644 index a0f07dc..0000000 --- a/bash-completion +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -_detect_kver() { - local kver_validator='^[[:digit:]]+(\.[[:digit:]]+)+' - offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1" 2>/dev/null) || return 1 - read kver _ < \ - <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null) - [[ $kver =~ $kver_validator ]] && printf "$kver" -} - -_lsinitcpio() { - local cur opts - opts=(-a --analyze -c --config -h --help -l --list - -n --nocolor -V --version -v --verbose -x --extract) - - _get_comp_words_by_ref cur - - case $cur in - -*) - COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) ;; - *) - _filedir ;; - esac -} - -_find_kernel_versions() { - local -a matches - local dir f kver - - for f in /boot/*; do - # only match regular files which pass validation - if [[ ! -L $f && -f $f ]] && kver=$(_detect_kver "$f"); then - matches+=("$f" "$kver") - fi - done - - COMPREPLY=($(compgen -W "${matches[*]}" -- $cur)) -} - -_files_from_dirs() { - local files stripsuf d f - - if [[ $1 = -s ]]; then - stripsuf=$2 - shift 2 - fi - - for d in "$@"; do - for f in "$d"/*; do - [[ -f $f ]] && files+=("${f##*/}") - done - done - - printf '%s\n' "${files[@]%$stripsuf}" -} - -_mkinitcpio() { - local action cur prev opts - opts=(-A --addhooks -c --config -g --generate -H --hookhelp -h --help -k --kernel - -L --listhooks -M --automods -n --nocolor -P --allpresets -p --preset -r --moduleroot - -S --skiphooks -s --save -t --builddir -V --version -v --verbose -z --compress) - - _get_comp_words_by_ref cur prev - - case $prev in - -[cg]|--config|--generate) - _filedir ;; - -r|--moduleroot|-t|--builddir) - _filedir -d ;; - -k|--kernel) - _find_kernel_versions ;; - -p|--preset) - COMPREPLY=($(compgen -W "$(_files_from_dirs -s .preset /etc/mkinitcpio.d)" -- "$cur")) ;; - -[AHS]|--add|--hookhelp|--skiphooks) - COMPREPLY=($(compgen -W "$(_files_from_dirs {/usr,}/lib/initcpio/install)" -- "$cur")) ;; - *) - COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) ;; - esac -} - -complete -F _mkinitcpio mkinitcpio -complete -F _lsinitcpio lsinitcpio - -# vim: set et ts=4 sw=4 ft=sh: diff --git a/mkinitcpio-generate-shutdown-ramfs.service b/mkinitcpio-generate-shutdown-ramfs.service deleted file mode 100644 index 36c2508..0000000 --- a/mkinitcpio-generate-shutdown-ramfs.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Generate shutdown-ramfs -DefaultDependencies=no -Before=shutdown.target -ConditionFileIsExecutable=!/run/initramfs/shutdown - -[Service] -Type=oneshot -# /tmp could be umounted at this point -# use /run as temporary directory -Environment=TMPDIR=/run -ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -c /dev/null -d /run/initramfs - -[Install] -WantedBy=shutdown.target diff --git a/shell/bash-completion b/shell/bash-completion new file mode 100644 index 0000000..a0f07dc --- /dev/null +++ b/shell/bash-completion @@ -0,0 +1,84 @@ +#!/bin/bash + +_detect_kver() { + local kver_validator='^[[:digit:]]+(\.[[:digit:]]+)+' + offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1" 2>/dev/null) || return 1 + read kver _ < \ + <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null) + [[ $kver =~ $kver_validator ]] && printf "$kver" +} + +_lsinitcpio() { + local cur opts + opts=(-a --analyze -c --config -h --help -l --list + -n --nocolor -V --version -v --verbose -x --extract) + + _get_comp_words_by_ref cur + + case $cur in + -*) + COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) ;; + *) + _filedir ;; + esac +} + +_find_kernel_versions() { + local -a matches + local dir f kver + + for f in /boot/*; do + # only match regular files which pass validation + if [[ ! -L $f && -f $f ]] && kver=$(_detect_kver "$f"); then + matches+=("$f" "$kver") + fi + done + + COMPREPLY=($(compgen -W "${matches[*]}" -- $cur)) +} + +_files_from_dirs() { + local files stripsuf d f + + if [[ $1 = -s ]]; then + stripsuf=$2 + shift 2 + fi + + for d in "$@"; do + for f in "$d"/*; do + [[ -f $f ]] && files+=("${f##*/}") + done + done + + printf '%s\n' "${files[@]%$stripsuf}" +} + +_mkinitcpio() { + local action cur prev opts + opts=(-A --addhooks -c --config -g --generate -H --hookhelp -h --help -k --kernel + -L --listhooks -M --automods -n --nocolor -P --allpresets -p --preset -r --moduleroot + -S --skiphooks -s --save -t --builddir -V --version -v --verbose -z --compress) + + _get_comp_words_by_ref cur prev + + case $prev in + -[cg]|--config|--generate) + _filedir ;; + -r|--moduleroot|-t|--builddir) + _filedir -d ;; + -k|--kernel) + _find_kernel_versions ;; + -p|--preset) + COMPREPLY=($(compgen -W "$(_files_from_dirs -s .preset /etc/mkinitcpio.d)" -- "$cur")) ;; + -[AHS]|--add|--hookhelp|--skiphooks) + COMPREPLY=($(compgen -W "$(_files_from_dirs {/usr,}/lib/initcpio/install)" -- "$cur")) ;; + *) + COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) ;; + esac +} + +complete -F _mkinitcpio mkinitcpio +complete -F _lsinitcpio lsinitcpio + +# vim: set et ts=4 sw=4 ft=sh: diff --git a/shell/zsh-completion b/shell/zsh-completion new file mode 100644 index 0000000..4d1e435 --- /dev/null +++ b/shell/zsh-completion @@ -0,0 +1,63 @@ +#compdef lsinitcpio mkinitcpio + +_detect_kver() { + local __ kver_validator='^[[:digit:]]+(\.[[:digit:]]+)+' + offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1" 2>/dev/null) || return 1 + read kver __ < \ + <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null) + [[ $kver =~ $kver_validator ]] && printf "$kver" +} + +_find_kernel_versions() { + local -a version + local filedata + + for f in /boot/*; do + # only match regular files which pass validation + if [[ ! -L $f && -f $f ]] && kver=$(_detect_kver "$f"); then + version+=("$kver" "$f") + fi + done + + compadd ${(u)version} +} + +case $service in + lsinitcpio) + _arguments : \ + '(-a --analyze)'{-a,--analyze}'[analyze contents of image]' \ + '(-c --config)'{-c,--config}'[show configuration file image was built with]' \ + '(-l --list)'{-l,--list}'[list contents of the image (default)]' \ + '(-x --extract)'{-x,--extract}'[extract image to disk]' \ + '(-h --help)'{-h,--help}'[display this help]' \ + '(-n --nocolor)'{-n,--nocolor}'[disable colorized output]' \ + '(-V --version)'{-V,--version}'[display version information]' \ + '(-v --verbose)'{-v,--verbose}'[more verbose output]' \ + ':files:_files' + ;; + mkinitcpio) + _arguments : \ + '(-A --addhooks)'{-A,--addhooks}'[Add specified hooks, comma separated, to image]::usr hooks:_path_files -W /usr/lib/initcpio/install::lib hooks:_path_files -W /lib/initcpio/install' \ + '(-c --config)'{-c,--config}'[Use alternate config file. (default: /etc/mkinitcpio.conf)]:config files:_files' \ + '(-g --generate)'{-g,--generate}'[Generate cpio image and write to specified path]:config files:_files' \ + '(-H --hookhelp)'{-H,--hookhelp}'[Display help for given hook and exit]::usr hooks:_path_files -W /usr/lib/initcpio/install::lib hooks:_path_files -W /lib/initcpio/install' \ + '(-h --help)'{-h,--help}'[Display this message and exit]' \ + '(-k --kernel)'{-k,--kernel}'[Use specified kernel version]:kernel versions:_find_kernel_versions' \ + '(-L --listhooks)'{-L,--listhooks}'[List all available hooks]' \ + '(-M --automods)'{-M,--automods}'[Display modules found via autodetection]' \ + '(-n --nocolor)'{-n,--nocolor}'[Disable colorized output messages]' \ + '(-p --preset)'{-p,--preset}'[Build specified preset from /etc/mkinitcpio.d]:presets:_files -g "*(\:r)" -W /etc/mkinitcpio.d' \ + '(-r --moduleroot)'{-r,--moduleroot}'[Root directory for modules (default: /)]:directories:_files -/' \ + '(-S --skiphooks)'{-S,--skiphooks}'[Skip specified hooks, comma-separated, during build]::usr hooks:_path_files -W /usr/lib/initcpio/install::lib hooks:_path_files -W /lib/initcpio/install' \ + '(-s --save)'{-s,--save}'[Save build directory. (default: no)]' \ + '(-t --builddir)'{-t,--builddir}'[Use DIR as the temporary build directory]:directories:_files -/' \ + '(-V --version)'{-V,--version}'[Display version information and exit]' \ + '(-v --verbose)'{-v,--verbose}'[Verbose output (default: no)]' \ + '(-z --compress)'{-z,--compress}'[Use an alternate compressor on the image]' + ;; + *) + return 1; + ;; +esac + +# vim: set et ts=4 sw=4 ft=zsh: diff --git a/systemd/mkinitcpio-generate-shutdown-ramfs.service b/systemd/mkinitcpio-generate-shutdown-ramfs.service new file mode 100644 index 0000000..36c2508 --- /dev/null +++ b/systemd/mkinitcpio-generate-shutdown-ramfs.service @@ -0,0 +1,15 @@ +[Unit] +Description=Generate shutdown-ramfs +DefaultDependencies=no +Before=shutdown.target +ConditionFileIsExecutable=!/run/initramfs/shutdown + +[Service] +Type=oneshot +# /tmp could be umounted at this point +# use /run as temporary directory +Environment=TMPDIR=/run +ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -c /dev/null -d /run/initramfs + +[Install] +WantedBy=shutdown.target diff --git a/udev/01-memdisk.rules b/udev/01-memdisk.rules new file mode 100644 index 0000000..0a8fd7b --- /dev/null +++ b/udev/01-memdisk.rules @@ -0,0 +1,11 @@ +ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="mtdblock*", ATTRS{name}=="memdisk", ATTRS{type}=="ram", GOTO="memdisk_start" +GOTO="memdisk_end" + +LABEL="memdisk_start" + +SYMLINK+="memdisk" +IMPORT{builtin}="blkid" +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + +LABEL="memdisk_end" diff --git a/zsh-completion b/zsh-completion deleted file mode 100644 index 4d1e435..0000000 --- a/zsh-completion +++ /dev/null @@ -1,63 +0,0 @@ -#compdef lsinitcpio mkinitcpio - -_detect_kver() { - local __ kver_validator='^[[:digit:]]+(\.[[:digit:]]+)+' - offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1" 2>/dev/null) || return 1 - read kver __ < \ - <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null) - [[ $kver =~ $kver_validator ]] && printf "$kver" -} - -_find_kernel_versions() { - local -a version - local filedata - - for f in /boot/*; do - # only match regular files which pass validation - if [[ ! -L $f && -f $f ]] && kver=$(_detect_kver "$f"); then - version+=("$kver" "$f") - fi - done - - compadd ${(u)version} -} - -case $service in - lsinitcpio) - _arguments : \ - '(-a --analyze)'{-a,--analyze}'[analyze contents of image]' \ - '(-c --config)'{-c,--config}'[show configuration file image was built with]' \ - '(-l --list)'{-l,--list}'[list contents of the image (default)]' \ - '(-x --extract)'{-x,--extract}'[extract image to disk]' \ - '(-h --help)'{-h,--help}'[display this help]' \ - '(-n --nocolor)'{-n,--nocolor}'[disable colorized output]' \ - '(-V --version)'{-V,--version}'[display version information]' \ - '(-v --verbose)'{-v,--verbose}'[more verbose output]' \ - ':files:_files' - ;; - mkinitcpio) - _arguments : \ - '(-A --addhooks)'{-A,--addhooks}'[Add specified hooks, comma separated, to image]::usr hooks:_path_files -W /usr/lib/initcpio/install::lib hooks:_path_files -W /lib/initcpio/install' \ - '(-c --config)'{-c,--config}'[Use alternate config file. (default: /etc/mkinitcpio.conf)]:config files:_files' \ - '(-g --generate)'{-g,--generate}'[Generate cpio image and write to specified path]:config files:_files' \ - '(-H --hookhelp)'{-H,--hookhelp}'[Display help for given hook and exit]::usr hooks:_path_files -W /usr/lib/initcpio/install::lib hooks:_path_files -W /lib/initcpio/install' \ - '(-h --help)'{-h,--help}'[Display this message and exit]' \ - '(-k --kernel)'{-k,--kernel}'[Use specified kernel version]:kernel versions:_find_kernel_versions' \ - '(-L --listhooks)'{-L,--listhooks}'[List all available hooks]' \ - '(-M --automods)'{-M,--automods}'[Display modules found via autodetection]' \ - '(-n --nocolor)'{-n,--nocolor}'[Disable colorized output messages]' \ - '(-p --preset)'{-p,--preset}'[Build specified preset from /etc/mkinitcpio.d]:presets:_files -g "*(\:r)" -W /etc/mkinitcpio.d' \ - '(-r --moduleroot)'{-r,--moduleroot}'[Root directory for modules (default: /)]:directories:_files -/' \ - '(-S --skiphooks)'{-S,--skiphooks}'[Skip specified hooks, comma-separated, during build]::usr hooks:_path_files -W /usr/lib/initcpio/install::lib hooks:_path_files -W /lib/initcpio/install' \ - '(-s --save)'{-s,--save}'[Save build directory. (default: no)]' \ - '(-t --builddir)'{-t,--builddir}'[Use DIR as the temporary build directory]:directories:_files -/' \ - '(-V --version)'{-V,--version}'[Display version information and exit]' \ - '(-v --verbose)'{-v,--verbose}'[Verbose output (default: no)]' \ - '(-z --compress)'{-z,--compress}'[Use an alternate compressor on the image]' - ;; - *) - return 1; - ;; -esac - -# vim: set et ts=4 sw=4 ft=zsh: -- cgit v1.2.3-24-g4f1b