pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg_alternatives does not allow for comments in ALTERNATIVES file (and the fix for this)



Hi, everyone!

I recently discovered that the ALTERNATIVES files in pkgsrc packages' directories are not allowed to contain comments.

The fix is trivial. Here is the patch:

$ git diff .
diff --git a/pkgtools/pkg_alternatives/files/pkg_alternatives.sh b/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
index 56a19b10524..3d794ee83d2 100644
--- a/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
+++ b/pkgtools/pkg_alternatives/files/pkg_alternatives.sh
@@ -56,7 +56,7 @@ action_auto_package() {
     validate_package ${1}
     pkg=${PKG_DBDIR}/${1}*/+ALTERNATIVES
 
-    set -- $(cat ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
+    set -- $(grep -v -e '^[[:space:]]*#' ${pkg} | sed -e 's# #__dE/lImIt/Er__#g')
     while [ ${#} -gt 0 ]; do
         action_auto_wrapper ${1%%__dE/lImIt/Er__*}
         shift

Not sure if all platforms' grep is capable of understading extended regexp (-e). I checked Linux and DragonflyBSD only.
In any case, using extended regexp '^[[:space::]*#'  is not strictly necessary. 
if you want to only allow comments that start with # simple grep -v '^#' can be used.

Please review and consider committing it. Thanks a lot!

--
Aleksej Lebedev


Home | Main Index | Thread Index | Old Index