Просмотр исходного кода

Add per-user configuration file

Wichert Akkerman лет назад: 25
Родитель
Сommit
ac6d78c8a1
4 измененных файлов с 20 добавлено и 0 удалено
  1. 4 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 8 0
      dselect/main.cc
  4. 7 0
      main/main.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+Sat Jul 14 23:35:57 CEST 2001 Wichert Akkerman <wakkerma@debian.org>
+
+  * dselect/main.cc, dpkg/main.c: add per-user configuration file
+
 Sat Jul 14 01:38:27 CEST 2001 Wichert Akkerman <wakkerma@debian.org>
 
   * Merge dselect patch from Joey Hess 

+ 1 - 0
debian/changelog

@@ -14,6 +14,7 @@ dpkg (1.10) unstable; urgency=low
   * dpkg-name(1) no longer mentions the non-existing dpkg(5) manpage.
     Closes: Bug#104214
   * Improve handling of Recommends and Suggests in dselect
+  * Add per-user configuration files. Closes: Bug#103845
 
 
  -- Wichert Akkerman <wakkerma@debian.org>  UNRELEASED

+ 8 - 0
dselect/main.cc

@@ -323,6 +323,7 @@ urqresult urq_quit(void) {
 
 int main(int, const char *const *argv) {
   jmp_buf ejbuf;
+  char *home, *homerc;
 
   setlocale(LC_ALL, "");
   bindtextdomain(PACKAGE, LOCALEDIR);
@@ -335,6 +336,12 @@ int main(int, const char *const *argv) {
   push_error_handler(&ejbuf,print_error_fatal,0);
 
   myfileopt(CONFIGDIR "/" DSELECT ".cfg", cmdinfos);
+  if ((home= getenv("HOME")) != NULL) {
+       homerc= (char*)malloc((strlen(home)+strlen("/." DSELECT ".cfg")+1)*sizeof(char));
+       sprintf(homerc, "%s/.%s.cfg", home, DSELECT);
+       myfileopt(homerc, cmdinfos);
+       free(homerc);
+  }
   myopt(&argv,cmdinfos);
 
   if (*argv) {
@@ -354,3 +361,4 @@ int main(int, const char *const *argv) {
   error_unwind(ehflag_normaltidy);
   return(0);
 }
+

+ 7 - 0
main/main.c

@@ -546,6 +546,7 @@ printf("line=`%*s'\n",(int)linevb.used,linevb.buf);
 int main(int argc, const char *const *argv) {
   jmp_buf ejbuf;
   static void (*actionfunction)(const char *const *argv);
+  char *home, *homerc;
 
   setlocale(LC_ALL, "");
   bindtextdomain(PACKAGE, LOCALEDIR);
@@ -559,6 +560,12 @@ int main(int argc, const char *const *argv) {
   umask(022); /* Make sure all our status databases are readable. */
  
   myfileopt(CONFIGDIR "/" DPKG ".cfg", cmdinfos);
+  if ((home= getenv("HOME")) != NULL) {
+       homerc= (char*)malloc((strlen(home)+strlen("/." DPKG ".cfg")+1)*sizeof(char));
+       sprintf(homerc, "%s/.%s.cfg", home, DPKG);
+       myfileopt(homerc, cmdinfos);
+       free(homerc);
+  }
   myopt(&argv,cmdinfos);
   if (!cipaction) badusage(_("need an action option"));