opkg: add a status flag to record if the package was automatically installed to
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:20:45 +0000 (04:20 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 04:20:45 +0000 (04:20 +0000)
      satisfy a dependency

git-svn-id: http://opkg.googlecode.com/svn/trunk@24 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

opkg_install.c
pkg.c
pkg.h
pkg_parse.c

index 242db59c617b6f6cf4b16437109354ea01d109d7..b278724a256e436122de3737b078172613984d22 100644 (file)
@@ -413,6 +413,9 @@ int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg)
              && (dep->state_status != SS_UNPACKED)) {
                opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_pkg \n",__FUNCTION__);
               err = opkg_install_pkg(conf, dep,0);
+              /* mark this package as having been automatically installed to
+               * satisfy a dependancy */
+              dep->auto_installed = 1;
               if (err) {
                    pkg_vec_free(depends);
                    return err;
diff --git a/pkg.c b/pkg.c
index 1202845e4fcd7d64601f70d0f315fb899490bcb5..fe9118f02ac5000027ea7a6aa8e6835f3d29576d 100644 (file)
--- a/pkg.c
+++ b/pkg.c
@@ -558,6 +558,13 @@ char * pkg_formatted_field(pkg_t *pkg, const char *field )
                    temp[0]='\0';
                    snprintf(temp, (strlen(pkg->architecture)+17), "Architecture: %s\n", pkg->architecture);
               }
+         } else if (strcasecmp(field, "Auto-Installed") == 0) {
+               /* Auto-Installed flag */
+               if (pkg->auto_installed) {
+                   char * s = "Auto-Installed: yes\n";
+                   temp = (char *)realloc(temp, strlen(s) + 1);
+                   strcpy (temp, s);
+               }
          } else {
               goto UNKNOWN_FMT_FIELD;
          }
@@ -1017,6 +1024,7 @@ void pkg_print_status(pkg_t * pkg, FILE * file)
      pkg_print_field(pkg, file, "Architecture");
      pkg_print_field(pkg, file, "Conffiles");
      pkg_print_field(pkg, file, "Installed-Time");
+     pkg_print_field(pkg, file, "Auto-Installed");
      fputs("\n", file);
 }
 
diff --git a/pkg.h b/pkg.h
index 665191b789422adcbb2e97f6adaf32b065ee5440..ffb969b613fc91f9b03691424870ae62ab2e6933 100644 (file)
--- a/pkg.h
+++ b/pkg.h
@@ -176,6 +176,10 @@ struct pkg
      int arch_priority;
 /* Adding this flag, to "force" opkg to choose a "provided_by_hand" package, if there are multiple choice */
      int provided_by_hand;
+
+     /* this flag specifies whether the package was installed to satisfy another
+      * package's dependancies */
+     int auto_installed;
 };
 
 pkg_t *pkg_new(void);
index da245ccbeff24ce1f8bec76ee4c2d06a705e78f1..d654e5dbad6170cc698e515d143a84cf8c4544b6 100644 (file)
@@ -267,6 +267,15 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest)
        case 'A':
            if(isGenericFieldType("Architecture:", *lines))
                pkg->architecture = parseGenericFieldType("Architecture", *lines);
+           else if(isGenericFieldType("Auto-Installed:", *lines)) {
+               char *auto_installed_value;
+               auto_installed_value = parseGenericFieldType("Auto-Installed:", *lines);
+               if (strcmp(auto_installed_value, "yes") == 0) {
+                   pkg->auto_installed = 1;
+               }
+               free(auto_installed_value);
+               pkg->architecture = parseGenericFieldType("Auto-Installed", *lines);
+           }
            break;
 
        case 'F':