Files
udev/source.sh
T

72 lines
3.8 KiB
Bash

# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
DOWNLOAD="https://github.com/systemd/systemd/archive/v${BPM_PKG_VERSION}/systemd-${BPM_PKG_VERSION}.tar.gz"
FILENAME="${DOWNLOAD##*/}"
# The prepare function is executed in the root of the temp directory
# This function is used for downloading files and putting them into the correct location
prepare() {
wget "$DOWNLOAD"
tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE"
cd "$BPM_SOURCE"
patch -Np1 -i "$BPM_WORKDIR"/fix-link-udev-shared.patch
}
# The build function is executed in the source directory
# This function is used to compile the source code
build() {
sed -i -e 's/GROUP="render"/GROUP="video"/' -e 's/GROUP="sgx", //' rules.d/50-udev-default.rules.in
sed '/systemd-sysctl/s/^/#/' -i rules.d/99-systemd.rules.in
sed '/NETWORK_DIRS/s/systemd/udev/' -i src/libsystemd/sd-network/network-util.h
mkdir build
cd build
meson setup --prefix=/usr \
--buildtype=release \
-Dmode=release \
-Ddev-kvm-mode=0660 \
-Dlink-udev-shared=false \
-Dlogind=false \
-Dvconsole=false .. \
export udev_helpers=$(grep "'name' :" ../src/udev/meson.build | awk '{print $3}' | tr -d ",'" | grep -v 'udevadm')
ninja udevadm systemd-hwdb \
$(ninja -n | grep -Eo '(src/(lib)?udev|rules.d|hwdb.d)/[^ ]*') \
$(realpath libudev.so --relative-to .) \
$udev_helpers
}
# The package function is executed in the source directory
# This function is used to move the compiled files into the output directory
package() {
cd build
export udev_helpers=$(grep "'name' :" ../src/udev/meson.build | awk '{print $3}' | tr -d ",'" | grep -v 'udevadm')
install -dm644 "$BPM_OUTPUT"/usr/{bin,sbin,lib,include}
install -dm644 "$BPM_OUTPUT"/usr/{lib,share}/pkgconfig
install -m755 -d "$BPM_OUTPUT"/{usr/lib,etc}/udev/{hwdb.d,rules.d,network}
install -m755 -d "$BPM_OUTPUT"/usr/{lib,share}/pkgconfig
install -m755 udevadm "$BPM_OUTPUT"/usr/bin/
install -m755 systemd-hwdb "$BPM_OUTPUT"/usr/bin/udev-hwdb
ln -sfn ../bin/udevadm "$BPM_OUTPUT"/usr/sbin/udevd
cp -a libudev.so{,*[0-9]} "$BPM_OUTPUT"/usr/lib/
install -m644 ../src/libudev/libudev.h "$BPM_OUTPUT"/usr/include/
install -m644 src/libudev/*.pc "$BPM_OUTPUT"/usr/lib/pkgconfig/
install -m644 src/udev/*.pc "$BPM_OUTPUT"/usr/share/pkgconfig/
install -m644 ../src/udev/udev.conf "$BPM_OUTPUT"/etc/udev/
install -m644 rules.d/* ../rules.d/README "$BPM_OUTPUT"/usr/lib/udev/rules.d/
install -m644 $(find ../rules.d/*.rules -not -name '*power-switch*') "$BPM_OUTPUT"/usr/lib/udev/rules.d/
install -m644 hwdb.d/* ../hwdb.d/{*.hwdb,README} "$BPM_OUTPUT"/usr/lib/udev/hwdb.d/
install -m755 $udev_helpers "$BPM_OUTPUT"/usr/lib/udev
install -m644 ../network/99-default.link "$BPM_OUTPUT"/usr/lib/udev/network
install -Dm644 "$BPM_WORKDIR"/udevd.esv "$BPM_OUTPUT"/etc/esvm/services/udevd.esv
install -Dm755 "$BPM_WORKDIR"/udevd.sh "$BPM_OUTPUT"/etc/esvm/scripts/udevd.sh
install -Dm644 "$BPM_WORKDIR"/udev-hwdb.bpmhook "$BPM_OUTPUT"/var/lib/bpm/hooks/udev-hwdb.bpmhook
install -Dm644 ../LICENSE.{GPL2,LGPL2.1} -t "$BPM_OUTPUT"/usr/share/licenses/udev/
}