summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-03-09 17:00:32 +0000
committerJason Woodward2005-03-09 17:00:32 +0000
commit6a5f1d60f2286179f14fff4af0217e2f9b1083e7 (patch)
treebc04c6926f6d6a5d2b5a1c4830d327aced07ac43 /src
parent9393d75f466445c1cc41239b28cce4c87f64068d (diff)
downloadslapt-get-6a5f1d60f2286179f14fff4af0217e2f9b1083e7.tar.gz
added --available option to only show packages available from the current sources. --list shows available and installed. --installed shows only the installed with a new output format.
Diffstat (limited to 'src')
-rw-r--r--src/action.c90
-rw-r--r--src/action.h3
-rw-r--r--src/main.c14
-rw-r--r--src/main.h3
4 files changed, 54 insertions, 56 deletions
diff --git a/src/action.c b/src/action.c
index e355a50..7c94e84 100644
--- a/src/action.c
+++ b/src/action.c
@@ -142,7 +142,7 @@ void pkg_action_install(const rc_config *global_config,const pkg_action_args_t *
}
/* list pkgs */
-void pkg_action_list(void){
+void pkg_action_list(const int show){
struct pkg_list *pkgs = NULL;
struct pkg_list *installed_pkgs = NULL;
unsigned int i;
@@ -150,45 +150,52 @@ void pkg_action_list(void){
pkgs = get_available_pkgs();
installed_pkgs = get_installed_pkgs();
- for(i = 0; i < pkgs->pkg_count; i++ ){
- /* this should eliminate the printing of updates */
- if( strstr(pkgs->pkgs[i]->description,"no description") == NULL ){
- unsigned int bool_installed = 0;
- char *short_description = gen_short_pkg_description(pkgs->pkgs[i]);
-
- /* is it installed? */
- if( get_exact_pkg(installed_pkgs,pkgs->pkgs[i]->name,pkgs->pkgs[i]->version) != NULL )
- bool_installed = 1;
-
- printf("%s %s [inst=%s]: %s\n",
- pkgs->pkgs[i]->name,
- pkgs->pkgs[i]->version,
- bool_installed == 1
+ if( show == LIST || show == AVAILABLE ){
+ for(i = 0; i < pkgs->pkg_count; i++ ){
+ /* this should eliminate the printing of updates */
+ if( strstr(pkgs->pkgs[i]->description,"no description") == NULL ){
+ unsigned int bool_installed = 0;
+ char *short_description = gen_short_pkg_description(pkgs->pkgs[i]);
+
+ /* is it installed? */
+ if( get_exact_pkg(installed_pkgs,pkgs->pkgs[i]->name,pkgs->pkgs[i]->version) != NULL )
+ bool_installed = 1;
+
+ printf("%s %s [inst=%s]: %s\n",
+ pkgs->pkgs[i]->name,
+ pkgs->pkgs[i]->version,
+ bool_installed == 1
? _("yes")
: _("no"),
- (short_description == NULL) ? "" : short_description
- );
- free(short_description);
+ (short_description == NULL) ? "" : short_description
+ );
+ free(short_description);
+ }
}
}
- for(i = 0; i < installed_pkgs->pkg_count;++i){
- char *short_description = NULL;
- if( get_exact_pkg(pkgs,
- installed_pkgs->pkgs[i]->name,
- installed_pkgs->pkgs[i]->version
- ) != NULL
- ) continue;
-
- short_description = gen_short_pkg_description(installed_pkgs->pkgs[i]);
+ if( show == LIST || show == INSTALLED ){
+ for(i = 0; i < installed_pkgs->pkg_count;++i){
+ char *short_description = NULL;
+
+ if( show == LIST ){
+ if( get_exact_pkg(pkgs,
+ installed_pkgs->pkgs[i]->name,
+ installed_pkgs->pkgs[i]->version
+ ) != NULL
+ ) continue;
+ }
- printf("%s %s [inst=%s]: %s\n",
- installed_pkgs->pkgs[i]->name,
- installed_pkgs->pkgs[i]->version,
- _("yes"),
- (short_description == NULL) ? "" : short_description
- );
+ short_description = gen_short_pkg_description(installed_pkgs->pkgs[i]);
+
+ printf("%s %s [inst=%s]: %s\n",
+ installed_pkgs->pkgs[i]->name,
+ installed_pkgs->pkgs[i]->version,
+ _("yes"),
+ (short_description == NULL) ? "" : short_description
+ );
free(short_description);
+ }
}
free_pkg_list(pkgs);
@@ -196,23 +203,6 @@ void pkg_action_list(void){
}
-/* list installed pkgs */
-void pkg_action_list_installed(void){
- unsigned int i;
- struct pkg_list *installed_pkgs = NULL;
-
- installed_pkgs = get_installed_pkgs();
-
- for(i = 0; i < installed_pkgs->pkg_count; i++ ){
- printf("%s - %s\n",
- installed_pkgs->pkgs[i]->name,
- installed_pkgs->pkgs[i]->version
- );
- }
-
- free_pkg_list(installed_pkgs);
-}
-
/* remove/uninstall pkg */
void pkg_action_remove(const rc_config *global_config,const pkg_action_args_t *action_args){
unsigned int i;
diff --git a/src/action.h b/src/action.h
index ce7395b..79e8f7d 100644
--- a/src/action.h
+++ b/src/action.h
@@ -25,8 +25,7 @@ pkg_action_args_t *init_pkg_action_args(int arg_count);
void free_pkg_action_args(pkg_action_args_t *paa);
void pkg_action_install(const rc_config *global_config,const pkg_action_args_t *action_args);
-void pkg_action_list(void);
-void pkg_action_list_installed(void);
+void pkg_action_list(const int show);
void pkg_action_remove(const rc_config *global_config,const pkg_action_args_t *action_args);
void pkg_action_search(const char *pattern);
void pkg_action_show(const char *pkg_name);
diff --git a/src/main.c b/src/main.c
index 3ce64da..3437c0b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -59,6 +59,7 @@ int main( int argc, char *argv[] ){
{"config",1, 0, CONFIG_OPT},
{"autoclean", 0, 0, AUTOCLEAN_OPT},
{"remove-obsolete", 0, 0, OBSOLETE_OPT},
+ {"available", 0, 0, AVAILABLE_OPT},
{0, 0, 0, 0},
};
@@ -180,6 +181,9 @@ int main( int argc, char *argv[] ){
case OBSOLETE_OPT: /* remove obsolete packages */
global_config->remove_obsolete = TRUE;
break;
+ case AVAILABLE_OPT: /* show available packages */
+ do_action = AVAILABLE;
+ break;
default:
usage();
free_rc_config(global_config);
@@ -262,10 +266,10 @@ int main( int argc, char *argv[] ){
pkg_action_upgrade_all(global_config);
break;
case LIST:
- pkg_action_list();
+ pkg_action_list(LIST);
break;
case INSTALLED:
- pkg_action_list_installed();
+ pkg_action_list(INSTALLED);
break;
case CLEAN:
/* clean out local cache */
@@ -278,6 +282,9 @@ int main( int argc, char *argv[] ){
case AUTOCLEAN:
purge_old_cached_pkgs(global_config, NULL, NULL);
break;
+ case AVAILABLE:
+ pkg_action_list(AVAILABLE);
+ break;
case USAGE:
default:
printf("main.c(l.%d): This should never be reached\n", __LINE__);
@@ -303,7 +310,8 @@ void usage(void){
printf(" --remove %s\n",_("[pkg name(s)] - remove specified pkg(s)"));
printf(" --show %s\n",_("[pkg name] - show pkg description"));
printf(" --search %s\n",_("[expression] - search available pkgs"));
- printf(" --list - %s\n",_("list available pkgs"));
+ printf(" --list - %s\n",_("list pkgs"));
+ printf(" --available - %s\n",_("list available pkgs"));
printf(" --installed - %s\n",_("list installed pkgs"));
printf(" --clean - %s\n",_("purge cached pkgs"));
printf(" --autoclean - %s\n",_("only purge cache of older, unreacheable pkgs"));
diff --git a/src/main.h b/src/main.h
index 5bf0665..eb7a385 100644
--- a/src/main.h
+++ b/src/main.h
@@ -45,7 +45,7 @@
enum action {
USAGE = 0, UPDATE, INSTALL, REMOVE, SHOW, SEARCH, UPGRADE,
- LIST, INSTALLED, CLEAN, SHOWVERSION, AUTOCLEAN
+ LIST, INSTALLED, CLEAN, SHOWVERSION, AUTOCLEAN, AVAILABLE
};
#define UPDATE_OPT 'u'
@@ -73,6 +73,7 @@ enum action {
#define CONFIG_OPT 'C'
#define AUTOCLEAN_OPT 'a'
#define OBSOLETE_OPT 'O'
+#define AVAILABLE_OPT 'A'
#define DEBUG 0
#define DO_NOT_UNLINK_BAD_FILES 1