summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Severance2015-08-04 03:34:28 -0400
committerChris Severance2015-08-04 03:34:28 -0400
commit25d098eed60e348733a3b89561e33b16d568dab5 (patch)
tree564290a7e2435681b26d54f8ad6094cb3bed69d0
parenta482519685ccf6bfd671f87ec5a198d0e85a7c0f (diff)
downloadaur-25d098eed60e348733a3b89561e33b16d568dab5.tar.gz
Seamless switch from mdadm
-rw-r--r--PKGBUILD32
-rw-r--r--mdadm.install20
2 files changed, 33 insertions, 19 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 1f6f22c466f8..59ab51414a7e 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -42,7 +42,8 @@ pkgver() {
prepare() {
set -u
cd mdadm_git*/
- sed -i -e 's: -Werror : :g' 'Makefile' # disable-werror.patch. NB strives for warning free code so this patch should not be necessary.
+ # NB strives for warning free code so this patch should not be necessary. Comment but don't erase it as it will be needed from time to time.
+ sed -i -e 's: -Werror : :g' 'Makefile' # disable-werror.patch.
sed -i -e 's:/usr/sbin/:/usr/bin:g' -e 's:/sbin:/usr/bin:g' 'Makefile' 'test' 'mkinitramfs' 'mdadm.conf.5'
set +u
}
@@ -54,10 +55,9 @@ build() {
CPPFLAGS+=" ${_XFlags}" # warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
CXXFLAGS+=" ${_XFlags}" # Despite claims in the Makefile, make CXFLAGS='-O' doesn't work.
make -s -j $(nproc) BINDIR='/usr/bin' UDEVDIR='/usr/lib/udev'
- # build static mdassemble for Arch's initramfs for use with (deprecated) mkinitcpio hook mdadm
+ # build static mdassemble for Arch's initramfs for use with mkinitcpio hook mdadm. Hook mdadm_udev does not use mdassemble.
make -s MDASSEMBLE_AUTO=1 mdassemble
- # https://github.com/neilbrown/mdadm/issues/10
- # mdassemble used by hook mdadm does not update the map file
+ # 2015-08-02 https://github.com/neilbrown/mdadm/issues/10 mdassemble used by hook mdadm does not update the map file
set +u
}
@@ -78,6 +78,10 @@ package() {
install -Dpm644 "${srcdir}/mdadm.conf" -t "${pkgdir}/etc/"
sed -i -e 's:/usr/sbin/:/usr/bin:g' "${pkgdir}/etc/mdadm.conf"
install -Dpm644 "${srcdir}/mdadm_install" "${pkgdir}/usr/lib/initcpio/install/mdadm"
+ # 2015-08-04 mdadm is required even when using mdassemble. This eliminates the need for adding mdadm to BINARIES="" in mkinitcpio.conf
+ if ! grep -q '/usr/bin/mdadm' "${pkgdir}/usr/lib/initcpio/install/mdadm"; then
+ sed -i -e 's:^\(\s\+\)\(add_binary \):\1\2"/usr/bin/mdadm"\n&:g' "${pkgdir}/usr/lib/initcpio/install/mdadm"
+ fi
install -Dpm644 "${srcdir}/mdadm_hook" "${pkgdir}/usr/lib/initcpio/hooks/mdadm"
install -Dpm644 "${srcdir}/mdadm_udev_install" "${pkgdir}/usr/lib/initcpio/install/mdadm_udev"
sed -i -e 's:#!/bin/bash:#!/usr/bin/bash:g' "${pkgdir}/usr/lib/initcpio/install"/{mdadm,mdadm_udev}
@@ -85,15 +89,15 @@ package() {
#ln -sf 'mdadm' "${pkgdir}/usr/lib/initcpio/hooks/raid" # symlink for backward compatibility
set +u
# Ensure there are no forbidden paths. Place at the end of package() and comment out as you find or need exceptions. (git-aurcheck)
- ! test -d "${pkgdir}/bin" || { echo "Line ${LINENO} Forbidden: /bin"; echo "${}"; }
- ! test -d "${pkgdir}/sbin" || { echo "Line ${LINENO} Forbidden: /sbin"; echo "${}"; }
- ! test -d "${pkgdir}/lib" || { echo "Line ${LINENO} Forbidden: /lib"; echo "${}"; }
- ! test -d "${pkgdir}/share" || { echo "Line ${LINENO} Forbidden: /share"; echo "${}"; }
- ! test -d "${pkgdir}/usr/sbin" || { echo "Line ${LINENO} Forbidden: /usr/sbin"; echo "${}"; }
- ! test -d "${pkgdir}/usr/local" || { echo "Line ${LINENO} Forbidden: /usr/local"; echo "${}"; }
- ! grep -lr "/sbin" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /sbin"; echo "${}"; }
- ! grep -lr "/usr/tmp" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /usr/tmp"; echo "${}"; }
- ! grep -lr "/usr/local" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /usr/local"; echo "${}"; }
- ! pcre2grep -Ilr "(?<!/usr)/bin" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /bin"; echo "${}"; }
+ ! test -d "${pkgdir}/bin" || { echo "Line ${LINENO} Forbidden: /bin"; false; }
+ ! test -d "${pkgdir}/sbin" || { echo "Line ${LINENO} Forbidden: /sbin"; false; }
+ ! test -d "${pkgdir}/lib" || { echo "Line ${LINENO} Forbidden: /lib"; false; }
+ ! test -d "${pkgdir}/share" || { echo "Line ${LINENO} Forbidden: /share"; false; }
+ ! test -d "${pkgdir}/usr/sbin" || { echo "Line ${LINENO} Forbidden: /usr/sbin"; false; }
+ ! test -d "${pkgdir}/usr/local" || { echo "Line ${LINENO} Forbidden: /usr/local"; false; }
+ ! grep -lr "/sbin" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /sbin"; false; }
+ ! grep -lr "/usr/tmp" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /usr/tmp"; false; }
+ ! grep -lr "/usr/local" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /usr/local"; false; }
+ ! pcre2grep -Ilr "(?<!/usr)/bin" "${pkgdir}" || { echo "Line ${LINENO} Forbidden: /bin"; false; }
}
set +u
diff --git a/mdadm.install b/mdadm.install
index 1a5d0eb6b447..25896f30be5c 100644
--- a/mdadm.install
+++ b/mdadm.install
@@ -7,11 +7,11 @@ post_upgrade() {
echo "raid_partitions hook has been replaced by the more powerfull mdadm hook."
echo "Please update your /etc/mkinitcpio.conf accordingly."
fi
- if [ -s '/etc/mkinitcpio.conf' ] && grep -q '^\s*HOOKS=".*\smdadm\s.*$' '/etc/mkinitcpio.conf'; then
- echo "Attention mdadm update:"
- echo "mdadm is deprecated for mdadm_udev"
- echo "Please update your /etc/mkinitcpio.conf accordingly."
- fi
+ #if [ -s '/etc/mkinitcpio.conf' ] && grep -q '^\s*HOOKS=".*\smdadm\s.*$' '/etc/mkinitcpio.conf'; then
+ # echo "Attention mdadm update:"
+ # echo "mdadm is deprecated for mdadm_udev"
+ # echo "Please update your /etc/mkinitcpio.conf accordingly."
+ #fi
if ! mdadm -D --scan >/dev/null; then
cat '/proc/mdstat'
tput 'rev'
@@ -22,4 +22,14 @@ post_upgrade() {
post_install() {
post_upgrade
+ # Moving from mdadm to mdadm-git doesn't count as an upgrade so pacman renames the config to pacsave.
+ # We'll restore it so that changing from mdadm -> mdadm-git will be seamless without having to repair a broken boot.
+ # This also works for remove and reinstall so long as you don't damage your system too much while mdadm is away.
+ # Unfortunately moving from mdadm-git back to mdadm won't be seamless unless that installer is fixed.
+ # We try our best to pick the file that has the arrays in it.
+ if [ -s '/etc/mdadm.conf.pacsave' ] && grep -q '^\s*ARRAY\s' '/etc/mdadm.conf.pacsave'; then
+ if [ ! -s '/etc/mdadm.conf' ] || ! grep -q '^\s*ARRAY\s' '/etc/mdadm.conf'; then
+ mv '/etc/mdadm.conf.pacsave' '/etc/mdadm.conf' && echo '/etc/mdadm.conf restored from /etc/mdadm.conf.pacsave'
+ fi
+ fi
}