tech-pkg archive

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

Re: pkgsrc RC scripts



On Mon, Oct 19, 2009 at 04:37:01PM +0200, Joerg Sonnenberger wrote:
> > I've noted that some of the script templates in pkgsrc/mk/pkginstall are 
> > already setup to use varialbles passed to them, i.e.:
> > PKG_CREATE_USERGROUP, PKG_CONFIG, PKG_CONFIG_PERMS, PKG_RCD_SCRIPTS,
> > PKG_UPDATE_FONTS_DB, FONTS_VERBOSE, INFO_FILES_VERBOSE, PKG_REGISTER_SHELLS.
> 
> Exactly, as that is the way it gets the data from mk.conf too. If
> anything, it should query the variables explicitly, IMO.

Attached is a simple patch to allow just that.

Joerg
Index: admin/main.c
===================================================================
RCS file: 
/home/joerg/repo/netbsd/pkgsrc/pkgtools/pkg_install/files/admin/main.c,v
retrieving revision 1.57
diff -u -p -r1.57 main.c
--- admin/main.c        8 Oct 2009 16:16:12 -0000       1.57
+++ admin/main.c        19 Oct 2009 22:26:02 -0000
@@ -422,7 +422,12 @@ main(int argc, char *argv[])
                usage();
        }
 
-       pkg_install_config();
+       /*
+        * config-var is reading the config file implicitly,
+        * so skip it here.
+        */
+       if (strcasecmp(argv[0], "config-var") != 0)
+               pkg_install_config();
 
        if (use_default_sfx)
                (void) strlcpy(sfx, DEFAULT_SFX, sizeof(sfx));
Index: lib/parse-config.c
===================================================================
RCS file: 
/home/joerg/repo/netbsd/pkgsrc/pkgtools/pkg_install/files/lib/parse-config.c,v
retrieving revision 1.11
diff -u -p -r1.11 parse-config.c
--- lib/parse-config.c  15 Oct 2009 12:41:41 -0000      1.11
+++ lib/parse-config.c  19 Oct 2009 22:30:19 -0000
@@ -99,6 +99,7 @@ static struct config_variable {
        { "PKGVULNURL", &pkg_vulnerabilities_url },
        { "VERBOSE_NETIO", &verbose_netio },
        { "VERIFIED_INSTALLATION", &verified_installation },
+       { NULL, NULL }, /* For use by pkg_install_show_variable */
        { NULL, NULL }
 };
 
@@ -198,11 +199,19 @@ void
 pkg_install_show_variable(const char *var_name)
 {
        struct config_variable *var;
+       const char *tmp_value = NULL;
 
        for (var = config_variables; var->name != NULL; ++var) {
-               if (strcmp(var->name, var_name) != 0)
-                       continue;
-               if (*var->var != NULL)
-                       puts(*var->var);
+               if (strcmp(var->name, var_name) == 0)
+                       break;
+       }
+       if (var->name == NULL) {
+               var->name = var_name;
+               var->var = &tmp_value;
        }
+
+       pkg_install_config();
+
+       if (*var->var != NULL)
+               puts(*var->var);
 }


Home | Main Index | Thread Index | Old Index