CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Bumped version to 5.32.0.
[pkgutils-cross.git] / pkgutil.cc
index 943c420f23a9d807b1fac599fc00dbe2a20899b3..216ca531de2dd92d507d474b42b5d3f8ccc70aad 100644 (file)
@@ -2,6 +2,7 @@
 //  pkgutils
 // 
 //  Copyright (c) 2000-2005 Per Liden
+//  Copyright (c) 2006-2007 by CRUX team (http://crux.nu)
 // 
 //  This program is free software; you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
 #include <archive.h>
 #include <archive_entry.h>
 
+#define INIT_ARCHIVE(ar) \
+       archive_read_support_compression_all((ar)); \
+       archive_read_support_format_all((ar))
+
 using __gnu_cxx::stdio_filebuf;
 
 pkgutil::pkgutil(const string& name)
@@ -342,8 +347,7 @@ pair<string, pkgutil::pkginfo_t> pkgutil::pkg_open(const string& filename) const
        result.second.version = version;
 
        archive = archive_read_new();
-       archive_read_support_compression_all(archive);
-       archive_read_support_format_all(archive);
+       INIT_ARCHIVE(archive);
 
        if (archive_read_open_filename(archive,
            const_cast<char*>(filename.c_str()),
@@ -382,8 +386,7 @@ void pkgutil::pkg_install(const string& filename, const set<string>& keep_list,
        unsigned int i;
 
        archive = archive_read_new();
-       archive_read_support_compression_all(archive);
-       archive_read_support_format_all(archive);
+       INIT_ARCHIVE(archive);
 
        if (archive_read_open_filename(archive,
            const_cast<char*>(filename.c_str()),
@@ -421,7 +424,7 @@ void pkgutil::pkg_install(const string& filename, const set<string>& keep_list,
                                           (real_filename.c_str()));
 
                // Extract file
-               unsigned int flags = ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_UNLINK;
+               unsigned int flags = ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK;
 
                if (archive_read_extract(archive, entry, flags) != ARCHIVE_OK) {
                        // If a file fails to install we just print an error message and
@@ -498,8 +501,7 @@ void pkgutil::pkg_footprint(string& filename) const
        //
        // FIXME the code duplication here is butt ugly
        archive = archive_read_new();
-       archive_read_support_compression_all(archive);
-       archive_read_support_format_all(archive);
+       INIT_ARCHIVE(archive);
 
        if (archive_read_open_filename(archive,
            const_cast<char*>(filename.c_str()),
@@ -526,8 +528,7 @@ void pkgutil::pkg_footprint(string& filename) const
        // Too bad, there doesn't seem to be a way to reuse our archive
        // instance
        archive = archive_read_new();
-       archive_read_support_compression_all(archive);
-       archive_read_support_format_all(archive);
+       INIT_ARCHIVE(archive);
 
        if (archive_read_open_filename(archive,
            const_cast<char*>(filename.c_str()),