summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 59ab51414a7ec5ad0bfbd394e899eadc4d04346d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com
# Contributor: Mathias Buren <mathias.buren@gmail.com>
# From core package
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Judd Vinet <jvinet@zeroflux.org>

set -u
_pkgname='mdadm'
pkgname="${_pkgname}-git"
pkgver=mdadm.3.3.3.r16.g53a087b
pkgrel=1
pkgdesc='create, manage, and monitor Linux md block device RAID arrays'
arch=('i686' 'x86_64')
license=('GPL')
url='http://neil.brown.name/blog/mdadm'
conflicts=('mkinitcpio<0.7' 'mdadm')
makedepends=('git')
depends=('linux' 'glibc')
backup=("etc/${_pkgname}.conf")
_archlink="@@@::https://projects.archlinux.org/svntogit/packages.git/plain/trunk/@@@?h=packages/${_pkgname}"
source=(# use either one, but not both. Reset with makepkg -sCf. My comparison shows these are identical, including the tags. Github is faster.
        #"mdadm_gitnb::git://neil.brown.name/${_pkgname}"
        "mdadm_github::git+https://github.com/neilbrown/${_pkgname}.git"
        "${_archlink//@@@/${_pkgname}.conf}"
        "${_archlink//@@@/${_pkgname}_install}"
        "${_archlink//@@@/${_pkgname}_udev_install}"
        "${_archlink//@@@/${_pkgname}_hook}")
install="${_pkgname}.install"
replaces=('raidtools')

sha256sums=('SKIP'
            '4ce1e90690282f98e4828e11576fbd61be65e97a2cdae6c7eac7035ea5ee53e5'
            '15bc46b9fa663dc204e2168861fabfd26e0dbcbb073792f271e3e4510897fb4e'
            '170b0e5d548416c0adb9df4e6941bea6bc33d843419c997e45ecaf9e36a58f38'
            'd297b4fa6213016ec08e4f66d07cf7eb03426e4e17ab31eddfa5c5c1d82ea294')

pkgver() {
  cd mdadm_git*/
  git describe --long | sed -e 's/\([^-]*-g\)/r\1/' -e 's/-/./g'
}

prepare() {
  set -u
  cd mdadm_git*/
  # 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
}

build() {
  set -u
  cd mdadm_git*/
  local _XFlags='-O' # -Wno-maybe-uninitialized' # uninitalized warnings are too dangerous to be hidden
  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 mkinitcpio hook mdadm. Hook mdadm_udev does not use mdassemble.
  make -s MDASSEMBLE_AUTO=1 mdassemble
  # 2015-08-02 https://github.com/neilbrown/mdadm/issues/10 mdassemble used by hook mdadm does not update the map file
  set +u
}

check() {
  set -u
  cd mdadm_git*/
  make -s test
  #sudo ./test # can't do sudo in a PKGBUILD
  set +u
}

package() {
  set -u
  cd mdadm_git*/
  make -s INSTALL='/usr/bin/install' BINDIR='/usr/bin' DESTDIR="${pkgdir}" UDEVDIR='/usr/lib/udev' install
  make -s SYSTEMD_DIR="${pkgdir}/usr/lib/systemd/system" install-systemd # does not honor silent -s
  install -Dpm755 'mdassemble' -t "${pkgdir}/usr/bin/"
  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}
  sed -i -e 's:#!/bin/sh:#!/usr/bin/sh:g' "${pkgdir}/usr/lib/systemd/system-shutdown/mdadm.shutdown"
  #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"; 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