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

Make admindir file local everywhere

The interface to get and set the database directory is dpkg_db_get_dir()
and dpkg_db_set_dir().
Guillem Jover лет назад: 15
Родитель
Сommit
dcac09fade
11 измененных файлов с 16 добавлено и 14 удалено
  1. 0 1
      dselect/dselect.h
  2. 2 1
      dselect/main.cc
  3. 5 5
      dselect/method.cc
  4. 1 1
      src/divertcmd.c
  5. 1 0
      src/help.c
  6. 1 1
      src/main.c
  7. 0 1
      src/main.h
  8. 2 0
      src/processarc.c
  9. 1 1
      src/querycmd.c
  10. 2 2
      src/statcmd.c
  11. 1 1
      src/update.c

+ 0 - 1
dselect/dselect.h

@@ -148,7 +148,6 @@ void mywerase(WINDOW *win);
 void curseson();
 void cursesoff();
 
-extern const char *admindir;
 extern int expertmode;
 
 enum screenparts {

+ 2 - 1
dselect/main.cc

@@ -61,9 +61,10 @@ const char thisname[]= DSELECT;
 const char printforhelp[]= N_("Type dselect --help for help.");
 
 modstatdb_rw readwrite;
-const char *admindir= ADMINDIR;
 int expertmode= 0;
 
+static const char *admindir = ADMINDIR;
+
 static keybindings packagelistbindings(packagelist_kinterps,packagelist_korgbindings);
 
 struct table_t {

+ 5 - 5
dselect/method.cc

@@ -179,8 +179,8 @@ static urqresult runscript(const char *exepath, const char *name) {
     strcpy(coption->meth->pathinmeth,exepath);
 
     command_init(&cmd, coption->meth->path, name);
-    command_add_args(&cmd, exepath, admindir, coption->meth->name,
-                     coption->name, NULL);
+    command_add_args(&cmd, exepath, dpkg_db_get_dir(),
+                     coption->meth->name, coption->name, NULL);
     ur = falliblesubprocess(&cmd);
     command_destroy(&cmd);
   } else {
@@ -205,7 +205,7 @@ static urqresult rundpkgauto(const char *name, const char *dpkgmode) {
   struct command cmd;
 
   command_init(&cmd, DPKG, name);
-  command_add_args(&cmd, DPKG, "--admindir", admindir, "--pending",
+  command_add_args(&cmd, DPKG, "--admindir", dpkg_db_get_dir(), "--pending",
                    dpkgmode, NULL);
 
   cursesoff();
@@ -244,8 +244,8 @@ urqresult urq_setup(void) {
     strcpy(coption->meth->pathinmeth,METHODSETUPSCRIPT);
 
     command_init(&cmd, coption->meth->path, _("query/setup script"));
-    command_add_args(&cmd, METHODSETUPSCRIPT, admindir, coption->meth->name,
-                     coption->name, NULL);
+    command_add_args(&cmd, METHODSETUPSCRIPT, dpkg_db_get_dir(),
+                     coption->meth->name, coption->name, NULL);
     ur = falliblesubprocess(&cmd);
     command_destroy(&cmd);
     if (ur == urqr_normal) writecurrentopt();

+ 1 - 1
src/divertcmd.c

@@ -49,7 +49,7 @@
 const char thisname[] = "dpkg-divert";
 const char printforhelp[] = N_("Use --help for help about querying packages.");
 
-const char *admindir;
+static const char *admindir;
 
 static bool opt_pkgname_match_any = true;
 static const char *opt_pkgname = NULL;

+ 1 - 0
src/help.c

@@ -180,6 +180,7 @@ force_conflicts(struct deppossi *possi)
 static const char *
 preexecscript(struct command *cmd)
 {
+  const char *admindir = dpkg_db_get_dir();
   size_t instdirl = strlen(instdir);
 
   if (*instdir) {

+ 1 - 1
src/main.c

@@ -189,7 +189,7 @@ int fc_unsafe_io = 0;
 int fc_badverify = 0;
 
 int errabort = 50;
-const char *admindir= ADMINDIR;
+static const char *admindir = ADMINDIR;
 const char *instdir= "";
 struct pkg_list *ignoredependss = NULL;
 

+ 0 - 1
src/main.h

@@ -136,7 +136,6 @@ extern int fc_unsafe_io;
 
 extern bool abort_processing;
 extern int errabort;
-extern const char *admindir;
 extern const char *instdir;
 extern struct pkg_list *ignoredependss;
 extern const char native_arch[];

+ 2 - 0
src/processarc.c

@@ -383,6 +383,8 @@ void process_archive(const char *filename) {
 
     free(tmpdir);
   } else {
+    const char *admindir = dpkg_db_get_dir();
+
     /* We want it to be on the same filesystem so that we can
      * use rename(2) to install the postinst &c. */
     if (!cidir)

+ 1 - 1
src/querycmd.c

@@ -652,7 +652,7 @@ usage(const struct cmdinfo *ci, const char *value)
 const char thisname[]= "dpkg-query";
 const char printforhelp[]= N_("Use --help for help about querying packages.");
 
-const char *admindir;
+static const char *admindir;
 
 /* This table has both the action entries in it and the normal options.
  * The action entries are made with the ACTION macro, as they all

+ 2 - 2
src/statcmd.c

@@ -99,7 +99,7 @@ usage(const struct cmdinfo *cip, const char *value)
 	exit(0);
 }
 
-const char *admindir;
+static const char *admindir;
 
 static int opt_verbose = 1;
 static int opt_force = 0;
@@ -224,7 +224,7 @@ statdb_write(void)
 	if (rename(dbname_new, dbname))
 		ohshite(_("error installing new statoverride"));
 
-	dir_sync_path(admindir);
+	dir_sync_path(dpkg_db_get_dir());
 
 	free(dbname);
 	free(dbname_new);

+ 1 - 1
src/update.c

@@ -54,7 +54,7 @@ void updateavailable(const char *const *argv) {
   }
 
   if (!f_noact) {
-    if (access(admindir,W_OK)) {
+    if (access(dpkg_db_get_dir(), W_OK)) {
       if (errno != EACCES)
         ohshite(_("unable to access dpkg status area for bulk available update"));
       else