aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2009-09-09 21:59:28 -0400
committerJason Woodward2009-09-09 22:45:08 -0400
commitb09ce22916f6b2fed483cdb15bc48b4f7a839a4e (patch)
tree622c7b17c69daef671860778a05fb93e3553d586 /src
parent6f64cceaf84cfcad61735fe700fd04b6340aa353 (diff)
downloadslapt-get-b09ce22916f6b2fed483cdb15bc48b4f7a839a4e.tar.gz
added --filelist option using slapt_get_pkg_filelist
Diffstat (limited to 'src')
-rw-r--r--src/action.c45
-rw-r--r--src/action.h3
-rw-r--r--src/main.c13
-rw-r--r--src/main.h4
4 files changed, 63 insertions, 2 deletions
diff --git a/src/action.c b/src/action.c
index 9c9a070..ce2c963 100644
--- a/src/action.c
+++ b/src/action.c
@@ -813,3 +813,48 @@ void slapt_pkg_action_add_keys(const slapt_rc_config *global_config)
}
#endif
+
+void slapt_pkg_action_filelist( const char *pkg_name )
+{
+ slapt_regex_t *pkg_regex = NULL;
+ struct slapt_pkg_list *installed_pkgs = NULL;
+ slapt_pkg_info_t *pkg = NULL;
+ char *filelist = NULL;
+
+ installed_pkgs = slapt_get_installed_pkgs();
+ if ( installed_pkgs == NULL )
+ exit(EXIT_FAILURE);
+
+ if ((pkg_regex = slapt_init_regex(SLAPT_PKG_LOG_PATTERN)) == NULL)
+ exit(EXIT_FAILURE);
+
+ /* Use regex to see if they specified a particular version */
+ slapt_execute_regex(pkg_regex,pkg_name);
+
+ /* If so, parse it out and try to get that version only */
+ if ( pkg_regex->reg_return == 0 ) {
+ char *p_name,*p_version;
+
+ p_name = slapt_regex_extract_match(pkg_regex, pkg_name, 1);
+ p_version = slapt_regex_extract_match(pkg_regex, pkg_name, 2);
+
+ pkg = slapt_get_exact_pkg(installed_pkgs,p_name,p_version);
+
+ if ( pkg == NULL )
+ exit(EXIT_FAILURE);
+
+ free(p_name);
+ free(p_version);
+
+ } else {
+ pkg = slapt_get_newest_pkg(installed_pkgs,pkg_name);
+ if ( pkg == NULL )
+ exit(EXIT_FAILURE);
+ }
+
+ filelist = slapt_get_pkg_filelist(pkg);
+
+ printf("%s",filelist);
+
+ free(filelist);
+}
diff --git a/src/action.h b/src/action.h
index 2415fb5..8e5a270 100644
--- a/src/action.h
+++ b/src/action.h
@@ -21,3 +21,6 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config);
#ifdef SLAPT_HAS_GPGME
void slapt_pkg_action_add_keys(const slapt_rc_config *global_config);
#endif
+
+void slapt_pkg_action_filelist( const char *pkg_name );
+
diff --git a/src/main.c b/src/main.c
index a51b177..a63ac17 100644
--- a/src/main.c
+++ b/src/main.c
@@ -74,6 +74,7 @@ int main( int argc, char *argv[] )
#ifdef SLAPT_HAS_GPGME
{"add-keys", 0, 0, SLAPT_ADD_KEYS_OPT},
#endif
+ {"filelist", 0, 0, SLAPT_FILELIST},
{0, 0, 0, 0},
};
char *custom_rc_location = NULL;
@@ -204,6 +205,9 @@ int main( int argc, char *argv[] )
do_action = ADD_KEYS;
break;
#endif
+ case SLAPT_FILELIST:
+ do_action = FILELIST;
+ break;
default:
usage();
slapt_free_rc_config(initial_config);
@@ -260,9 +264,10 @@ int main( int argc, char *argv[] )
if (global_config->remove_obsolete == SLAPT_TRUE)
break;
- /* show and search must have arguments */
+ /* show, search, filelist must have arguments */
case SHOW:
case SEARCH:
+ case FILELIST:
if ( optind >= argc )
do_action = 0;
break;
@@ -398,6 +403,11 @@ int main( int argc, char *argv[] )
slapt_pkg_action_add_keys(global_config);
break;
#endif
+ case FILELIST:
+ while (optind < argc) {
+ slapt_pkg_action_filelist( argv[optind++] );
+ }
+ break;
case USAGE:
default:
printf("main.c(l.%d): This should never be reached\n", __LINE__);
@@ -424,6 +434,7 @@ void usage(void)
printf(" --install-set %s\n",gettext("[disk set(s)] - install specified disk set(s)"));
printf(" --remove %s\n",gettext("[pkg name(s)] - remove specified pkg(s)"));
printf(" --show %s\n",gettext("[pkg name] - show pkg description"));
+ printf(" --filelist %s\n",gettext("[pkg name] - show pkg installed files"));
printf(" --search %s\n",gettext("[expression] - search available pkgs"));
printf(" --list - %s\n",gettext("list pkgs"));
printf(" --available - %s\n",gettext("list available pkgs"));
diff --git a/src/main.h b/src/main.h
index 961325b..7609466 100644
--- a/src/main.h
+++ b/src/main.h
@@ -57,7 +57,8 @@ enum slapt_action {
#ifdef SLAPT_HAS_GPGME
ADD_KEYS,
#endif
- INSTALL_DISK_SET
+ INSTALL_DISK_SET,
+ FILELIST
};
#define SLAPT_UPDATE_OPT 'u'
@@ -93,6 +94,7 @@ enum slapt_action {
#ifdef SLAPT_HAS_GPGME
#define SLAPT_ADD_KEYS_OPT 'k'
#endif
+#define SLAPT_FILELIST 'f'
#define SLAPT_DO_NOT_UNLINK_BAD_FILES 1
#define SLACKWARE_EXTRA_TESTING_PASTURE_WORKAROUND 1