Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] hplip: prevent conflicts with the GUI package
@ 2022-11-16 15:19 ahesford
  2022-11-17 18:54 ` [PR PATCH] [Updated] " ahesford
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ahesford @ 2022-11-16 15:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1849 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages hplip-sanity
https://github.com/void-linux/void-packages/pull/40559

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.

The only really sophisticated part is handling the configuration symlink when removing `hplip-gui`. Because a  user might remove the GUI package and want to keep the non-GUI version installed, the remove hook should detect whether a) it owns the existing symlink (*i.e.*, the link points at the GUI configuration) and b) whether the non-GUI configuration exists (in which case the link should be moved to the non-GUI config; otherwise, it should be removed). The rest of the hooks are very basic:
- `hplip` only claims the configuration symlink on installation if *no* valid configuration symlink exists, to avoid clobbering, *e.g.*, the existing GUI link on an upgrade.
- `hplip-gui` claims any configuration symlink (but leaves regular files alone) because a user installing the GUI package probably wants it to work.
- `hplip` just removes any configuration symlink it owns when the package is removed.

The removal hooks also treat a failure of `readlink` (which really ought to never happen) as if they "own" the symlink.

I've run through a few installation and removal cycles, and this seems to do what I expect.

A patch file from https://github.com/void-linux/void-packages/pull/40559.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-hplip-sanity-40559.patch --]
[-- Type: text/x-diff, Size: 5702 bytes --]

From b3c709a1898c3586155268c5384e26f7fe7c15dc Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 16 Nov 2022 10:02:36 -0500
Subject: [PATCH] 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.
---
 srcpkgs/hplip/INSTALL           |  5 +++++
 srcpkgs/hplip/REMOVE            | 10 ++++++++++
 srcpkgs/hplip/hplip-gui.INSTALL |  7 +++++++
 srcpkgs/hplip/hplip-gui.REMOVE  | 18 ++++++++++++++++++
 srcpkgs/hplip/template          | 31 +++++++++++++++----------------
 5 files changed, 55 insertions(+), 16 deletions(-)
 create mode 100644 srcpkgs/hplip/INSTALL
 create mode 100644 srcpkgs/hplip/REMOVE
 create mode 100644 srcpkgs/hplip/hplip-gui.INSTALL
 create mode 100644 srcpkgs/hplip/hplip-gui.REMOVE

diff --git a/srcpkgs/hplip/INSTALL b/srcpkgs/hplip/INSTALL
new file mode 100644
index 000000000000..a6b558e01ef5
--- /dev/null
+++ b/srcpkgs/hplip/INSTALL
@@ -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
diff --git a/srcpkgs/hplip/REMOVE b/srcpkgs/hplip/REMOVE
new file mode 100644
index 000000000000..0dc5ee37fe7f
--- /dev/null
+++ b/srcpkgs/hplip/REMOVE
@@ -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
diff --git a/srcpkgs/hplip/hplip-gui.INSTALL b/srcpkgs/hplip/hplip-gui.INSTALL
new file mode 100644
index 000000000000..5619d54d4f98
--- /dev/null
+++ b/srcpkgs/hplip/hplip-gui.INSTALL
@@ -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
diff --git a/srcpkgs/hplip/hplip-gui.REMOVE b/srcpkgs/hplip/hplip-gui.REMOVE
new file mode 100644
index 000000000000..9775a19b1f72
--- /dev/null
+++ b/srcpkgs/hplip/hplip-gui.REMOVE
@@ -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
diff --git a/srcpkgs/hplip/template b/srcpkgs/hplip/template
index 063581e4e899..31b4d6e665ec 100644
--- a/srcpkgs/hplip/template
+++ b/srcpkgs/hplip/template
@@ -1,7 +1,7 @@
 # Template file for 'hplip'
 pkgname=hplip
 version=3.22.6
-revision=2
+revision=3
 build_style=gnu-configure
 pycompile_dirs="usr/share/hplip"
 # configure checks sys.version[:3] for Python versioning, so 3.10 becomes 3.1;
@@ -22,7 +22,7 @@ configure_args="
  --disable-imageProcessor-build
  --with-mimedir=/usr/share/cups/mime
  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"
 hostmakedepends="pkg-config automake libtool python3"
 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"
 distfiles="${SOURCEFORGE_SITE}/hplip/hplip/${version}/hplip-${version}.tar.gz"
 checksum=27ed0d492febb0b47c656234820d3ce573b24ff5b62e3bf4b2c47f82868d6bb4
-conflicts="hplip-gui"
 
 CFLAGS="-I${XBPS_CROSS_BASE}/usr/include/libusb-1.0 -I${XBPS_CROSS_BASE}/${py3_inc}"
 
@@ -71,30 +70,30 @@ do_install() {
 	# remove systemd service file
 	rm -rf ${DESTDIR}/usr/lib/systemd
 	# 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
-	sed -i ${PKGDESTDIR}/etc/hp/hplip.conf \
-	 -e "s/\(gui-build=\).*/\1no/" \
-	 -e "s/\(ui-toolkit=\).*/\1no/" \
-	 -e "s/\(qt5=\).*/\1no/"
+	sed -e "s/\(gui-build=\).*/\1no/" \
+		-e "s/\(ui-toolkit=\).*/\1no/" \
+		-e "s/\(qt5=\).*/\1no/" \
+		"${_confdir}/hplip-gui.conf" > "${_confdir}/hplip-nogui.conf"
 	# licenses
 	vlicense COPYING
 	vlicense copyright
 }
 
 hplip-gui_package() {
-	depends="python3-gobject python3-dbus desktop-file-utils
-	 foomatic-db foomatic-db-engine python3-distro python3-PyQt5-dbus"
-	short_desc+=" (with GUI)"
-	conflicts="${sourcepkg}"
-	provides="${sourcepkg}-${version}_${revision}"
+	depends="${sourcepkg}>=${version}_${revision} python3-gobject
+	 python3-dbus desktop-file-utils foomatic-db foomatic-db-engine
+	 python3-distro python3-PyQt5-dbus"
+	short_desc+=" (GUI add-ons)"
+	python_version=3
+	conf_files="/etc/hp/hplip-gui.conf"
 	pkg_install() {
 		vmove usr/bin/hp-toolbox
 		vmove usr/share/applications
 		vmove usr/share/hplip/ui5
 		vmove usr/share/hplip/data/images
-		cp -a ${DESTDIR}/. ${PKGDESTDIR}/
-		# restore gui-version of hplip.conf
-		mv /tmp/hplip.conf ${PKGDESTDIR}/etc/hp/
+		vmove etc/hp/hplip-gui.conf
 	}
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PR PATCH] [Updated] hplip: prevent conflicts with the GUI package
  2022-11-16 15:19 [PR PATCH] hplip: prevent conflicts with the GUI package ahesford
@ 2022-11-17 18:54 ` ahesford
  2022-11-17 18:58 ` ahesford
  2022-12-02 19:19 ` [PR PATCH] [Merged]: " ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2022-11-17 18:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages hplip-sanity
https://github.com/void-linux/void-packages/pull/40559

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.

The only really sophisticated part is handling the configuration symlink when removing `hplip-gui`. Because a  user might remove the GUI package and want to keep the non-GUI version installed, the remove hook should detect whether a) it owns the existing symlink (*i.e.*, the link points at the GUI configuration) and b) whether the non-GUI configuration exists (in which case the link should be moved to the non-GUI config; otherwise, it should be removed). The rest of the hooks are very basic:
- `hplip` only claims the configuration symlink on installation if *no* valid configuration symlink exists, to avoid clobbering, *e.g.*, the existing GUI link on an upgrade.
- `hplip-gui` claims any configuration symlink (but leaves regular files alone) because a user installing the GUI package probably wants it to work.
- `hplip` just removes any configuration symlink it owns when the package is removed.

The removal hooks also treat a failure of `readlink` (which really ought to never happen) as if they "own" the symlink.

I've run through a few installation and removal cycles, and this seems to do what I expect.

A patch file from https://github.com/void-linux/void-packages/pull/40559.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-hplip-sanity-40559.patch --]
[-- Type: text/x-diff, Size: 5936 bytes --]

From 5c2951845aaf302692ef4e4e80817b149c471485 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 16 Nov 2022 10:02:36 -0500
Subject: [PATCH] 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.
---
 srcpkgs/hplip/INSTALL           |  5 ++++
 srcpkgs/hplip/REMOVE            | 10 ++++++++
 srcpkgs/hplip/hplip-gui.INSTALL |  7 ++++++
 srcpkgs/hplip/hplip-gui.REMOVE  | 18 ++++++++++++++
 srcpkgs/hplip/template          | 43 ++++++++++++++++++++-------------
 5 files changed, 66 insertions(+), 17 deletions(-)
 create mode 100644 srcpkgs/hplip/INSTALL
 create mode 100644 srcpkgs/hplip/REMOVE
 create mode 100644 srcpkgs/hplip/hplip-gui.INSTALL
 create mode 100644 srcpkgs/hplip/hplip-gui.REMOVE

diff --git a/srcpkgs/hplip/INSTALL b/srcpkgs/hplip/INSTALL
new file mode 100644
index 000000000000..a6b558e01ef5
--- /dev/null
+++ b/srcpkgs/hplip/INSTALL
@@ -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
diff --git a/srcpkgs/hplip/REMOVE b/srcpkgs/hplip/REMOVE
new file mode 100644
index 000000000000..0dc5ee37fe7f
--- /dev/null
+++ b/srcpkgs/hplip/REMOVE
@@ -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
diff --git a/srcpkgs/hplip/hplip-gui.INSTALL b/srcpkgs/hplip/hplip-gui.INSTALL
new file mode 100644
index 000000000000..5619d54d4f98
--- /dev/null
+++ b/srcpkgs/hplip/hplip-gui.INSTALL
@@ -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
diff --git a/srcpkgs/hplip/hplip-gui.REMOVE b/srcpkgs/hplip/hplip-gui.REMOVE
new file mode 100644
index 000000000000..9775a19b1f72
--- /dev/null
+++ b/srcpkgs/hplip/hplip-gui.REMOVE
@@ -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
diff --git a/srcpkgs/hplip/template b/srcpkgs/hplip/template
index 063581e4e899..16c186f378a1 100644
--- a/srcpkgs/hplip/template
+++ b/srcpkgs/hplip/template
@@ -1,7 +1,7 @@
 # Template file for 'hplip'
 pkgname=hplip
 version=3.22.6
-revision=2
+revision=3
 build_style=gnu-configure
 pycompile_dirs="usr/share/hplip"
 # configure checks sys.version[:3] for Python versioning, so 3.10 becomes 3.1;
@@ -22,7 +22,7 @@ configure_args="
  --disable-imageProcessor-build
  --with-mimedir=/usr/share/cups/mime
  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"
 hostmakedepends="pkg-config automake libtool python3"
 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"
 distfiles="${SOURCEFORGE_SITE}/hplip/hplip/${version}/hplip-${version}.tar.gz"
 checksum=27ed0d492febb0b47c656234820d3ce573b24ff5b62e3bf4b2c47f82868d6bb4
-conflicts="hplip-gui"
 
 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
 	rm -rf ${DESTDIR}/usr/lib/systemd
 	# 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
