Details
-
Type:
Bug
-
Status: Open
-
Priority:
Medium
-
Resolution: Unresolved
-
Affects Version/s: master, 3.7.4
-
Fix Version/s: None
-
Component/s: package_module: pkgsrc, Promise type: packages
-
Labels:None
-
Environment:installation of packages using pkgsrc from cfengine
Description
Here I send a fix for three problems I have found:
- The version "latest" doesn't work with the module pkgsrc.
- The pkgsrc module uses read -r u 0 instead of read -r. "-u 0" option isn't supported by NetBSD 7.0 (the most used platform in pkgsrc). I think that -u 0 (read from std input) is the default behavior, and it isn't harmful to remove this option.
DONE in
CFE-3151
- The "options" doesn't work for me using whitespaces on Solaris 11.3 SPARC. I had to prefix them with "\", and it was awful. Now I can use by example:
options =>
{ "export PKG_REPOS=http://12.11.155.170/packages" }
, or:
options =>
{ "export http_proxy=http://10.191.55.101:8080" }
I think that the problem with the previous implementation of option is that options is passed as: options='export PKG_REPOS=http://12.11.155.170/packages', eval removes the simple quotes (eval I think that needs double quotation for work properly), and It leaves as: eval options=export PKG_REPOS=http://12.11.155.170/packages. At the end it executes only export instead of "export PKG...." and giving a syntax error
Patch:
pc2$ diff -u pkgsrc.orig pkgsrc — pkgsrc.orig 2016-09-19 23:09:01.000000000 +0200 +++ pkgsrc 2016-09-19 23:10:55.000000000 +0200 pc2$ diff -u pkgsrc.orig pkgsrc — pkgsrc.orig 2016-09-19 23:09:01.000000000 +0200 +++ pkgsrc 2016-09-19 23:10:55.000000000 +0200 @@ -10@@ -102,6 +98,9 @@ # or version, return nothing. # There's possibly a bug here because we're already emitting that the # PackageType is repo. + if [ "$Version" = "latest" ]; then + Version="" + fi parse_pkg_data "$(pkgin -pP avail | grep "^${File}-" | grep "$Version;" | sort -n | tail -1)" | grep Name fi } @@ -140,13 +139,16 @@ } # Cfengine passes data on STDIN. Absorb that and convert to shell variables. -while IFS= read -r -u 0 line; do +while IFS= read -r line; do eval "$line" + IFS="=" read options command << _EOF_ +$line +_EOF_ # options can be passed multiple times so we need to avoid clobbering # previous instances. Plus, what we really want to eval is the value of # each option. - if [ -n "$options" ]; then - eval "$options" + if [ "$options" = "options" ]; then + eval "$command" fi done 2,6 +98,9 @@ # or version, return nothing. # There's possibly a bug here because we're already emitting that the # PackageType is repo. + if [ "$Version" = "latest" ]; then + Version="" + fi parse_pkg_data "$(pkgin -pP avail | grep "^${File}-" | grep "$Version;" | sort -n | tail -1)" | grep Name fi } @@ -140,13 +139,16 @@ } # Cfengine passes data on STDIN. Absorb that and convert to shell variables. -while IFS= read -r -u 0 line; do +while IFS= read -r line; do eval "$line" + IFS="=" read options command << _EOF_ +$line +_EOF_ # options can be passed multiple times so we need to avoid clobbering # previous instances. Plus, what we really want to eval is the value of # each option. - if [ -n "$options" ]; then - eval "$options" + if [ "$options" = "options" ]; then + eval "$command" fi done