Files
udisks/source.sh
T
2025-10-15 13:56:54 +03:00

77 lines
2.6 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
# The prepare function is executed in the root of the temp directory
# This function is used for putting downloaded files to the correct location or applying patches
prepare() {
cd "$BPM_SOURCE"
NOCONFIGURE=1 ./autogen.sh
}
# The build function is executed in the source directory
# This function is used to compile the source code
build() {
./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--disable-static \
--enable-btrfs \
--enable-lvm2
# prevent overlinking due to libtool
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
}
# The check function is executed in the source directory
# This function is used to run tests to verify the package has been compiled correctly
check() {
make check
}
_pick() {
local p="$1" f d; shift
for f; do
[ -d "$BPM_WORKDIR"/output_"$p" ] || { echo "Split package $p not found"; exit 1; }
d="$BPM_WORKDIR"/output_"$p"/"${f#$BPM_OUTPUT}"
mkdir -p "$(dirname "$d")"
mv "$f" "$d"
rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
done
}
# The package function is executed in the source directory
# This function is used to move the compiled files into the output directory
package_udisks() {
make DESTDIR="$BPM_OUTPUT" install
cd "$BPM_OUTPUT"
# Move btrfs files into split package
_pick udisks-btrfs usr/lib/udisks2/modules/libudisks2_btrfs.so
_pick udisks-btrfs usr/lib/pkgconfig/udisks2-btrfs.pc
_pick udisks-btrfs usr/share/polkit-1/actions/org.freedesktop.UDisks2.btrfs.policy
# Move lvm files into split package
_pick udisks-lvm usr/lib/udisks2/modules/libudisks2_lvm2.so
_pick udisks-lvm usr/lib/pkgconfig/udisks2-lvm2.pc
_pick udisks-lvm usr/share/polkit-1/actions/org.freedesktop.UDisks2.lvm2.policy
# Install package license
install -Dm644 "$BPM_SOURCE"/COPYING "$BPM_OUTPUT"/usr/share/licenses/udisks/COPYING
}
package_udisks-btrfs() {
# Install package license
install -d "$BPM_OUTPUT"/usr/share/licenses/
ln -sf udisks "$BPM_OUTPUT"/usr/share/licenses/udisks-btrfs
}
package_udisks-lvm() {
# Install package license
install -d "$BPM_OUTPUT"/usr/share/licenses/
ln -sf udisks "$BPM_OUTPUT"/usr/share/licenses/udisks-lvm
}