[darwinbuild-changes] [657] branches/PR-6729491/darwinup
source_changes at macosforge.org
source_changes at macosforge.org
Sat Dec 12 22:39:05 PST 2009
Revision: 657
http://trac.macosforge.org/projects/darwinbuild/changeset/657
Author: wsiegrist at apple.com
Date: 2009-12-12 22:39:01 -0800 (Sat, 12 Dec 2009)
Log Message:
-----------
Add support to darwinup for cpio, xar, and zip archives.
Modified Paths:
--------------
branches/PR-6729491/darwinup/Archive.cpp
branches/PR-6729491/darwinup/Archive.h
Modified: branches/PR-6729491/darwinup/Archive.cpp
===================================================================
--- branches/PR-6729491/darwinup/Archive.cpp 2009-12-13 05:53:52 UTC (rev 656)
+++ branches/PR-6729491/darwinup/Archive.cpp 2009-12-13 06:39:01 UTC (rev 657)
@@ -204,6 +204,75 @@
}
+CpioArchive::CpioArchive(const char* path) : Archive(path) {}
+
+int CpioArchive::extract(const char* destdir) {
+ const char* args[] = {
+ "/usr/bin/ditto",
+ "-x", m_path,
+ destdir,
+ NULL
+ };
+ return exec_with_args(args);
+}
+
+CpioGZArchive::CpioGZArchive(const char* path) : CpioArchive(path) {}
+
+CpioBZ2Archive::CpioBZ2Archive(const char* path) : CpioArchive(path) {}
+
+
+XarArchive::XarArchive(const char* path) : Archive(path) {}
+
+int XarArchive::extract(const char* destdir) {
+ const char* args[] = {
+ "/usr/bin/xar",
+ "-xf", m_path,
+ "-C", destdir,
+ NULL
+ };
+ return exec_with_args(args);
+}
+
+
+XarGZArchive::XarGZArchive(const char* path) : Archive(path) {}
+
+int XarGZArchive::extract(const char* destdir) {
+ const char* args[] = {
+ "/usr/bin/xar",
+ "-xzf", m_path,
+ "-C", destdir,
+ NULL
+ };
+ return exec_with_args(args);
+}
+
+
+XarBZ2Archive::XarBZ2Archive(const char* path) : Archive(path) {}
+
+int XarBZ2Archive::extract(const char* destdir) {
+ const char* args[] = {
+ "/usr/bin/xar",
+ "-xjf", m_path,
+ "-C", destdir,
+ NULL
+ };
+ return exec_with_args(args);
+}
+
+
+ZipArchive::ZipArchive(const char* path) : Archive(path) {}
+
+int ZipArchive::extract(const char* destdir) {
+ const char* args[] = {
+ "/usr/bin/ditto",
+ "-xk", m_path,
+ destdir,
+ NULL
+ };
+ return exec_with_args(args);
+}
+
+
Archive* ArchiveFactory(const char* path) {
Archive* archive = NULL;
@@ -222,6 +291,20 @@
archive = new TarGZArchive(path);
} else if (has_suffix(path, ".tar.bz2") || has_suffix(path, ".tbz2")) {
archive = new TarBZ2Archive(path);
+ } else if (has_suffix(path, ".cpio")) {
+ archive = new CpioArchive(path);
+ } else if (has_suffix(path, ".cpio.gz") || has_suffix(path, ".cpgz")) {
+ archive = new CpioGZArchive(path);
+ } else if (has_suffix(path, ".cpio.bz2") || has_suffix(path, ".cpbz2")) {
+ archive = new CpioBZ2Archive(path);
+ } else if (has_suffix(path, ".xar")) {
+ archive = new XarArchive(path);
+ } else if (has_suffix(path, ".xar.gz") || has_suffix(path, ".xgz")) {
+ archive = new XarGZArchive(path);
+ } else if (has_suffix(path, ".xar.bz2") || has_suffix(path, ".xbz2")) {
+ archive = new XarBZ2Archive(path);
+ } else if (has_suffix(path, ".zip")) {
+ archive = new ZipArchive(path);
} else {
fprintf(stderr, "Error: unknown archive type: %s\n", path);
}
Modified: branches/PR-6729491/darwinup/Archive.h
===================================================================
--- branches/PR-6729491/darwinup/Archive.h 2009-12-13 05:53:52 UTC (rev 656)
+++ branches/PR-6729491/darwinup/Archive.h 2009-12-13 06:39:01 UTC (rev 657)
@@ -197,3 +197,85 @@
TarBZ2Archive(const char* path);
virtual int extract(const char* destdir);
};
+
+
+////
+// CpioArchive
+//
+// Corresponds to the cpio(1) file format. This handles uncompressed cpio
+// archives by using the cpio(1) command line tool.
+////
+struct CpioArchive : public Archive {
+ CpioArchive(const char* path);
+ virtual int extract(const char* destdir);
+};
+
+////
+// CpioGZArchive
+//
+// Corresponds to the cpio(1) file format, compressed with gzip(1).
+// This inherits from CpioArchive and relies on ditto(1) automated
+// handling of compressed cpio archives.
+////
+struct CpioGZArchive : public CpioArchive {
+ CpioGZArchive(const char* path);
+};
+
+////
+// CpioBZ2Archive
+//
+// Corresponds to the cpio(1) file format, compressed with bzip2(1).
+// This inherits from CpioArchive and relies on ditto(1) automated
+// handling of compressed cpio archives.
+////
+struct CpioBZ2Archive : public CpioArchive {
+ CpioBZ2Archive(const char* path);
+};
+
+
+////
+// XarArchive
+//
+// Corresponds to the xar(1) file format. This handles uncompressed cpio
+// archives by using the xar(1) command line tool.
+////
+struct XarArchive : public Archive {
+ XarArchive(const char* path);
+ virtual int extract(const char* destdir);
+};
+
+////
+// XarGZArchive
+//
+// Corresponds to the xar(1) file format, compressed with gzip(1).
+// This installs archives using the xar(1) command line tool with
+// the -z option.
+////
+struct XarGZArchive : public Archive {
+ XarGZArchive(const char* path);
+ virtual int extract(const char* destdir);
+};
+
+////
+// XarBZ2Archive
+//
+// Corresponds to the xar(1) file format, compressed with bzip2(1).
+// This installs archives using the xar(1) command line tool with
+// the -j option.
+////
+struct XarBZ2Archive : public Archive {
+ XarBZ2Archive(const char* path);
+ virtual int extract(const char* destdir);
+};
+
+
+////
+// ZipArchive
+//
+// Corresponds to a zip archive. We use the -k option to ditto(1)
+// to handle it.
+////
+struct ZipArchive : public Archive {
+ ZipArchive(const char* path);
+ virtual int extract(const char* destdir);
+};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20091212/ec8aecd5/attachment.html>
More information about the darwinbuild-changes
mailing list