summaryrefslogtreecommitdiff
path: root/libraries/libvirt/libvirt.SlackBuild
blob: fbc0e960c352cb90a92541b811cf9a11b9ed0250 (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
166
167
168
169
#!/bin/bash

# Slackware build script for libvirt
# Written by Michal Bialozor <bialyy@o2.pl>
# Maintained by Robby Workman <rworkman@slackbuilds.org>

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=libvirt
VERSION=${VERSION:-8.0.0}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

VIRTGROUP=${VIRTGROUP:-users}

# Some optional dependencies checks
audit="dis" ; if pkg-config --exists audit ; then audit="en" ; fi
bash_completion="" ; if pkg-config --exists bash-completion ; then
  bash_completion="-Dbash_completion=enabled -Dbash_completion_dir=/usr/share/bash-completion/completions"
fi
libiscsi="dis" ; if pkg-config --exists libiscsi ; then libiscsi="en" ; fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
 -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
 -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

# we have sysctld files in /etc/sysctl.d
sed -i "s|prefix / 'lib' / 'sysctl.d'|sysconfdir / 'sysctl.d'|" src/remote/meson.build

patch -p1 < $CWD/use-virtgroup-in-polkit-rules.diff
sed -i -e "s,@VIRTGROUP@,$VIRTGROUP,g" src/remote/libvirtd.rules

# Since 5.10: "configure: error: Build directory must be different from source directory"
mkdir -p build
cd build
  CFLAGS="$SLKCFLAGS" \
  CXXFLAGS="$SLKCFLAGS" \
  meson .. \
    --buildtype=release \
    --infodir=/usr/info \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --localstatedir=/var \
    --mandir=/usr/man \
    --prefix=/usr \
    --sysconfdir=/etc \
    -Dqemu_group=$VIRTGROUP \
    $bash_completion \
    -Daudit=${audit}abled \
    -Dlibiscsi=${libiscsi}abled \
    -Dopenwsman=disabled \
    -Dapparmor=disabled \
    -Dselinux=disabled \
    -Dwireshark_dissector=disabled \
    -Ddriver_bhyve=disabled \
    -Ddriver_hyperv=disabled \
    -Ddriver_libxl=disabled \
    -Ddriver_vz=disabled \
    -Dsecdriver_apparmor=disabled \
    -Dsecdriver_selinux=disabled \
    -Dstorage_sheepdog=disabled \
    -Dstorage_vstorage=disabled \
    -Ddtrace=disabled \
    -Dinit_script=none
  "${NINJA:=ninja}"
  DESTDIR=$PKG $NINJA install
cd ..

# we don't have augeas
rm -fr $PKG/usr/share/augeas

# this tree is recreated when starting the daemon
rm -fR $PKG/var/run

# add an rc.libvirt to start/stop/restart the daemon
install -D -m 0755 $CWD/rc.libvirt $PKG/etc/rc.d/rc.libvirt.new

# we use $VIRTGROUP as our virtualization group, fix auth permissions, and
# consider the fact that by default we got no certs
sed -i \
  -e "s|^\#unix_sock_group\ =\ \"libvirt\"|unix_sock_group = \"$VIRTGROUP\"|" \
  -e "s|^\#unix_sock_rw_perms\ =\ \"0770\"|unix_sock_rw_perms = \"0770\"|" \
  -e "s|^\#auth_unix_ro.*|auth_unix_ro = \"none\"|" \
  -e "s|^\#auth_unix_rw.*|auth_unix_rw = \"none\"|" \
  -e "s|^\#listen_tls|listen_tls|" \
  $PKG/etc/libvirt/libvirtd.conf

# still, we use $VIRTGROUP as our virtualization group
sed -i \
  -e "s|^\#group\ =\ \"root\"|group = \"$VIRTGROUP\"|" \
  $PKG/etc/libvirt/qemu.conf

# disable seccomp support or else VMs won't start with new libvirt/qemu combo
# 20220212 bkw: this file doesn't exist if qemu wasn't installed. and
# since qemu isn't in REQUIRES, it's optional, so the build shouldn't fail.
if [ -e $PKG/etc/libvirt/qemu.conf ]; then
  sed -i  "s|^\#seccomp_sandbox = 1|seccomp_sandbox = 0|" \
    $PKG/etc/libvirt/qemu.conf
fi

find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
mv $PKG/usr/share/doc/$PRGNAM/* $PKG/usr/doc/$PRGNAM-$VERSION/
rm -fR $PKG/usr/share/doc
cp -a \
  *.rst COPYING* examples/polkit/* \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

# Don't clobber existing configuration files
for i in etc/libvirt etc/libvirt/nwfilter etc/libvirt/qemu/networks etc/logrotate.d etc/sasl2 etc/sysctl.d; do
  for j in $(ls -1 $PKG/$i); do
    if [ ! -d $PKG/$i/$j ]; then
      mv $PKG/$i/$j $PKG/$i/$j.new
      echo "config $i/$j.new" >> $PKG/install/doinst.sh
    fi
  done
done

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE