This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] cygport: PKG_OBSOLETES


I wanted to get feedback from those using cygport regarding a possible new feature: PKG_OBSOLETES. This is best explained with an example, so let's say I had the following:

NAME="libfoo"
...
PKG_NAMES="libfoo1 libfoo-bin libfoo-devel"
libfoo1_CONTENTS="usr/bin/cygfoo-1.dll"
libfoo_bin_CONTENTS="etc/ usr/bin/*.exe usr/share/doc/ usr/share/man/man[15]"
libfoo_devel_CONTENTS="usr/include/ usr/lib/ usr/share/man/man3/"

It then becomes apparent that libfoo-bin is a really bad name for a package, because people looking for the executables aren't finding an obvious match in the package list. Also, libfoo1 really needs those configuration files, so I decide to add a libfoo-common package, and rename libfoo-bin to foobar. Right now, I could do the following:

PKG_NAMES="libfoo1 libfoo-bin libfoo-common libfoo-devel foobar"
libfoo1_REQUIRES="libfoo-common"
libfoo1_CONTENTS="usr/bin/cygfoo-1.dll"
libfoo_common_CONTENTS="etc/ usr/share/doc/ usr/share/man/man5/"
libfoo_bin_CATEGORY="_obsolete"
libfoo_bin_REQUIRES="foobar"
libfoo_bin_SUMMARY="Obsolete package"
libfoo_bin_CONTENTS= # empty
libfoo_devel_CONTENTS="usr/include/ usr/lib/ usr/share/man/man3/"
foobar_CONTENTS="usr/bin/*.exe usr/share/man/man1/"

While that works, that's a lot of lines to handle an empty package. What PKG_OBSOLETES could do is make that much simpler:

PKG_NAMES="libfoo1 libfoo-common libfoo-devel foobar"
libfoo1_REQUIRES="libfoo-common"
libfoo1_CONTENTS="usr/bin/cygfoo-1.dll"
libfoo_common_CONTENTS="etc/ usr/share/doc/ usr/share/man/man5/"
libfoo_devel_CONTENTS="usr/include/ usr/lib/ usr/share/man/man3/"
foobar_OBSOLETES="libfoo-bin"
foobar_CONTENTS="usr/bin/*.exe usr/share/man/man1/"

The attached patch is what I'm working with at the moment.  Thoughts?


Yaakov
diff --git a/lib/pkg_pkg.cygpart b/lib/pkg_pkg.cygpart
index dc57b1d..2c9b1e4 100644
--- a/lib/pkg_pkg.cygpart
+++ b/lib/pkg_pkg.cygpart
@@ -471,7 +471,8 @@ __pkg_dist() {
 	local -a pkg_hint;
 	local distsubdir;
 	local pkg_category_var pkg_requires_var pkg_summary_var;
-	local pkg_description_var pkg_message_var;
+	local pkg_description_var pkg_message_var pkg_obsoletes_var;
+	local obspkg;
 
 	rm -fr ${distdir}/*;
 
@@ -592,7 +593,19 @@ __pkg_dist() {
 #    which are accessed by dlopen(), or data used by your package at runtime.
 #  * Any newlines in this variable must be escaped.
 #****
-
+#****v* Packaging/PKG_OBSOLETES
+#  DESCRIPTION
+#  A single-line string containing a list of package(s) which this
+#  package replaces.  An empty package will be created for each listed
+#  obsoletion which will cause PKG to be installed in its place.
+#
+#  Note that the PKG_REQUIRES name is descriptive rather than literal,
+#  where "PKG" should be substituted with the name of the binary package
+#  whose contents it describes.  When a package contains a character which
+#  cannot be used in a shell variable name (namely '+', '-', and '.'),
+#  that character must be substituted with an underscore ('_'), e.g.
+#  libfoo-devel will use libfoo_devel_OBSOLETES.
+#****
 	n=0;
 	while defined pkg_name[${n}]
 	do
@@ -601,6 +614,7 @@ __pkg_dist() {
 		pkg_summary_var=${pkg_name[${n}]//[-+\.]/_}_SUMMARY;
 		pkg_description_var=${pkg_name[${n}]//[-+\.]/_}_DESCRIPTION;
 		pkg_message_var=${pkg_name[${n}]//[-+\.]/_}_MESSAGE;
+		pkg_obsoletes_var=${pkg_name[${n}]//[-+\.]/_}_OBSOLETES;
 
 		case ${pkg_name[${n}]} in
 			${PN})  distsubdir="" ;;
@@ -649,6 +663,24 @@ _EOF
 			warning "${pkg_hint[${n}]%.hint}.hint is missing";
 		fi
 
+		for obspkg in ${!pkg_obsoletes_var}
+		do
+			mkdir -p ${distdir}/${PN}/${obspkg}
+			bzip2 < /dev/null > ${distdir}/${PN}/${obspkg}/${obspkg}-${PVR}.tar.bz2
+
+			__step "${pkg_name[${n}]} OBSOLETES: ${obspkg}"
+
+			cat > ${distdir}/${PN}/${obspkg}/setup.hint <<-_EOF
+category: _obsolete
+requires: ${pkg_name[${n}]}
+sdesc: "Obsoleted by ${pkg_name[${n}]}"
+ldesc: "The ${obspkg} package is obsolete.  Selecting this package for
+installation will cause the ${pkg_name[${n}]} package, which replaces this
+one, to be installed instead."
+external-source: ${PN}
+_EOF
+		done
+
 		n+=1;
 	done
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]