summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2014-04-03 22:54:32 -0400
committerJason Woodward2014-04-03 22:57:08 -0400
commit0f36e5bd3564ff36f5deb829106ee935b3b18c85 (patch)
tree155a4b8875de12ce77851a2eb6225a8ad392fe09
parent56c8f3efb94a1ed65edb6ed7e67eb2882842bd2a (diff)
downloadslapt-get-0f36e5bd3564ff36f5deb829106ee935b3b18c85.tar.gz
support fractional installed size from /var/log/packages files
-rw-r--r--ChangeLog1
-rw-r--r--Makefile2
-rw-r--r--src/main.h1
-rw-r--r--src/package.c6
-rw-r--r--src/package.h4
5 files changed, 9 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b60c7e..82bbeb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
0.10.2q Feb 13, 2014
+ * support fractional installed size from /var/log/packages files
* --show now returns non-zero if nothing found
* tweak search to return exact name matches in case of regex characters
diff --git a/Makefile b/Makefile
index c60809c..112a4b4 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ PACKAGE_LOCALE_DIR=/usr/share/locale
SBINDIR=/usr/sbin/
GETTEXT_PACKAGE=$(PACKAGE)
DEFINES=-DPACKAGE="\"$(PACKAGE)\"" -DVERSION="\"$(VERSION)\"" -DRC_LOCATION="\"$(RCDEST)\"" -DENABLE_NLS -DPACKAGE_LOCALE_DIR="\"$(PACKAGE_LOCALE_DIR)\"" -DGETTEXT_PACKAGE="\"$(GETTEXT_PACKAGE)\""
-LDFLAGS+=$(CURLFLAGS) -lz
+LDFLAGS+=$(CURLFLAGS) -lz -lm
HAS_GPGME=$(shell gpgme-config --libs 2>&1 >/dev/null && echo 1)
ifeq ($(HAS_GPGME),1)
DEFINES+=-DSLAPT_HAS_GPGME
diff --git a/src/main.h b/src/main.h
index 68bb74f..e50e90a 100644
--- a/src/main.h
+++ b/src/main.h
@@ -39,6 +39,7 @@
#include <sys/mman.h>
#include <zlib.h>
#include <utime.h>
+#include <math.h>
#include "common.h"
#include "configuration.h"
diff --git a/src/package.c b/src/package.c
index 9524cb0..1f055ad 100644
--- a/src/package.c
+++ b/src/package.c
@@ -598,7 +598,8 @@ slapt_pkg_list_t *slapt_get_installed_pkgs(void)
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);
+ double c = strtof(size_c, (char **)NULL);
+ tmp_pkg->size_c = round(c);
if ( strcmp(unit, "M") == 0 )
tmp_pkg->size_c *= 1024;
free(size_c);
@@ -610,7 +611,8 @@ slapt_pkg_list_t *slapt_get_installed_pkgs(void)
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);
+ double u = strtof(size_u, (char **)NULL);
+ tmp_pkg->size_u = round(u);
if ( strcmp(unit, "M") == 0 )
tmp_pkg->size_u *= 1024;
free(size_u);
diff --git a/src/package.h b/src/package.h
index db98e8c..adac7ee 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,}([MK])$"
-#define SLAPT_PKG_LOG_SIZEU_PATTERN "^UNCOMPRESSED PACKAGE SIZE:[ ]{1,}([0-9]{1,})[ ]{0,}([MK])$"
+#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