summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2011-06-26 22:56:02 +0000
committerJason Woodward2011-06-26 22:56:02 +0000
commit8425e6211f75f1bafdabb8cbdc52876b36724b76 (patch)
treea55e155e3060a1c63544024f9665ef9692debfcd /src
parent5bb022d221a53636548bf00b52d4ddcab4a33aa6 (diff)
downloadslapt-get-8425e6211f75f1bafdabb8cbdc52876b36724b76.tar.gz
Updated regex for reading /var/log/packages compressed and uncompressed sizes
Larger packages use 'M' instead of 'K' for size designation... account for this.
Diffstat (limited to 'src')
-rw-r--r--src/package.c8
-rw-r--r--src/package.h4
2 files changed, 10 insertions, 2 deletions
diff --git a/src/package.c b/src/package.c
index a94648b..04f307d 100644
--- a/src/package.c
+++ b/src/package.c
@@ -592,16 +592,24 @@ slapt_pkg_list_t *slapt_get_installed_pkgs(void)
slapt_execute_regex(compressed_size_reg,pkg_data);
if (compressed_size_reg->reg_return == 0) {
char *size_c = slapt_regex_extract_match(compressed_size_reg, pkg_data, 1);
+ char *unit = slapt_regex_extract_match(compressed_size_reg, pkg_data, 2);
tmp_pkg->size_c = strtol(size_c,(char **)NULL,10);
+ if ( strcmp(unit, "M") == 0 )
+ tmp_pkg->size_c *= 1024;
free(size_c);
+ free(unit);
}
/* pull out uncompressed size */
slapt_execute_regex(uncompressed_size_reg,pkg_data);
if (uncompressed_size_reg->reg_return == 0 ) {
char *size_u = slapt_regex_extract_match(uncompressed_size_reg, pkg_data, 1);
+ char *unit = slapt_regex_extract_match(uncompressed_size_reg, pkg_data, 2);
tmp_pkg->size_u = strtol(size_u,(char **)NULL,10);
+ if ( strcmp(unit, "M") == 0 )
+ tmp_pkg->size_u *= 1024;
free(size_u);
+ free(unit);
}
/* Ignore the location for installed packages */
diff --git a/src/package.h b/src/package.h
index 4726425..5bd6a71 100644
--- a/src/package.h
+++ b/src/package.h
@@ -8,8 +8,8 @@
#define SLAPT_PKG_LOCATION_PATTERN "^PACKAGE LOCATION:[ ]+(.*)$"
#define SLAPT_PKG_SIZEC_PATTERN "^PACKAGE SIZE [(]+compressed[)]{1,}:[ ]{1,}([0-9]{1,}) K$"
#define SLAPT_PKG_SIZEU_PATTERN "^PACKAGE SIZE [(]+uncompressed[)]{1,}:[ ]{1,}([0-9]{1,}) K$"
-#define SLAPT_PKG_LOG_SIZEC_PATTERN "^COMPRESSED PACKAGE SIZE:[ ]{1,}([0-9]{1,})[ ]{0,}K$"
-#define SLAPT_PKG_LOG_SIZEU_PATTERN "^UNCOMPRESSED PACKAGE SIZE:[ ]{1,}([0-9]{1,})[ ]{0,}K$"
+#define SLAPT_PKG_LOG_SIZEC_PATTERN "^COMPRESSED PACKAGE SIZE:[ ]{1,}([0-9]{1,})[ ]{0,}([MK])$"
+#define SLAPT_PKG_LOG_SIZEU_PATTERN "^UNCOMPRESSED PACKAGE SIZE:[ ]{1,}([0-9]{1,})[ ]{0,}([MK])$"
#define SLAPT_PKG_LOG_DIR "/var/log/packages"
#define SLAPT_ROOT_ENV_NAME "ROOT"
#define SLAPT_ROOT_ENV_LEN 255