hplip: prevent conflicts with the GUI package

The hplip-gui package uses the exact same files as the regular hplip
package, plus a few extra for the UI and three changes in the
configuration file. Rather than copy the entire package contents and
register conflict= and provides= to fool the package manager, we can
make hplip-gui depend on hplip and just manage a symlink between two
alternative configuration files.
This commit is contained in:
Andrew J. Hesford 2022-11-16 10:02:36 -05:00 committed by Andrew J. Hesford
parent 04aca67821
commit 316bc350dd
5 changed files with 66 additions and 17 deletions

5
srcpkgs/hplip/INSTALL Normal file
View File

@ -0,0 +1,5 @@
case "${ACTION}" in
post)
# Link to the no-GUI config if there is none
[ -e etc/hp/hplip.conf ] || ln -sf hplip-nogui.conf etc/hp/hplip.conf
esac

10
srcpkgs/hplip/REMOVE Normal file
View File

@ -0,0 +1,10 @@
case "${ACTION}" in
pre)
# Remove a configuration symlink if it points to the non-GUI config
if [ -L etc/hp/hplip.conf ]; then
case "$(readlink etc/hp/hplip.conf 2>/dev/null)" in
""|hplip-nogui.conf) rm etc/hp/hplip.conf ;;
esac
fi
esac

View File

@ -0,0 +1,7 @@
case "${ACTION}" in
post)
# Link to GUI config if there is none or it is a symlink
if [ ! -e etc/hp/hplip.conf ] || [ -L etc/hp/hplip.conf ]; then
ln -sf hplip-gui.conf etc/hp/hplip.conf
fi
esac

View File

@ -0,0 +1,18 @@
case "${ACTION}" in
pre)
# Handle the configuration symlink, if it points to the GUI config.
# The link will be replaced to the non-GUI config if that exists;
# otherwise, it will just be removed.
if [ -L etc/hp/hplip.conf ]; then
case "$(readlink etc/hp/hplip.conf 2>/dev/null)" in
""|hplip-gui.conf)
# Replace with no-gui symlink
if [ -e etc/hp/hplip-nogui.conf ]; then
ln -sf hplip-nogui.conf etc/hp/hplip.conf
else
rm etc/hp/hplip.conf
fi
;;
esac
fi
esac

View File

@ -1,7 +1,7 @@
# Template file for 'hplip' # Template file for 'hplip'
pkgname=hplip pkgname=hplip
version=3.22.6 version=3.22.6
revision=2 revision=3
build_style=gnu-configure build_style=gnu-configure
pycompile_dirs="usr/share/hplip" pycompile_dirs="usr/share/hplip"
# configure checks sys.version[:3] for Python versioning, so 3.10 becomes 3.1; # configure checks sys.version[:3] for Python versioning, so 3.10 becomes 3.1;
@ -22,7 +22,7 @@ configure_args="
--disable-imageProcessor-build --disable-imageProcessor-build
--with-mimedir=/usr/share/cups/mime --with-mimedir=/usr/share/cups/mime
am_cv_python_version=${py3_ver}" am_cv_python_version=${py3_ver}"
conf_files="/etc/hp/hplip.conf" conf_files="/etc/hp/hplip-nogui.conf"
make_dirs="/var/lib/hp 0755 root root" make_dirs="/var/lib/hp 0755 root root"
hostmakedepends="pkg-config automake libtool python3" hostmakedepends="pkg-config automake libtool python3"
makedepends="openssl-devel python3-devel libxml2-python3 cups-devel sane-devel makedepends="openssl-devel python3-devel libxml2-python3 cups-devel sane-devel
@ -37,7 +37,6 @@ homepage="https://developers.hp.com/hp-linux-imaging-and-printing"
changelog="https://developers.hp.com/hp-linux-imaging-and-printing/release_notes" changelog="https://developers.hp.com/hp-linux-imaging-and-printing/release_notes"
distfiles="${SOURCEFORGE_SITE}/hplip/hplip/${version}/hplip-${version}.tar.gz" distfiles="${SOURCEFORGE_SITE}/hplip/hplip/${version}/hplip-${version}.tar.gz"
checksum=27ed0d492febb0b47c656234820d3ce573b24ff5b62e3bf4b2c47f82868d6bb4 checksum=27ed0d492febb0b47c656234820d3ce573b24ff5b62e3bf4b2c47f82868d6bb4
conflicts="hplip-gui"
CFLAGS="-I${XBPS_CROSS_BASE}/usr/include/libusb-1.0 -I${XBPS_CROSS_BASE}/${py3_inc}" CFLAGS="-I${XBPS_CROSS_BASE}/usr/include/libusb-1.0 -I${XBPS_CROSS_BASE}/${py3_inc}"
@ -71,30 +70,40 @@ do_install() {
# remove systemd service file # remove systemd service file
rm -rf ${DESTDIR}/usr/lib/systemd rm -rf ${DESTDIR}/usr/lib/systemd
# save gui-version of hplip.conf # save gui-version of hplip.conf
cp -p ${DESTDIR}/etc/hp/hplip.conf /tmp/hplip.conf local _confdir="${DESTDIR}/etc/hp"
mv "${_confdir}/hplip.conf" "${_confdir}/hplip-gui.conf"
# adjust values to non-gui version # adjust values to non-gui version
sed -i ${PKGDESTDIR}/etc/hp/hplip.conf \ sed -e "s/\(gui-build=\).*/\1no/" \
-e "s/\(gui-build=\).*/\1no/" \ -e "s/\(ui-toolkit=\).*/\1no/" \
-e "s/\(ui-toolkit=\).*/\1no/" \ -e "s/\(qt5=\).*/\1no/" \
-e "s/\(qt5=\).*/\1no/" "${_confdir}/hplip-gui.conf" > "${_confdir}/hplip-nogui.conf"
# licenses # licenses
vlicense COPYING vlicense COPYING
vlicense copyright vlicense copyright
} }
hplip-gui_package() { hplip-gui_package() {
depends="python3-gobject python3-dbus desktop-file-utils depends="${sourcepkg}>=${version}_${revision} python3-gobject
foomatic-db foomatic-db-engine python3-distro python3-PyQt5-dbus" python3-dbus desktop-file-utils foomatic-db foomatic-db-engine
short_desc+=" (with GUI)" python3-distro python3-PyQt5-dbus"
conflicts="${sourcepkg}" short_desc+=" (GUI utilities)"
provides="${sourcepkg}-${version}_${revision}" python_version=3
conf_files="/etc/hp/hplip-gui.conf"
pkg_install() { pkg_install() {
vmove usr/bin/hp-toolbox local _app _apps
_apps="devicesettings faxsetup linefeedcal toolbox
print printsettings pqdiag uiscan wificonfig"
for _app in ${_apps}; do
vmove "usr/bin/hp-${_app}"
vmove "usr/share/hplip/${_app}.py"
done
vmove usr/share/applications vmove usr/share/applications
vmove usr/share/hplip/ui5 vmove usr/share/hplip/ui5
vmove usr/share/hplip/data/images vmove usr/share/hplip/data/images
cp -a ${DESTDIR}/. ${PKGDESTDIR}/
# restore gui-version of hplip.conf vmove etc/hp/hplip-gui.conf
mv /tmp/hplip.conf ${PKGDESTDIR}/etc/hp/
} }
} }