-	sed -i ${PKGDESTDIR}/etc/hp/hplip.conf \
-	 -e "s/\(gui-build=\).*/\1no/" \
-	 -e "s/\(ui-toolkit=\).*/\1no/" \
-	 -e "s/\(qt5=\).*/\1no/"
+	sed -e "s/\(gui-build=\).*/\1no/" \
+		-e "s/\(ui-toolkit=\).*/\1no/" \
+		-e "s/\(qt5=\).*/\1no/" \
+		"${_confdir}/hplip-gui.conf" > "${_confdir}/hplip-nogui.conf"
 	# licenses
 	vlicense COPYING
 	vlicense copyright
 }
 
 hplip-gui_package() {
-	depends="python3-gobject python3-dbus desktop-file-utils
-	 foomatic-db foomatic-db-engine python3-distro python3-PyQt5-dbus"
-	short_desc+=" (with GUI)"
-	conflicts="${sourcepkg}"
-	provides="${sourcepkg}-${version}_${revision}"
+	depends="${sourcepkg}>=${version}_${revision} python3-gobject
+	 python3-dbus desktop-file-utils foomatic-db foomatic-db-engine
+	 python3-distro python3-PyQt5-dbus"
+	short_desc+=" (GUI utilities)"
+	python_version=3
+	conf_files="/etc/hp/hplip-gui.conf"
 	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/hplip/ui5
 		vmove usr/share/hplip/data/images
-		cp -a ${DESTDIR}/. ${PKGDESTDIR}/
-		# restore gui-version of hplip.conf
-		mv /tmp/hplip.conf ${PKGDESTDIR}/etc/hp/
+
+		vmove etc/hp/hplip-gui.conf
 	}
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: hplip: prevent conflicts with the GUI package
  2022-11-16 15:19 [PR PATCH] hplip: prevent conflicts with the GUI package ahesford
  2022-11-17 18:54 ` [PR PATCH] [Updated] " ahesford
@ 2022-11-17 18:58 ` ahesford
  2022-12-02 19:19 ` [PR PATCH] [Merged]: " ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2022-11-17 18:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 408 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/40559#issuecomment-1319070074

Comment:
I moved every `usr/bin/hp*` strictly-GUI application and its corresponding script in `usr/share/hplip` to the `hplip-gui` package. These are clearly intended to be `__main__` entrypoints, so their absence from the `hplip` packge shouldn't break anything over there.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PR PATCH] [Merged]: hplip: prevent conflicts with the GUI package
  2022-11-16 15:19 [PR PATCH] hplip: prevent conflicts with the GUI package ahesford
  2022-11-17 18:54 ` [PR PATCH] [Updated] " ahesford
  2022-11-17 18:58 ` ahesford
@ 2022-12-02 19:19 ` ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2022-12-02 19:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]

There's a merged pull request on the void-packages repository

hplip: prevent conflicts with the GUI package
https://github.com/void-linux/void-packages/pull/40559

Description:
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.

The only really sophisticated part is handling the configuration symlink when removing `hplip-gui`. Because a  user might remove the GUI package and want to keep the non-GUI version installed, the remove hook should detect whether a) it owns the existing symlink (*i.e.*, the link points at the GUI configuration) and b) whether the non-GUI configuration exists (in which case the link should be moved to the non-GUI config; otherwise, it should be removed). The rest of the hooks are very basic:
- `hplip` only claims the configuration symlink on installation if *no* valid configuration symlink exists, to avoid clobbering, *e.g.*, the existing GUI link on an upgrade.
- `hplip-gui` claims any configuration symlink (but leaves regular files alone) because a user installing the GUI package probably wants it to work.
- `hplip` just removes any configuration symlink it owns when the package is removed.

The removal hooks also treat a failure of `readlink` (which really ought to never happen) as if they "own" the symlink.

I've run through a few installation and removal cycles, and this seems to do what I expect.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-02 19:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 15:19 [PR PATCH] hplip: prevent conflicts with the GUI package ahesford
2022-11-17 18:54 ` [PR PATCH] [Updated] " ahesford
2022-11-17 18:58 ` ahesford
2022-12-02 19:19 ` [PR PATCH] [Merged]: " ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).