summaryrefslogtreecommitdiff
path: root/pcr/apparmor/PKGBUILD
blob: def30d3e498ec7d70256fcacce467b266eeb865b (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Maintainer: David P. <megver83@parabola.nu>
# Contributor: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: Marcin Wieczorek <marcin@marcin.co>
# Contributor: Thomas Kuther <archlinux@kuther.net>
# Contributor: Gianni Vialetto <gianni at rootcube dot net>
# Contributor: Paul N. Maxwell <msg dot maxwel at gmail dot com>
# Contributor: Thomas Mudrunka <harvie@@email..cz>
# Contributor: Max Fierke <max@maxfierke.com>

pkgbase=apparmor
pkgname=($pkgbase apparmor-parser apparmor-libapparmor apparmor-utils apparmor-profiles apparmor-pam apparmor-vim)
pkgver=2.11.0
#_majorver=${pkgver%.*}  # bleh, AUR...
_majorver=2.11
pkgrel=1
pkgdesc='Linux application security framework - mandatory access control for programs'
arch=('i686' 'x86_64')
license=('GPL')
url='http://wiki.apparmor.net/index.php/Main_Page'
makedepends=('flex' 'swig' 'perl' 'python' 'perl-locale-gettext' 'perl-rpc-xml' 'audit')

source=(https://launchpad.net/$pkgname/${_majorver}/${_majorver}/+download/${pkgname}-${pkgver}.tar.gz{,.asc}
        "apparmor_load.sh"
        "apparmor_unload.sh"
        "apparmor.service")

sha256sums=('b1c489ea11e7771b8e6b181532cafbf9ebe6603e3cb00e2558f21b7a5bdd739a'
            'SKIP'
            '124300162dab2a923c024b91c5a977dbee901376a22eefc64cad2f91319876d5'
            '9704478ae13fe1c3fb2747afac86c31b1b4593493f0e1425ae2b77d47878e32e'
            'eea47ec2a3fb0c1104193bed91586cfccda745f2e0a473f6d1d2a0d2fe42c413')

# 3D3664BB: AppArmor Development Team (AppArmor signing key) <apparmor@lists.ubuntu.com>
validpgpkeys=('3ECDCBA5FB34D254961CC53F6689E64E3D3664BB')

#Configuration
core_perl_dir='/usr/bin/core_perl'
export MAKEFLAGS+=" POD2MAN=${core_perl_dir}/pod2man"
export MAKEFLAGS+=" POD2HTML=${core_perl_dir}/pod2html"
export MAKEFLAGS+=" PODCHECKER=${core_perl_dir}/podchecker"
export MAKEFLAGS+=" PROVE=${core_perl_dir}/prove"
export MAKEFLAGS+=" PYTHON=python3"


prepare() {
  cd "${srcdir}/${pkgbase}-${pkgver}/parser"
  # avoid depend on texlive-latex
  sed -i -e 's/pdflatex/true/g' Makefile

  cd "${srcdir}/${pkgbase}-${pkgver}/utils"
  # Set Arch paths
  sed -e '/logfiles/ s/syslog /syslog.log /g' \
      -e '/logfiles/ s/messages/messages.log/g' \
      -e '/parser/ s# /sbin/# /usr/bin/#g' \
      -i logprof.conf
  # do not build/install vim file with utils package (causes ref to $srcdir and wrong location)
  sed -i '/vim/d' Makefile

  cd "${srcdir}/${pkgbase}-${pkgver}/profiles/apparmor.d"
  # /usr merge vs. profiles
  for i in `find . -name "*sbin*"`; do sed -i -e 's@sbin@bin@g' ${i} && mv ${i} ${i/sbin/bin}; done
  for i in klogd ping syslog-ng syslogd; do
    sed -e "s@/bin/${i}@/usr/bin/${i}@g" \
        -e "s@bin\.${i}@usr\.bin\.${i}@g" \
        -i bin.${i} && \
    mv bin.${i} usr.bin.${i}
  done
}

build() {
  msg2 "Building: apparmor-libapparmor"
  cd "${srcdir}/${pkgbase}-${pkgver}/libraries/libapparmor"
  unset PERL_MM_OPT
  NOCONFIGURE=1 ./autogen.sh
  ./configure --prefix=/usr --sbindir=/usr/bin --with-perl --with-python
  make

  cd "${srcdir}/${pkgbase}-${pkgver}"
  msg2 "Building: apparmor-parser"
  make -C parser

  msg2 "Building: apparmor-utils"
  make -C utils

  msg2 "Building: apparmor-profiles"
  make -C profiles

  msg2 "Building: apparmor-pam"
  make -C changehat/pam_apparmor

  msg2 "Building: apparmor-vim"
  make -C utils/vim -j1
}

package_apparmor() {
  pkgdesc='Linux application security framework - mandatory access control for programs (metapackage)'
  depends=(apparmor-parser apparmor-libapparmor apparmor-utils apparmor-profiles apparmor-pam apparmor-vim)
  optdepends=('linux-apparmor: an arch kernel with AppArmor patches')
  install='apparmor.install'
}

package_apparmor-parser() {
  pkgdesc='AppArmor parser - loads AA profiles to kernel module'
  depends=('apparmor-libapparmor')

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make -C parser install DESTDIR=${pkgdir}
  mv "${pkgdir}/lib" "${pkgdir}/usr/lib"
  mv "${pkgdir}/sbin" "${pkgdir}/usr/bin"
}

package_apparmor-libapparmor() {
  pkgdesc='AppArmor library'
  makedepends=('swig' 'perl' 'python')
  depends=('python')

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make -C libraries/libapparmor install DESTDIR="${pkgdir}"
  install -D -m644 "libraries/libapparmor/swig/perl/LibAppArmor.pm" "${pkgdir}/usr/lib/perl5/vendor_perl/"
}

package_apparmor-utils() {
  pkgdesc='AppArmor userspace utilities'
  depends=('perl' 'perl-locale-gettext' 'perl-term-readkey'
    'perl-file-tail' 'perl-rpc-xml' 'python')
  install='apparmor-utils.install'

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make -C utils install DESTDIR="${pkgdir}" BINDIR="${pkgdir}/usr/bin"
  install -D -m755 "${srcdir}/apparmor_load.sh" "${pkgdir}/usr/bin/apparmor_load.sh"
  install -D -m755 "${srcdir}/apparmor_unload.sh" "${pkgdir}/usr/bin/apparmor_unload.sh"
  install -D -m644 "${srcdir}/apparmor.service" "${pkgdir}/usr/lib/systemd/system/apparmor.service"
}

package_apparmor-profiles() {
  pkgdesc='AppArmor sample pre-made profiles'
  depends=(apparmor-parser)

  # backup /etc/apparmor.d/* so using logprof is safe
  cd "${srcdir}/${pkgbase}-${pkgver}/profiles/apparmor.d"
  declare -a _profiles=(`find -type f|sed 's@./@etc/apparmor.d/@'`)
  backup=(`echo ${_profiles[@]}`)

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make -C profiles install DESTDIR="${pkgdir}"
}

package_apparmor-pam() {
  pkgdesc='AppArmor PAM library'
  depends=('apparmor-libapparmor' 'pam')

  cd "${srcdir}/${pkgbase}-${pkgver}"
  make -C changehat/pam_apparmor install DESTDIR="${pkgdir}/usr"
  install -D -m644 changehat/pam_apparmor/README "${pkgdir}/usr/share/doc/apparmor/README.pam_apparmor"
}
package_apparmor-vim() {
  pkgdesc='AppArmor VIM support'
  depends=('vim')

  cd "${srcdir}/${pkgbase}-${pkgver}/utils/vim"
  install -D -m644 apparmor.vim \
    "${pkgdir}/usr/share/vim/vimfiles/syntax/apparmor.vim"
}

# vim:set ts=2 sw=2 et: