summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-02-28 22:52:22 +0000
committerJason Woodward2005-02-28 22:52:22 +0000
commit90a5073fa32fc7f777ec2709591539cb4e559237 (patch)
tree56e9520042721f52cff8d267ebbd04c3c4bf0371 /src
parent64dda2e5670bf28b0b937011bebd4fca41d2db7e (diff)
downloadslapt-get-90a5073fa32fc7f777ec2709591539cb4e559237.tar.gz
installed packages now parse out package location from /var/log/packages entry
Diffstat (limited to 'src')
-rw-r--r--src/package.c19
-rw-r--r--src/package.h2
2 files changed, 19 insertions, 2 deletions
diff --git a/src/package.c b/src/package.c
index 6fdb10d..d615789 100644
--- a/src/package.c
+++ b/src/package.c
@@ -403,7 +403,7 @@ struct pkg_list *get_installed_pkgs(void){
char *root_env_entry = NULL;
char *pkg_log_dirname = NULL;
struct dirent *file;
- sg_regex ip_regex, compressed_size_reg, uncompressed_size_reg;
+ sg_regex ip_regex, compressed_size_reg, uncompressed_size_reg,location_regex;
struct pkg_list *list;
list = init_pkg_list();
@@ -411,6 +411,7 @@ struct pkg_list *get_installed_pkgs(void){
init_regex(&ip_regex,PKG_LOG_PATTERN);
init_regex(&compressed_size_reg,PKG_LOG_SIZEC_PATTERN);
init_regex(&uncompressed_size_reg,PKG_LOG_SIZEU_PATTERN);
+ init_regex(&location_regex,PKG_LOCATION_PATTERN);
/* Generate package log directory using ROOT env variable if set */
if( getenv(ROOT_ENV_NAME) && strlen(getenv(ROOT_ENV_NAME)) < ROOT_ENV_LEN ){
@@ -479,6 +480,7 @@ struct pkg_list *get_installed_pkgs(void){
while( (bytes_read = getline(&getline_buffer,&getline_len,pkg_f)) != EOF ){
execute_regex(&compressed_size_reg,getline_buffer);
execute_regex(&uncompressed_size_reg,getline_buffer);
+ execute_regex(&location_regex,getline_buffer);
/* ignore unless we matched */
if( compressed_size_reg.reg_return == 0 ){
@@ -495,6 +497,20 @@ struct pkg_list *get_installed_pkgs(void){
);
tmp_pkg->size_u = strtol(size_u,(char **)NULL,10);
free(size_u);
+ }else if( location_regex.reg_return == 0 ){
+ if( (location_regex.pmatch[1].rm_eo - location_regex.pmatch[1].rm_so) > LOCATION_LEN ){
+ fprintf( stderr, _("pkg location too long\n"));
+ free_pkg(tmp_pkg);
+ continue;
+ }
+ strncpy(tmp_pkg->location,
+ getline_buffer + location_regex.pmatch[1].rm_so,
+ location_regex.pmatch[1].rm_eo - location_regex.pmatch[1].rm_so
+ );
+ tmp_pkg->location[
+ location_regex.pmatch[1].rm_eo - location_regex.pmatch[1].rm_so
+ ] = '\0';
+
}else{
if(strstr(getline_buffer,"PACKAGE DESCRIPTION") != NULL){
while(1){
@@ -526,6 +542,7 @@ struct pkg_list *get_installed_pkgs(void){
free(pkg_log_dirname);
free_regex(&compressed_size_reg);
free_regex(&uncompressed_size_reg);
+ free_regex(&location_regex);
list->free_pkgs = TRUE;
return list;
diff --git a/src/package.h b/src/package.h
index 8a8fc90..c393acd 100644
--- a/src/package.h
+++ b/src/package.h
@@ -35,7 +35,7 @@
#define NAME_LEN 50
#define VERSION_LEN 50
#define MIRROR_LEN 200
-#define LOCATION_LEN 50
+#define LOCATION_LEN 100
#define DESCRIPTION_LEN 1024
#define MD5_STR_LEN 34
#define MD5_CHECKSUM_FAILED -100