Skip to content

Commit

Permalink
darwinup: don't run bzip2 compression on (limited cpu) embedded devices.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.macosforge.org/repository/darwinbuild/trunk@1064 10a61168-4876-4dac-953b-31e694342555
  • Loading branch information
mwwa committed May 2, 2013
1 parent b993329 commit e6f8ade
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Darwin Build Scripts Change History
-----------------------------------
Release 36 [2-May-2013]
- darwinup: fix bad return code from update_xpc_services_cache.
- darwinup: don't run bzip2 compression on (limited cpu) embedded devices.

Release 35 [24-Apr-2013]
- all: fix implicit integer conversions.
Expand Down
29 changes: 25 additions & 4 deletions darwinup/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
#include <string.h>
#include <unistd.h>

#if TARGET_OS_EMBEDDED
# define COMPACT_SUFFIX ".tar"
# define COMPACT_COMPRESSION ""
#else
# define COMPACT_SUFFIX ".tar.bz2"
# define COMPACT_COMPRESSION "j"
#endif

extern char** environ;

Archive::Archive(const char* path) {
Expand Down Expand Up @@ -110,11 +118,11 @@ int Archive::compact_directory(const char* prefix) {
char* tarpath = NULL;
char uuidstr[37];
uuid_unparse_upper(m_uuid, uuidstr);
asprintf(&tarpath, "%s/%s.tar.bz2", prefix, uuidstr);
asprintf(&tarpath, "%s/%s" COMPACT_SUFFIX, prefix, uuidstr);
if (tarpath) {
const char* args[] = {
"/usr/bin/tar",
"cjf", tarpath,
"cf" COMPACT_COMPRESSION, tarpath,
"-C", prefix,
uuidstr,
NULL
Expand All @@ -133,11 +141,11 @@ int Archive::expand_directory(const char* prefix) {
char* tarpath = NULL;
char uuidstr[37];
uuid_unparse_upper(m_uuid, uuidstr);
asprintf(&tarpath, "%s/%s.tar.bz2", prefix, uuidstr);
asprintf(&tarpath, "%s/%s" COMPACT_SUFFIX, prefix, uuidstr);
if (tarpath) {
const char* args[] = {
"/usr/bin/tar",
"xjf", tarpath,
"xf" COMPACT_COMPRESSION, tarpath,
"-C", prefix,
"-p", // --preserve-permissions
NULL
Expand All @@ -151,6 +159,19 @@ int Archive::expand_directory(const char* prefix) {
return res;
}

int Archive::prune_compacted_archive(const char* prefix) {
int res = 0;
char* tarpath = NULL;
char uuidstr[37];
uuid_unparse_upper(m_uuid, uuidstr);
asprintf(&tarpath, "%s/%s" COMPACT_SUFFIX, prefix, uuidstr);
if (tarpath) {
res = unlink(tarpath);
if (res) perror(tarpath);
free(tarpath);
}
return res;
}

int Archive::extract(const char* destdir) {
// not implemented
Expand Down
6 changes: 5 additions & 1 deletion darwinup/Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define _ARCHIVE_H

#include <Availability.h>
#include <TargetConditionals.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
Expand Down Expand Up @@ -100,7 +101,7 @@ struct Archive {

// the OS build this archive was installed onto
virtual const char* build();

// ARCHIVE_INFO flags.
virtual uint64_t info();

Expand Down Expand Up @@ -132,6 +133,9 @@ struct Archive {
// Expands the backing-store directory from its single file.
int expand_directory(const char* prefix);

// Removes the compacted backing-store file from disk.
int prune_compacted_archive(const char* prefix);

protected:

// Constructor for subclasses and Depot to use when
Expand Down
8 changes: 1 addition & 7 deletions darwinup/Depot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,13 +915,7 @@ int Depot::prune_archive(Archive* archive) {
}

// clean up disk
char path[PATH_MAX];
char uuid[37];
uuid_unparse_upper(archive->uuid(), uuid);
if (res == 0) snprintf(path, PATH_MAX, "%s/%s.tar.bz2", m_archives_path, uuid);
if (res == 0) res = unlink(path);
if (res) perror(path);

res = archive->prune_compacted_archive(m_archives_path);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion darwinup/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

void usage(char* progname) {
fprintf(stderr, "usage: %s [-v] [-p DIR] [command] [args] \n", progname);
fprintf(stderr, "version: 33 \n");
fprintf(stderr, "version: 36 \n");
fprintf(stderr, " \n");
fprintf(stderr, "options: \n");
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
Expand Down

0 comments on commit e6f8ade

Please sign in to comment.