code:
commit 5a94115b99030c87baff2195c2d2a8165e8373ad
Author: Natanael Copa <natanael.copa@gmail.com>
Date:   Tue Apr 24 17:06:19 2012 +0200

    tar: implement --no-recursion

    function                                             old     new   delta
    tar_longopts                                         259     274     +15
    .rodata                                             5757    5772     +15
    tar_main                                            1038    1052     +14
    writeTarFile                                         362     353      -9
    ------------------------------------------------------------------------------
    (add/remove: 0/0 grow/shrink: 3/1 up/down: 44/-9)              Total: 35 bytes
       text	   data	    bss	    dec	    hex	filename
      81457	   1706	   8344	  91507	  16573	busybox_old
      81477	   1706	   8344	  91527	  16587	busybox_unstripped

    Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
    Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

diff --git a/archival/tar.c b/archival/tar.c
index cf972c2..a64d651 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -60,8 +60,8 @@

 #if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
 /* Do not pass gzip flag to writeTarFile() */
-#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
-	writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
+#define writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude, gzip) \
+	writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude)
 #endif

@@ -598,7 +598,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)

 /* gcc 4.2.1 inlines it, making code bigger */
 static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
-	int dereferenceFlag, const llist_t *include,
+	int recurseFlags, const llist_t *include,
 	const llist_t *exclude, int gzip)
 {
 	int errorFlag = FALSE;
@@ -621,8 +621,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,

 	/* Read the directory/files and iterate over them one at a time */
 	while (include) {
-		if (!recursive_action(include->data, ACTION_RECURSE |
-				(dereferenceFlag ? ACTION_FOLLOWLINKS : 0),
+		if (!recursive_action(include->data, recurseFlags,
 				writeFileToTarball, writeFileToTarball, &tbInfo, 0)
 		) {
 			errorFlag = TRUE;
@@ -662,7 +661,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
 }
 #else
 int writeTarFile(int tar_fd, int verboseFlag,
-	int dereferenceFlag, const llist_t *include,
+	int recurseFlags, const llist_t *include,
 	const llist_t *exclude, int gzip);
 #endif /* FEATURE_TAR_CREATE */

@@ -749,6 +748,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
 //	o	no-same-owner
 //	p	same-permissions
 //	k	keep-old
+//	no-recursion
 //	numeric-owner
 //	no-same-permissions
 //	overwrite
@@ -768,6 +768,7 @@ enum {
 	IF_FEATURE_SEAMLESS_Z(   OPTBIT_COMPRESS    ,) // 16th bit
 	IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
 #if ENABLE_FEATURE_TAR_LONG_OPTIONS
+	OPTBIT_NORECURSION,
 	IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND   ,)
 	OPTBIT_NUMERIC_OWNER,
 	OPTBIT_NOPRESERVE_PERM,
@@ -791,6 +792,7 @@ enum {
 	OPT_GZIP         = IF_FEATURE_SEAMLESS_GZ(  (1 << OPTBIT_GZIP        )) + 0, // z
 	OPT_COMPRESS     = IF_FEATURE_SEAMLESS_Z(   (1 << OPTBIT_COMPRESS    )) + 0, // Z
 	OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
+	OPT_NORECURSION     = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION    )) + 0, // no-recursion
 	OPT_2COMMAND        = IF_FEATURE_TAR_TO_COMMAND(  (1 << OPTBIT_2COMMAND       )) + 0, // to-command
 	OPT_NUMERIC_OWNER   = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER  )) + 0, // numeric-owner
 	OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
@@ -835,6 +837,7 @@ static const char tar_longopts[] ALIGN1 =
 # if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
 	"touch\0"               No_argument       "m"
 # endif
+	"no-recursion\0"	No_argument       "\xfa"
 # if ENABLE_FEATURE_TAR_TO_COMMAND
 	"to-command\0"		Required_argument "\xfb"
 # endif
@@ -1050,7 +1053,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
 			zipMode = 2;
 #endif
 		/* NB: writeTarFile() closes tar_handle->src_fd */
-		return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE,
+		return writeTarFile(tar_handle->src_fd, verboseFlag,
+				(opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0)
+				| (opt & OPT_NORECURSION ? 0 : ACTION_RECURSE),
 				tar_handle->accept,
 				tar_handle->reject, zipMode);
 	}


code:
commit dfc2473b9ed88039697ac89ee2a4301cdaefcf84
Author: Boris Reisig <boris@boris.ca>
Date:   Thu May 24 09:01:55 2012 +0200

    tar: support -J, --xz explicit compression option

    function                                             old     new   delta
    tar_main                                             868     881     +13
    tar_longopts                                         285     290      +5
    packed_usage                                       29267   29270      +3

    Signed-off-by: Boris Reisig <boris@boris.ca>
    Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

diff --git a/archival/tar.c b/archival/tar.c
index a64d651..a3565d6 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -693,6 +693,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
 //usage:	"-[" IF_FEATURE_TAR_CREATE("c") "xt"
 //usage:	IF_FEATURE_SEAMLESS_Z("Z")
 //usage:	IF_FEATURE_SEAMLESS_GZ("z")
+//usage:	IF_FEATURE_SEAMLESS_XZ("J")
 //usage:	IF_FEATURE_SEAMLESS_BZ2("j")
 //usage:	IF_FEATURE_SEAMLESS_LZMA("a")
 //usage:	IF_FEATURE_TAR_CREATE("h")
@@ -719,6 +720,9 @@ static llist_t *append_file_list_to_list(llist_t *list)
 //usage:	IF_FEATURE_SEAMLESS_GZ(
 //usage:     "\n	z	(De)compress using gzip"
 //usage:	)
+//usage:	IF_FEATURE_SEAMLESS_XZ(
+//usage:     "\n	J	(De)compress using xz"
+//usage:	)
 //usage:	IF_FEATURE_SEAMLESS_BZ2(
 //usage:     "\n	j	(De)compress using bzip2"
 //usage:	)
@@ -765,7 +769,8 @@ enum {
 	IF_FEATURE_TAR_FROM(     OPTBIT_INCLUDE_FROM,)
 	IF_FEATURE_TAR_FROM(     OPTBIT_EXCLUDE_FROM,)
 	IF_FEATURE_SEAMLESS_GZ(  OPTBIT_GZIP        ,)
-	IF_FEATURE_SEAMLESS_Z(   OPTBIT_COMPRESS    ,) // 16th bit
+	IF_FEATURE_SEAMLESS_XZ(  OPTBIT_XZ          ,) // 16th bit
+	IF_FEATURE_SEAMLESS_Z(   OPTBIT_COMPRESS    ,)
 	IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
 #if ENABLE_FEATURE_TAR_LONG_OPTIONS
 	OPTBIT_NORECURSION,
@@ -790,6 +795,7 @@ enum {
 	OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM(     (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
 	OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM(     (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
 	OPT_GZIP         = IF_FEATURE_SEAMLESS_GZ(  (1 << OPTBIT_GZIP        )) + 0, // z
+	OPT_XZ           = IF_FEATURE_SEAMLESS_XZ(  (1 << OPTBIT_XZ          )) + 0, // J
 	OPT_COMPRESS     = IF_FEATURE_SEAMLESS_Z(   (1 << OPTBIT_COMPRESS    )) + 0, // Z
 	OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
 	OPT_NORECURSION     = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION    )) + 0, // no-recursion
@@ -798,7 +804,7 @@ enum {
 	OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
 	OPT_OVERWRITE       = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE      )) + 0, // overwrite

-	OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_COMPRESS),
+	OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_XZ | OPT_COMPRESS),
 };
 #if ENABLE_FEATURE_TAR_LONG_OPTIONS
 static const char tar_longopts[] ALIGN1 =
@@ -831,6 +837,9 @@ static const char tar_longopts[] ALIGN1 =
 # if ENABLE_FEATURE_SEAMLESS_GZ
 	"gzip\0"                No_argument       "z"
 # endif
+# if ENABLE_FEATURE_SEAMLESS_XZ
+	"xz\0"                  No_argument       "J"
+# endif
 # if ENABLE_FEATURE_SEAMLESS_Z
 	"compress\0"            No_argument       "Z"
 # endif
@@ -924,6 +933,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
 		IF_FEATURE_SEAMLESS_LZMA("a"   )
 		IF_FEATURE_TAR_FROM(     "T:X:")
 		IF_FEATURE_SEAMLESS_GZ(  "z"   )
+		IF_FEATURE_SEAMLESS_XZ(  "J"   )
 		IF_FEATURE_SEAMLESS_Z(   "Z"   )
 		IF_FEATURE_TAR_NOPRESERVE_TIME("m")
 		, &base_dir // -C dir
@@ -1076,6 +1086,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
 		if (opt & OPT_LZMA)
 			USE_FOR_MMU(xformer = unpack_lzma_stream;)
 			USE_FOR_NOMMU(xformer_prog = "unlzma";)
+		if (opt & OPT_XZ)
+			USE_FOR_MMU(xformer = unpack_xz_stream;)
+			USE_FOR_NOMMU(xformer_prog = "unxz";)

 		open_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog);
 		/* Can't lseek over pipes */

repo_name: aarf/bkauler

license: unknown


code:
diff --git a/archival/tar.c b/archival/tar.c
index 3cd033b..16270bc 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -58,13 +58,6 @@
 #define block_buf bb_common_bufsiz1

-#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
-/* Do not pass gzip flag to writeTarFile() */
-#define writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude, gzip) \
-	writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude)
-#endif
-
-
 #if ENABLE_FEATURE_TAR_CREATE

 /*
@@ -519,21 +512,12 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
 	return TRUE;
 }

-#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
-# if !(ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2)
-#  define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd)
-# endif
+#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 || ENABLE_FEATURE_SEAMLESS_XZ
 /* Don't inline: vfork scares gcc and pessimizes code */
-static void NOINLINE vfork_compressor(int tar_fd, int gzip)
+static void NOINLINE vfork_compressor(int tar_fd, const char* zip_exec)
 {
 	pid_t gzipPid;
-# if ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2
-	const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
-# elif ENABLE_FEATURE_SEAMLESS_GZ
-	const char *zip_exec = "gzip";
-# else /* only ENABLE_FEATURE_SEAMLESS_BZ2 */
-	const char *zip_exec = "bzip2";
-# endif
+
 	// On Linux, vfork never unpauses parent early, although standard
 	// allows for that. Do we want to waste bytes checking for it?
 # define WAIT_FOR_CHILD 0
@@ -593,13 +577,13 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
 		bb_perror_msg_and_die("can't execute '%s'", zip_exec);
 	}
 }
-#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 */
+#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 || ENABLE_FEATURE_SEAMLESS_XZ */

 /* gcc 4.2.1 inlines it, making code bigger */
 static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
 	int recurseFlags, const llist_t *include,
-	const llist_t *exclude, int gzip)
+	const llist_t *exclude, const char* compressor)
 {
 	int errorFlag = FALSE;
 	struct TarBallInfo tbInfo;
@@ -612,9 +596,9 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
 	 * can avoid including the tarball into itself....  */
 	xfstat(tbInfo.tarFd, &tbInfo.tarFileStatBuf, "can't stat tar file");

-#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
-	if (gzip)
-		vfork_compressor(tbInfo.tarFd, gzip);
+#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 || ENABLE_FEATURE_SEAMLESS_XZ
+	if (compressor)
+		vfork_compressor(tbInfo.tarFd, compressor);
 #endif

 	tbInfo.excludeList = exclude;
@@ -647,13 +631,13 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
 	if (errorFlag)
 		bb_error_msg("error exit delayed from previous errors");

-#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
-	if (gzip) {
+#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 || ENABLE_FEATURE_SEAMLESS_XZ
+	if (compressor) {
 		int status;
 		if (safe_waitpid(-1, &status, 0) == -1)
 			bb_perror_msg("waitpid");
 		else if (!WIFEXITED(status) || WEXITSTATUS(status))
-			/* gzip was killed or has exited with nonzero! */
+			/* compressor was killed or has exited with nonzero! */
 			errorFlag = TRUE;
 	}
 #endif
@@ -662,7 +646,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
 #else
 int writeTarFile(int tar_fd, int verboseFlag,
 	int recurseFlags, const llist_t *include,
-	const llist_t *exclude, int gzip);
+	const llist_t *exclude, const char *compressor);
 #endif /* FEATURE_TAR_CREATE */

 #if ENABLE_FEATURE_TAR_FROM
@@ -1053,12 +1037,14 @@ int tar_main(int argc UNUSED_PARAM, char **argv)

 	/* Create an archive */
 	if (opt & OPT_CREATE) {
-#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
-		int zipMode = 0;
+		const char *zipMode = 0;
+#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 || ENABLE_FEATURE_SEAMLESS_XZ
 		if (ENABLE_FEATURE_SEAMLESS_GZ && (opt & OPT_GZIP))
-			zipMode = 1;
+			zipMode = "gzip";
 		if (ENABLE_FEATURE_SEAMLESS_BZ2 && (opt & OPT_BZIP2))
-			zipMode = 2;
+			zipMode = "bzip2";
+		if (ENABLE_FEATURE_SEAMLESS_XZ && (opt & OPT_XZ))
+			zipMode = "xz";
 #endif
 		/* NB: writeTarFile() closes tar_handle->src_fd */
 		return writeTarFile(tar_handle->src_fd, verboseFlag,
--
1.7.3.4


code:
diff --git a/archival/unzip.c b/archival/unzip.c
index c1b945a..3806747 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -20,11 +20,11 @@
  */

 //usage:#define unzip_trivial_usage
-//usage:       "[-opts[modifiers]] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
+//usage:       "[-lnopq] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
 //usage:#define unzip_full_usage "\n\n"
 //usage:       "Extract files from ZIP archives\n"
 //usage:     "\n	-l	List archive contents (with -q for short form)"
-//usage:     "\n	-n	Never overwrite files (default)"
+//usage:     "\n	-n	Never overwrite files (default: ask)"
 //usage:     "\n	-o	Overwrite"
 //usage:     "\n	-p	Send output to stdout"
 //usage:     "\n	-q	Quiet"
@@ -277,6 +277,7 @@ int unzip_main(int argc, char **argv)
 	IF_NOT_DESKTOP(const) smallint verbose = 0;
 	smallint listing = 0;
 	smallint overwrite = O_PROMPT;
+	smallint x_opt_seen;
 #if ENABLE_DESKTOP
 	uint32_t cdf_offset;
 #endif
@@ -290,7 +291,6 @@ int unzip_main(int argc, char **argv)
 	llist_t *zreject = NULL;
 	char *base_dir = NULL;
 	int i, opt;
-	int opt_range = 0;
 	char key_buf[80];
 	struct stat stat_buf;

@@ -335,81 +335,81 @@ int unzip_main(int argc, char **argv)
  *    204372                   1 file
  */

+	x_opt_seen = 0;
 	/* '-' makes getopt return 1 for non-options */
 	while ((opt = getopt(argc, argv, "-d:lnopqxv")) != -1) {
-		switch (opt_range) {
-		case 0: /* Options */
-			switch (opt) {
-			case 'l': /* List */
-				listing = 1;
-				break;
+		switch (opt) {
+		case 'd':  /* Extract to base directory */
+			base_dir = optarg;
+			break;

-			case 'n': /* Never overwrite existing files */
-				overwrite = O_NEVER;
-				break;
+		case 'l': /* List */
+			listing = 1;
+			break;

-			case 'o': /* Always overwrite existing files */
-				overwrite = O_ALWAYS;
-				break;
+		case 'n': /* Never overwrite existing files */
+			overwrite = O_NEVER;
+			break;

-			case 'p': /* Extract files to stdout and fall through to set verbosity */
-				dst_fd = STDOUT_FILENO;
+		case 'o': /* Always overwrite existing files */
+			overwrite = O_ALWAYS;
+			break;

-			case 'q': /* Be quiet */
-				quiet++;
-				break;
+		case 'p': /* Extract files to stdout and fall through to set verbosity */
+			dst_fd = STDOUT_FILENO;

-			case 'v': /* Verbose list */
-				IF_DESKTOP(verbose++;)
-				listing = 1;
-				break;
+		case 'q': /* Be quiet */
+			quiet++;
+			break;

-			case 1: /* The zip file */
-				/* +5: space for ".zip" and NUL */
-				src_fn = xmalloc(strlen(optarg) + 5);
-				strcpy(src_fn, optarg);
-				opt_range++;
-				break;
+		case 'v': /* Verbose list */
+			IF_DESKTOP(verbose++;)
+			listing = 1;
+			break;

-			default:
-				bb_show_usage();
-			}
+		case 'x':
+			x_opt_seen = 1;
 			break;

-		case 1: /* Include files */
-			if (opt == 1) {
+		case 1:
+			if (!src_fn) {
+				/* The zip file */
+				/* +5: space for ".zip" and NUL */
+				src_fn = xmalloc(strlen(optarg) + 5);
+				strcpy(src_fn, optarg);
+			} else if (!x_opt_seen) {
+				/* Include files */
 				llist_add_to(&zaccept, optarg);
-				break;
-			}
-			if (opt == 'd') {
-				base_dir = optarg;
-				opt_range += 2;
-				break;
-			}
-			if (opt == 'x') {
-				opt_range++;
-				break;
-			}
-			bb_show_usage();
-
-		case 2 : /* Exclude files */
-			if (opt == 1) {
+			} else {
+				/* Exclude files */
 				llist_add_to(&zreject, optarg);
-				break;
 			}
-			if (opt == 'd') { /* Extract to base directory */
-				base_dir = optarg;
-				opt_range++;
-				break;
-			}
-			/* fall through */
+			break;

 		default:
 			bb_show_usage();
 		}
 	}

-	if (src_fn == NULL) {
+#ifndef __GLIBC__
+	/*
+	 * This code is needed for non-GNU getopt
+	 * which doesn't understand "-" in option string.
+	 * The -x option won't work properly in this case:
+	 * "unzip a.zip q -x w e" will be interpreted as
+	 * "unzip a.zip q w e -x" = "unzip a.zip q w e"
+	 */
+	argv += optind;
+	if (argv[0]) {
+		/* +5: space for ".zip" and NUL */
+		src_fn = xmalloc(strlen(argv[0]) + 5);
+		strcpy(src_fn, argv[0]);
+		while (*++argv)
+			llist_add_to(&zaccept, *argv);
+	}
+#endif
+
+	if (!src_fn) {
 		bb_show_usage();
 	}

@@ -420,17 +420,20 @@ int unzip_main(int argc, char **argv)
 		if (overwrite == O_PROMPT)
 			overwrite = O_NEVER;
 	} else {
-		static const char extn[][5] = {"", ".zip", ".ZIP"};
-		int orig_src_fn_len = strlen(src_fn);
-		int src_fd = -1;
+		static const char extn[][5] = { ".zip", ".ZIP" };
+		char *ext = src_fn + strlen(src_fn);
+		int src_fd;

-		for (i = 0; (i < 3) && (src_fd == -1); i++) {
-			strcpy(src_fn + orig_src_fn_len, extn[i]);
+		i = 0;
+		for (;;) {
 			src_fd = open(src_fn, O_RDONLY);
-		}
-		if (src_fd == -1) {
-			src_fn[orig_src_fn_len] = '\0';
-			bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
+			if (src_fd >= 0)
+				break;
+			if (++i > 2) {
+				*ext = '\0';
+				bb_error_msg_and_die("can't open %s[.zip]", src_fn);
+			}
+			strcpy(ext, extn[i - 1]);
 		}
 		xmove_fd(src_fd, zip_fd);
 	}
--
1.7.3.4


code:
--- busybox-1.20.2-a/networking/wget.c
+++ busybox-1.20.2-b/networking/wget.c
@@ -43,12 +43,14 @@
 	char *allocated;
 	const char *path;
 	const char *user;
+	const char *protocol;
 	char       *host;
 	int         port;
-	smallint    is_ftp;
 };
+static const char P_FTP[] = "ftp";
+static const char P_HTTP[] = "http";
+static const char P_HTTPS[] = "https";

-
 /* Globals */
 struct globals {
 	off_t content_len;        /* Content-length of the file */
@@ -198,7 +200,7 @@
 	/* glibc 2.4 seems to try seeking on it - ??! */
 	/* hopefully it understands what ESPIPE means... */
 	fp = fdopen(xconnect_stream(lsa), "r+");
-	if (fp == NULL)
+	if (!fp)
 		bb_perror_msg_and_die(bb_msg_memory_exhausted);

 	return fp;
@@ -252,16 +254,29 @@
 	free(h->allocated);
 	h->allocated = url = xstrdup(src_url);

-	if (strncmp(url, "http://", 7) == 0) {
-		h->port = bb_lookup_port("http", "tcp", 80);
-		h->host = url + 7;
-		h->is_ftp = 0;
-	} else if (strncmp(url, "ftp://", 6) == 0) {
-		h->port = bb_lookup_port("ftp", "tcp", 21);
-		h->host = url + 6;
-		h->is_ftp = 1;
-	} else
-		bb_error_msg_and_die("not an http or ftp url: %s", sanitize_string(url));
+	h->protocol = P_FTP;
+	p = strstr(url, "://");
+	if (p) {
+		*p = '\0';
+		h->host = p + 3;
+		if (strcmp(url, P_FTP) == 0) {
+			h->port = bb_lookup_port(P_FTP, "tcp", 21);
+		} else if (strcmp(url, P_HTTPS) == 0) {
+			h->port = bb_lookup_port(P_HTTPS, "tcp", 443);
+			h->protocol = P_HTTPS;
+		} else if (strcmp(url, P_HTTP) == 0) {
+http:
+			h->port = bb_lookup_port(P_HTTP, "tcp", 80);
+			h->protocol = P_HTTP;
+		} else {
+			*p = ':';
+			bb_error_msg_and_die("not an http or ftp url: %s", sanitize_string(url));
+		}
+	} else {
+		// GNU wget is user-friendly and falls back to http://
+		h->host = url;
+		goto http;
+	}

 	// FYI:
 	// "Real" wget 'http://busybox.net?var=a/b' sends this request:
@@ -427,6 +442,56 @@
 	return sfp;
 }

+static int spawn_https_helper(const char *host, unsigned port)
+{
+	char *allocated = NULL;
+	int sp[2];
+	int pid;
+
+	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) != 0)
+		/* Kernel can have AF_UNIX support disabled */
+		bb_perror_msg_and_die("socketpair");
+
+	if (!strchr(host, ':'))
+		host = allocated = xasprintf("%s:%u", host, port);
+
+	pid = BB_MMU ? xfork() : xvfork();
+	if (pid == 0) {
+		/* Child */
+		char *argv[6];
+
+		close(sp[0]);
+		xmove_fd(sp[1], 0);
+		xdup2(0, 1);
+		/*
+		* TODO: develop a tiny ssl/tls helper (using matrixssl?),
+		* try to exec it here before falling back to big fat openssl.
+		*/
+		/*
+		* openssl s_client -quiet -connect www.kernel.org:443 2>/dev/null
+		* It prints some debug stuff on stderr, don't know how to suppress it.
+		* Work around by dev-nulling stderr. We lose all error messages :(
+		*/
+		xmove_fd(2, 3);
+		xopen("/dev/null", O_RDWR);
+		argv[0] = (char*)"openssl";
+		argv[1] = (char*)"s_client";
+		argv[2] = (char*)"-quiet";
+		argv[3] = (char*)"-connect";
+		argv[4] = (char*)host;
+		argv[5] = NULL;
+		BB_EXECVP(argv[0], argv);
+		xmove_fd(3, 2);
+		bb_perror_msg_and_die("can't execute '%s'", argv[0]);
+		/* notreached */
+	}
+
+	/* parent process */
+	free(allocated);
+	close(sp[1]);
+	return sp[0];
+}
+
 static void NOINLINE retrieve_file_data(FILE *dfp)
 {
 #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT
@@ -571,7 +636,8 @@
 	/* Use the proxy if necessary */
 	use_proxy = (strcmp(G.proxy_flag, "off") != 0);
 	if (use_proxy) {
-		proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy");
+		proxy = getenv(target.protocol == P_FTP ? "ftp_proxy" : "http_proxy");
+		//FIXME: what if protocol is https? Ok to use http_proxy?
 		use_proxy = (proxy && proxy[0]);
 		if (use_proxy)
 			parse_url(proxy, &server);
@@ -633,27 +699,31 @@
 	/*G.content_len = 0; - redundant, got_clen = 0 is enough */
 	G.got_clen = 0;
 	G.chunked = 0;
-	if (use_proxy || !target.is_ftp) {
+	if (use_proxy || !target.protocol != P_FTP) {
 		/*
 		 *  HTTP session
 		 */
 		char *str;
 		int status;

+		/* Open socket to http(s) server */
+		if (target.protocol == P_HTTPS) {
+			int fd = spawn_https_helper(server.host, server.port);
+			sfp = fdopen(fd, "r+");
+			if (!sfp)
+				bb_perror_msg_and_die(bb_msg_memory_exhausted);
+		} else
+			 sfp = open_socket(lsa);

-		/* Open socket to http server */
-		sfp = open_socket(lsa);
-
 		/* Send HTTP request */
 		if (use_proxy) {
-			fprintf(sfp, "GET %stp://%s/%s HTTP/1.1\r\n",
-				target.is_ftp ? "f" : "ht", target.host,
+			fprintf(sfp, "GET %s://%s/%s HTTP/1.1\r\n",
+				target.protocol, target.host,
 				target.path);
 		} else {
-			if (option_mask32 & WGET_OPT_POST_DATA)
-				fprintf(sfp, "POST /%s HTTP/1.1\r\n", target.path);
-			else
-				fprintf(sfp, "GET /%s HTTP/1.1\r\n", target.path);
+			fprintf(sfp, "%s /%s HTTP/1.1\r\n",
+				(option_mask32 & WGET_OPT_POST_DATA) ? "POST" : "GET",
+				target.path);
 		}

 		fprintf(sfp, "Host: %s\r\nUser-Agent: %s\r\n",


code:
http://git.tukaani.org/?p=xz-embedded.git;a=commitdiff;h=4cec51e1be4797a4bd8b266a1d34cabd7fdb79fd
--- busybox-1.20.2.org/archival/libarchive/unxz/xz_dec_lzma2.c
+++ busybox-1.20.2/archival/libarchive/unxz/xz_dec_lzma2.c
@@ -972,6 +972,9 @@
 			 */
 			tmp = b->in[b->in_pos++];

+			if (tmp == 0x00)
+				return XZ_STREAM_END;
+
 			if (tmp >= 0xE0 || tmp == 0x01) {
 				s->lzma2.need_props = true;
 				s->lzma2.need_dict_reset = false;
@@ -1004,9 +1007,6 @@
 						lzma_reset(s);
 				}
 			} else {
-				if (tmp == 0x00)
-					return XZ_STREAM_END;
-
 				if (tmp > 0x02)
 					return XZ_DATA_ERROR;


code:
http://git.tukaani.org/?p=xz-embedded.git;a=commitdiff;h=9690fe69dc97eb2e7fe2804e4448a5278cde5411
--- busybox-1.20.2.org/archival/libarchive/unxz/xz_dec_bcj.c
+++ busybox-1.20.2/archival/libarchive/unxz/xz_dec_bcj.c
@@ -443,8 +443,12 @@
 	 * next filter in the chain. Apply the BCJ filter on the new data
 	 * in the output buffer. If everything cannot be filtered, copy it
 	 * to temp and rewind the output buffer position accordingly.
+	 *
+	 * This needs to be always run when temp.size == 0 to handle a special
+	 * case where the output buffer is full and the next filter has no
+	 * more output coming but hasn't returned XZ_STREAM_END yet.
 	 */
-	if (s->temp.size < b->out_size - b->out_pos) {
+	if (s->temp.size < b->out_size - b->out_pos || s->temp.size == 0) {
 		out_start = b->out_pos;
 		memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
 		b->out_pos += s->temp.size;
@@ -467,16 +471,25 @@
 		s->temp.size = b->out_pos - out_start;
 		b->out_pos -= s->temp.size;
 		memcpy(s->temp.buf, b->out + b->out_pos, s->temp.size);
+
+		/*
+		 * If there wasn't enough input to the next filter to fill
+		 * the output buffer with unfiltered data, there's no point
+		 * to try decoding more data to temp.
+		 */
+		if (b->out_pos + s->temp.size < b->out_size)
+			return XZ_OK;
 	}

 	/*
-	 * If we have unfiltered data in temp, try to fill by decoding more
-	 * data from the next filter. Apply the BCJ filter on temp. Then we
-	 * hopefully can fill the actual output buffer by copying filtered
-	 * data from temp. A mix of filtered and unfiltered data may be left
-	 * in temp; it will be taken care on the next call to this function.
+	 * We have unfiltered data in temp. If the output buffer isn't full
+	 * yet, try to fill the temp buffer by decoding more data from the
+	 * next filter. Apply the BCJ filter on temp. Then we hopefully can
+	 * fill the actual output buffer by copying filtered data from temp.
+	 * A mix of filtered and unfiltered data may be left in temp; it will
+	 * be taken care on the next call to this function.
 	 */
-	if (s->temp.size > 0) {
+	if (b->out_pos < b->out_size) {
 		/* Make b->out{,_pos,_size} temporarily point to s->temp. */
 		s->out = b->out;
 		s->out_pos = b->out_pos;


code:
http://lists.busybox.net/pipermail/busybox/2013-February/078927.html

--- busybox-1.20.2.org/archival/libarchive/decompress_unxz.c
+++ busybox-1.20.2/archival/libarchive/decompress_unxz.c
@@ -86,8 +86,40 @@
 			IF_DESKTOP(total += iobuf.out_pos;)
 			iobuf.out_pos = 0;
 		}
-		if (r == XZ_STREAM_END) {
-			break;
+		while (r == XZ_STREAM_END) {
+			/* Handle concatenated .xz Streams including possible
+			 * Stream Padding.
+			 */
+			if (iobuf.in_pos == iobuf.in_size) {
+				int rd = safe_read(src_fd, membuf, BUFSIZ);
+				if (rd < 0) {
+					bb_error_msg(bb_msg_read_error);
+					total = -1;
+					goto out;
+				}
+				if (rd == 0)
+					goto out;
+
+				iobuf.in_size = rd;
+				iobuf.in_pos = 0;
+			}
+
+			/* Stream Padding must always be a multiple of four
+			 * bytes to preserve four-byte alignment. To keep the
+			 * code slightly smaller, we aren't as strict here as
+			 * the .xz spec requires. We just skip all zero-bytes
+			 * without checking the alignment and thus can accept
+			 * files that aren't valid, e.g. the XZ Utils test
+			 * files bad-0pad-empty.xz and bad-0catpad-empty.xz.
+			 */
+			while (iobuf.in_pos < iobuf.in_size) {
+				if (membuf[iobuf.in_pos] != 0) {
+					xz_dec_reset(state);
+					r = XZ_OK;
+					break;
+				}
+				++iobuf.in_pos;
+			}
 		}
 		if (r != XZ_OK && r != XZ_UNSUPPORTED_CHECK) {
 			bb_error_msg("corrupted data");
@@ -95,6 +127,8 @@
 			break;
 		}
 	}
+
+out:
 	xz_dec_end(state);
 	free(membuf);


code:
diff -aur busybox-1.19.2.orig//include/libbb.h busybox-1.19.2//include/libbb.h
--- busybox-1.19.2.orig//include/libbb.h	2011-09-16 01:12:38.000000000 +0000
+++ busybox-1.19.2//include/libbb.h	2011-09-16 01:13:21.000000000 +0000
@@ -37,6 +37,7 @@
 #include <sys/mman.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include <sys/sysinfo.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #ifndef major
Only in busybox-1.19.2//include: libbb.h.orig
diff -aur busybox-1.19.2.orig//include/platform.h busybox-1.19.2//include/platform.h
--- busybox-1.19.2.orig//include/platform.h	2011-09-16 01:12:38.000000000 +0000
+++ busybox-1.19.2//include/platform.h	2011-09-16 01:13:21.000000000 +0000
@@ -443,6 +443,13 @@
 # undef HAVE_NET_ETHERNET_H
 #endif

+#if defined(__musl__)
+# undef HAVE_SETBIT
+# include <stddef.h>
+# include <termios.h>
+# include <sys/ioctl.h>
+#endif
+
 /*
  * Now, define prototypes for all the functions defined in platform.c
  * These must come after all the HAVE_* macros are defined (or not)
Only in busybox-1.19.2//include: platform.h.orig
diff -aur busybox-1.19.2.orig//miscutils/man.c busybox-1.19.2//miscutils/man.c
--- busybox-1.19.2.orig//miscutils/man.c	2011-09-16 01:12:38.000000000 +0000
+++ busybox-1.19.2//miscutils/man.c	2011-09-16 01:13:21.000000000 +0000
@@ -116,7 +116,7 @@
 	/* "2>&1" is added so that nroff errors are shown in pager too.
 	 * Otherwise it may show just empty screen */
 	cmd = xasprintf(
-		man ? "gtbl | nroff -Tlatin1 -mandoc 2>&1 | %s"
+		man ? "nroff -Tutf -man 2>&1 | %s"
 		    : "%s",
 		pager);
 	system(cmd);
Only in busybox-1.19.2//miscutils: man.c.orig
diff -aur busybox-1.19.2.orig//networking/ifconfig.c busybox-1.19.2//networking/ifconfig.c
--- busybox-1.19.2.orig//networking/ifconfig.c	2011-09-16 01:12:38.000000000 +0000
+++ busybox-1.19.2//networking/ifconfig.c	2011-09-16 01:13:21.000000000 +0000
@@ -56,7 +56,7 @@
 #endif

 #if ENABLE_FEATURE_IFCONFIG_SLIP
-# include <net/if_slip.h>
+# include <linux/if_slip.h>
 #endif

 /* I don't know if this is needed for busybox or not.  Anyone? */
Only in busybox-1.19.2//networking: ifconfig.c.orig
diff -aur busybox-1.19.2.orig//networking/libiproute/iplink.c busybox-1.19.2//networking/libiproute/iplink.c
--- busybox-1.19.2.orig//networking/libiproute/iplink.c	2011-09-16 01:12:38.000000000 +0000
+++ busybox-1.19.2//networking/libiproute/iplink.c	2011-09-16 01:13:21.000000000 +0000
@@ -5,7 +5,6 @@
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 #include <net/if.h>
-#include <net/if_packet.h>
 #include <netpacket/packet.h>
 #include <netinet/if_ether.h>

Only in busybox-1.19.2//networking/libiproute: iplink.c.orig
diff -aur busybox-1.19.2.orig//networking/tcpudp.c busybox-1.19.2//networking/tcpudp.c
--- busybox-1.19.2.orig//networking/tcpudp.c	2011-09-16 01:12:38.000000000 +0000
+++ busybox-1.19.2//networking/tcpudp.c	2011-09-16 01:13:21.000000000 +0000
@@ -71,7 +71,7 @@
 /* Wants <limits.h> etc, thus included after libbb.h: */
 #ifdef __linux__
 #include <linux/types.h> /* for __be32 etc */
-#include <linux/netfilter_ipv4.h>
+//#include <linux/netfilter_ipv4.h>
 #endif

 // TODO: move into this file:
diff -aur busybox-1.19.2.orig//util-linux/fdisk.c busybox-1.19.2//util-linux/fdisk.c
--- busybox-1.19.2.orig//util-linux/fdisk.c	2011-09-16 01:12:38.000000000 +0000
+++ busybox-1.19.2//util-linux/fdisk.c	2011-09-16 01:13:21.000000000 +0000
@@ -550,7 +550,7 @@
 {
 #if ENABLE_FDISK_SUPPORT_LARGE_DISKS
 	off64_t off = (off64_t)secno * sector_size;
-	if (lseek64(dev_fd, off, SEEK_SET) == (off64_t) -1)
+	if (lseek(dev_fd, off, SEEK_SET) == (off64_t) -1)
 		fdisk_fatal(unable_to_seek);
 #else
 	uint64_t off = (uint64_t)secno * sector_size;
Only in busybox-1.19.2//util-linux: fdisk.c.orig


code:
#
# Automatically generated make config: don't edit
# Busybox version: 1.20.1
# Mon Jun  4 02:12:36 2012
#
CONFIG_HAVE_DOT_CONFIG=y

#
# Busybox Settings
#

#
# General Configuration
#
CONFIG_DESKTOP=y
# CONFIG_EXTRA_COMPAT is not set
CONFIG_INCLUDE_SUSv2=y
# CONFIG_USE_PORTABLE_CODE is not set
CONFIG_PLATFORM_LINUX=y
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
CONFIG_SHOW_USAGE=y
CONFIG_FEATURE_VERBOSE_USAGE=y
CONFIG_FEATURE_COMPRESS_USAGE=y
CONFIG_FEATURE_INSTALLER=y
CONFIG_INSTALL_NO_USR=y
# CONFIG_LOCALE_SUPPORT is not set
CONFIG_UNICODE_SUPPORT=y
# CONFIG_UNICODE_USING_LOCALE is not set
# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set
CONFIG_SUBST_WCHAR=63
CONFIG_LAST_SUPPORTED_WCHAR=767
# CONFIG_UNICODE_COMBINING_WCHARS is not set
# CONFIG_UNICODE_WIDE_WCHARS is not set
# CONFIG_UNICODE_BIDI_SUPPORT is not set
# CONFIG_UNICODE_NEUTRAL_TABLE is not set
# CONFIG_UNICODE_PRESERVE_BROKEN is not set
CONFIG_LONG_OPTS=y
CONFIG_FEATURE_DEVPTS=y
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_UTMP=y
CONFIG_FEATURE_WTMP=y
CONFIG_FEATURE_PIDFILE=y
CONFIG_FEATURE_SUID=y
CONFIG_FEATURE_SUID_CONFIG=y
CONFIG_FEATURE_SUID_CONFIG_QUIET=y
# CONFIG_SELINUX is not set
# CONFIG_FEATURE_PREFER_APPLETS is not set
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
CONFIG_FEATURE_SYSLOG=y
# CONFIG_FEATURE_HAVE_RPC is not set

#
# Build Options
#
CONFIG_STATIC=y
# CONFIG_PIE is not set
# CONFIG_NOMMU is not set
# CONFIG_BUILD_LIBBUSYBOX is not set
# CONFIG_FEATURE_INDIVIDUAL is not set
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
CONFIG_LFS=y
CONFIG_CROSS_COMPILER_PREFIX=""
CONFIG_SYSROOT=""
CONFIG_EXTRA_CFLAGS="-D__musl__ -static"
CONFIG_EXTRA_LDFLAGS=""
CONFIG_EXTRA_LDLIBS=""

#
# Debugging Options
#
# CONFIG_DEBUG is not set
# CONFIG_DEBUG_PESSIMIZE is not set
# CONFIG_WERROR is not set
CONFIG_NO_DEBUG_LIB=y
# CONFIG_DMALLOC is not set
# CONFIG_EFENCE is not set

#
# Installation Options ("make install" behavior)
#
CONFIG_INSTALL_APPLET_SYMLINKS=y
# CONFIG_INSTALL_APPLET_HARDLINKS is not set
# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
# CONFIG_INSTALL_APPLET_DONT is not set
# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set
# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set
# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set
CONFIG_PREFIX="./_install"

#
# Busybox Library Tuning
#
# CONFIG_FEATURE_SYSTEMD is not set
CONFIG_FEATURE_RTMINMAX=y
CONFIG_PASSWORD_MINLEN=6
CONFIG_MD5_SMALL=3
CONFIG_FEATURE_FAST_TOP=y
# CONFIG_FEATURE_ETC_NETWORKS is not set
CONFIG_FEATURE_USE_TERMIOS=y
CONFIG_FEATURE_EDITING=y
CONFIG_FEATURE_EDITING_MAX_LEN=1024
# CONFIG_FEATURE_EDITING_VI is not set
CONFIG_FEATURE_EDITING_HISTORY=255
CONFIG_FEATURE_EDITING_SAVEHISTORY=y
CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y
CONFIG_FEATURE_REVERSE_SEARCH=y
CONFIG_FEATURE_TAB_COMPLETION=y
CONFIG_FEATURE_USERNAME_COMPLETION=y
CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
# CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set
CONFIG_FEATURE_NON_POSIX_CP=y
# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
CONFIG_FEATURE_COPYBUF_KB=4
CONFIG_FEATURE_SKIP_ROOTFS=y
CONFIG_MONOTONIC_SYSCALL=y
CONFIG_IOCTL_HEX2STR_ERROR=y
CONFIG_FEATURE_HWIB=y

#
# Applets
#

#
# Archival Utilities
#
CONFIG_FEATURE_SEAMLESS_XZ=y
CONFIG_FEATURE_SEAMLESS_LZMA=y
CONFIG_FEATURE_SEAMLESS_BZ2=y
CONFIG_FEATURE_SEAMLESS_GZ=y
# CONFIG_FEATURE_SEAMLESS_Z is not set
# CONFIG_AR is not set
# CONFIG_FEATURE_AR_LONG_FILENAMES is not set
# CONFIG_FEATURE_AR_CREATE is not set
CONFIG_BUNZIP2=y
CONFIG_BZIP2=y
CONFIG_CPIO=y
CONFIG_FEATURE_CPIO_O=y
CONFIG_FEATURE_CPIO_P=y
# CONFIG_DPKG is not set
# CONFIG_DPKG_DEB is not set
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
CONFIG_GUNZIP=y
CONFIG_GZIP=y
CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
CONFIG_GZIP_FAST=2
CONFIG_LZOP=y
# CONFIG_LZOP_COMPR_HIGH is not set
# CONFIG_RPM2CPIO is not set
# CONFIG_RPM is not set
CONFIG_TAR=y
CONFIG_FEATURE_TAR_CREATE=y
CONFIG_FEATURE_TAR_AUTODETECT=y
CONFIG_FEATURE_TAR_FROM=y
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
CONFIG_FEATURE_TAR_TO_COMMAND=y
CONFIG_FEATURE_TAR_UNAME_GNAME=y
CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
# CONFIG_FEATURE_TAR_SELINUX is not set
# CONFIG_UNCOMPRESS is not set
CONFIG_UNLZMA=y
CONFIG_FEATURE_LZMA_FAST=y
CONFIG_LZMA=y
CONFIG_UNXZ=y
CONFIG_XZ=y
CONFIG_UNZIP=y

#
# Coreutils
#
CONFIG_BASENAME=y
CONFIG_CAT=y
CONFIG_DATE=y
CONFIG_FEATURE_DATE_ISOFMT=y
CONFIG_FEATURE_DATE_NANO=y
CONFIG_FEATURE_DATE_COMPAT=y
CONFIG_HOSTID=y
CONFIG_ID=y
CONFIG_GROUPS=y
CONFIG_TEST=y
CONFIG_FEATURE_TEST_64=y
CONFIG_TOUCH=y
CONFIG_FEATURE_TOUCH_SUSV3=y
CONFIG_TR=y
CONFIG_FEATURE_TR_CLASSES=y
CONFIG_FEATURE_TR_EQUIV=y
CONFIG_BASE64=y
CONFIG_WHO=y
CONFIG_USERS=y
CONFIG_CAL=y
CONFIG_CATV=y
CONFIG_CHGRP=y
CONFIG_CHMOD=y
CONFIG_CHOWN=y
CONFIG_FEATURE_CHOWN_LONG_OPTIONS=y
CONFIG_CHROOT=y
CONFIG_CKSUM=y
CONFIG_COMM=y
CONFIG_CP=y
CONFIG_FEATURE_CP_LONG_OPTIONS=y
CONFIG_CUT=y
CONFIG_DD=y
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
CONFIG_FEATURE_DD_THIRD_STATUS_LINE=y
CONFIG_FEATURE_DD_IBS_OBS=y
CONFIG_DF=y
CONFIG_FEATURE_DF_FANCY=y
CONFIG_DIRNAME=y
CONFIG_DOS2UNIX=y
CONFIG_UNIX2DOS=y
CONFIG_DU=y
CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y
CONFIG_ECHO=y
CONFIG_FEATURE_FANCY_ECHO=y
CONFIG_ENV=y
CONFIG_FEATURE_ENV_LONG_OPTIONS=y
CONFIG_EXPAND=y
CONFIG_FEATURE_EXPAND_LONG_OPTIONS=y
CONFIG_EXPR=y
CONFIG_EXPR_MATH_SUPPORT_64=y
CONFIG_FALSE=y
CONFIG_FOLD=y
CONFIG_FSYNC=y
CONFIG_HEAD=y
CONFIG_FEATURE_FANCY_HEAD=y
CONFIG_INSTALL=y
CONFIG_FEATURE_INSTALL_LONG_OPTIONS=y
CONFIG_LN=y
CONFIG_LOGNAME=y
CONFIG_LS=y
CONFIG_FEATURE_LS_FILETYPES=y
CONFIG_FEATURE_LS_FOLLOWLINKS=y
CONFIG_FEATURE_LS_RECURSIVE=y
CONFIG_FEATURE_LS_SORTFILES=y
CONFIG_FEATURE_LS_TIMESTAMPS=y
CONFIG_FEATURE_LS_USERNAME=y
CONFIG_FEATURE_LS_COLOR=y
CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y
CONFIG_MD5SUM=y
CONFIG_MKDIR=y
CONFIG_FEATURE_MKDIR_LONG_OPTIONS=y
CONFIG_MKFIFO=y
CONFIG_MKNOD=y
CONFIG_MV=y
CONFIG_FEATURE_MV_LONG_OPTIONS=y
CONFIG_NICE=y
CONFIG_NOHUP=y
CONFIG_OD=y
CONFIG_PRINTENV=y
CONFIG_PRINTF=y
CONFIG_PWD=y
CONFIG_READLINK=y
CONFIG_FEATURE_READLINK_FOLLOW=y
CONFIG_REALPATH=y
CONFIG_RM=y
CONFIG_RMDIR=y
CONFIG_FEATURE_RMDIR_LONG_OPTIONS=y
CONFIG_SEQ=y
CONFIG_SHA1SUM=y
CONFIG_SHA256SUM=y
CONFIG_SHA512SUM=y
CONFIG_SLEEP=y
CONFIG_FEATURE_FANCY_SLEEP=y
CONFIG_FEATURE_FLOAT_SLEEP=y
CONFIG_SORT=y
CONFIG_FEATURE_SORT_BIG=y
CONFIG_SPLIT=y
CONFIG_FEATURE_SPLIT_FANCY=y
CONFIG_STAT=y
CONFIG_FEATURE_STAT_FORMAT=y
CONFIG_STTY=y
CONFIG_SUM=y
CONFIG_SYNC=y
CONFIG_TAC=y
CONFIG_TAIL=y
CONFIG_FEATURE_FANCY_TAIL=y
CONFIG_TEE=y
CONFIG_FEATURE_TEE_USE_BLOCK_IO=y
CONFIG_TRUE=y
CONFIG_TTY=y
CONFIG_UNAME=y
CONFIG_UNEXPAND=y
CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS=y
CONFIG_UNIQ=y
CONFIG_USLEEP=y
CONFIG_UUDECODE=y
CONFIG_UUENCODE=y
CONFIG_WC=y
CONFIG_FEATURE_WC_LARGE=y
CONFIG_WHOAMI=y
CONFIG_YES=y

#
# Common options for cp and mv
#
CONFIG_FEATURE_PRESERVE_HARDLINKS=y

#
# Common options for ls, more and telnet
#
CONFIG_FEATURE_AUTOWIDTH=y

#
# Common options for df, du, ls
#
CONFIG_FEATURE_HUMAN_READABLE=y

#
# Common options for md5sum, sha1sum, sha256sum, sha512sum
#
CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y

#
# Console Utilities
#
CONFIG_CHVT=y
CONFIG_FGCONSOLE=y
CONFIG_CLEAR=y
CONFIG_DEALLOCVT=y
CONFIG_DUMPKMAP=y
CONFIG_KBD_MODE=y
CONFIG_LOADFONT=y
CONFIG_LOADKMAP=y
CONFIG_OPENVT=y
CONFIG_RESET=y
CONFIG_RESIZE=y
CONFIG_FEATURE_RESIZE_PRINT=y
CONFIG_SETCONSOLE=y
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
CONFIG_SETFONT=y
CONFIG_FEATURE_SETFONT_TEXTUAL_MAP=y
CONFIG_DEFAULT_SETFONT_DIR=""
CONFIG_SETKEYCODES=y
CONFIG_SETLOGCONS=y
CONFIG_SHOWKEY=y

#
# Common options for loadfont and setfont
#
CONFIG_FEATURE_LOADFONT_PSF2=y
CONFIG_FEATURE_LOADFONT_RAW=y

#
# Debian Utilities
#
CONFIG_MKTEMP=y
CONFIG_PIPE_PROGRESS=y
CONFIG_RUN_PARTS=y
CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
CONFIG_FEATURE_RUN_PARTS_FANCY=y
CONFIG_START_STOP_DAEMON=y
CONFIG_FEATURE_START_STOP_DAEMON_FANCY=y
CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y
CONFIG_WHICH=y

#
# Editors
#
# CONFIG_PATCH is not set
CONFIG_VI=y
CONFIG_FEATURE_VI_MAX_LEN=4096
# CONFIG_FEATURE_VI_8BIT is not set
CONFIG_FEATURE_VI_COLON=y
CONFIG_FEATURE_VI_YANKMARK=y
CONFIG_FEATURE_VI_SEARCH=y
# CONFIG_FEATURE_VI_REGEX_SEARCH is not set
CONFIG_FEATURE_VI_USE_SIGNALS=y
CONFIG_FEATURE_VI_DOT_CMD=y
CONFIG_FEATURE_VI_READONLY=y
CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_AWK=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
CONFIG_DIFF=y
CONFIG_FEATURE_DIFF_LONG_OPTIONS=y
CONFIG_FEATURE_DIFF_DIR=y
CONFIG_ED=y
CONFIG_SED=y
CONFIG_FEATURE_ALLOW_EXEC=y

#
# Finding Utilities
#
CONFIG_FIND=y
CONFIG_FEATURE_FIND_PRINT0=y
CONFIG_FEATURE_FIND_MTIME=y
CONFIG_FEATURE_FIND_MMIN=y
CONFIG_FEATURE_FIND_PERM=y
CONFIG_FEATURE_FIND_TYPE=y
CONFIG_FEATURE_FIND_XDEV=y
CONFIG_FEATURE_FIND_MAXDEPTH=y
CONFIG_FEATURE_FIND_NEWER=y
CONFIG_FEATURE_FIND_INUM=y
CONFIG_FEATURE_FIND_EXEC=y
CONFIG_FEATURE_FIND_USER=y
CONFIG_FEATURE_FIND_GROUP=y
CONFIG_FEATURE_FIND_NOT=y
CONFIG_FEATURE_FIND_DEPTH=y
CONFIG_FEATURE_FIND_PAREN=y
CONFIG_FEATURE_FIND_SIZE=y
CONFIG_FEATURE_FIND_PRUNE=y
CONFIG_FEATURE_FIND_DELETE=y
CONFIG_FEATURE_FIND_PATH=y
CONFIG_FEATURE_FIND_REGEX=y
# CONFIG_FEATURE_FIND_CONTEXT is not set
CONFIG_FEATURE_FIND_LINKS=y
CONFIG_GREP=y
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
CONFIG_FEATURE_GREP_CONTEXT=y
CONFIG_XARGS=y
CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y

#
# Init Utilities
#
# CONFIG_BOOTCHARTD is not set
# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
CONFIG_HALT=y
# CONFIG_FEATURE_CALL_TELINIT is not set
CONFIG_TELINIT_PATH=""
CONFIG_INIT=y
CONFIG_FEATURE_USE_INITTAB=y
# CONFIG_FEATURE_KILL_REMOVED is not set
CONFIG_FEATURE_KILL_DELAY=0
CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=y
CONFIG_FEATURE_EXTRA_QUIET=y
CONFIG_FEATURE_INIT_COREDUMPS=y
CONFIG_FEATURE_INITRD=y
CONFIG_INIT_TERMINAL_TYPE="linux"
CONFIG_MESG=y
CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y

#
# Login/Password Management Utilities
#
CONFIG_ADD_SHELL=y
CONFIG_REMOVE_SHELL=y
CONFIG_FEATURE_SHADOWPASSWDS=y
CONFIG_USE_BB_PWD_GRP=y
CONFIG_USE_BB_SHADOW=y
CONFIG_USE_BB_CRYPT=y
CONFIG_USE_BB_CRYPT_SHA=y
CONFIG_ADDUSER=y
CONFIG_FEATURE_ADDUSER_LONG_OPTIONS=y
# CONFIG_FEATURE_CHECK_NAMES is not set
CONFIG_FIRST_SYSTEM_ID=11
CONFIG_LAST_SYSTEM_ID=999
CONFIG_ADDGROUP=y
CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS=y
CONFIG_FEATURE_ADDUSER_TO_GROUP=y
CONFIG_DELUSER=y
CONFIG_DELGROUP=y
CONFIG_FEATURE_DEL_USER_FROM_GROUP=y
CONFIG_GETTY=y
CONFIG_LOGIN=y
# CONFIG_LOGIN_SESSION_AS_CHILD is not set
# CONFIG_PAM is not set
CONFIG_LOGIN_SCRIPTS=y
CONFIG_FEATURE_NOLOGIN=y
# CONFIG_FEATURE_SECURETTY is not set
CONFIG_PASSWD=y
CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
CONFIG_CRYPTPW=y
CONFIG_CHPASSWD=y
CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="bf"
# CONFIG_SU is not set
CONFIG_FEATURE_SU_SYSLOG=y
# CONFIG_FEATURE_SU_CHECKS_SHELLS is not set
CONFIG_SULOGIN=y
CONFIG_VLOCK=y

#
# Linux Ext2 FS Progs
#
CONFIG_CHATTR=y
# CONFIG_FSCK is not set
CONFIG_LSATTR=y
CONFIG_TUNE2FS=y

#
# Linux Module Utilities
#
CONFIG_MODINFO=y
# CONFIG_MODPROBE_SMALL is not set
# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
CONFIG_INSMOD=y
CONFIG_RMMOD=y
CONFIG_LSMOD=y
CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
CONFIG_MODPROBE=y
CONFIG_FEATURE_MODPROBE_BLACKLIST=y
CONFIG_DEPMOD=y

#
# Options common to multiple modutils
#
# CONFIG_FEATURE_2_4_MODULES is not set
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
CONFIG_FEATURE_MODUTILS_ALIAS=y
CONFIG_FEATURE_MODUTILS_SYMBOLS=y
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"

#
# Linux System Utilities
#
CONFIG_BLOCKDEV=y
CONFIG_MDEV=y
CONFIG_FEATURE_MDEV_CONF=y
CONFIG_FEATURE_MDEV_RENAME=y
CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
CONFIG_FEATURE_MDEV_EXEC=y
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
CONFIG_REV=y
CONFIG_ACPID=y
CONFIG_FEATURE_ACPID_COMPAT=y
CONFIG_BLKID=y
# CONFIG_FEATURE_BLKID_TYPE is not set
CONFIG_DMESG=y
CONFIG_FEATURE_DMESG_PRETTY=y
CONFIG_FBSET=y
CONFIG_FEATURE_FBSET_FANCY=y
CONFIG_FEATURE_FBSET_READMODE=y
CONFIG_FDFLUSH=y
CONFIG_FDFORMAT=y
CONFIG_FDISK=y
# CONFIG_FDISK_SUPPORT_LARGE_DISKS is not set
CONFIG_FEATURE_FDISK_WRITABLE=y
# CONFIG_FEATURE_AIX_LABEL is not set
# CONFIG_FEATURE_SGI_LABEL is not set
# CONFIG_FEATURE_SUN_LABEL is not set
CONFIG_FEATURE_OSF_LABEL=y
CONFIG_FEATURE_GPT_LABEL=y
CONFIG_FEATURE_FDISK_ADVANCED=y
CONFIG_FINDFS=y
CONFIG_FLOCK=y
CONFIG_FREERAMDISK=y
# CONFIG_FSCK_MINIX is not set
CONFIG_MKFS_EXT2=y
# CONFIG_MKFS_MINIX is not set
# CONFIG_FEATURE_MINIX2 is not set
# CONFIG_MKFS_REISER is not set
CONFIG_MKFS_VFAT=y
CONFIG_GETOPT=y
CONFIG_FEATURE_GETOPT_LONG=y
CONFIG_HEXDUMP=y
CONFIG_FEATURE_HEXDUMP_REVERSE=y
CONFIG_HD=y
CONFIG_HWCLOCK=y
CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
# CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS is not set
# CONFIG_IPCRM is not set
# CONFIG_IPCS is not set
CONFIG_LOSETUP=y
CONFIG_LSPCI=y
CONFIG_LSUSB=y
CONFIG_MKSWAP=y
CONFIG_FEATURE_MKSWAP_UUID=y
CONFIG_MORE=y
CONFIG_MOUNT=y
CONFIG_FEATURE_MOUNT_FAKE=y
CONFIG_FEATURE_MOUNT_VERBOSE=y
# CONFIG_FEATURE_MOUNT_HELPERS is not set
CONFIG_FEATURE_MOUNT_LABEL=y
# CONFIG_FEATURE_MOUNT_NFS is not set
CONFIG_FEATURE_MOUNT_CIFS=y
CONFIG_FEATURE_MOUNT_FLAGS=y
CONFIG_FEATURE_MOUNT_FSTAB=y
# CONFIG_PIVOT_ROOT is not set
CONFIG_RDATE=y
CONFIG_RDEV=y
CONFIG_READPROFILE=y
CONFIG_RTCWAKE=y
CONFIG_SCRIPT=y
CONFIG_SCRIPTREPLAY=y
# CONFIG_SETARCH is not set
CONFIG_SWAPONOFF=y
CONFIG_FEATURE_SWAPON_PRI=y
CONFIG_SWITCH_ROOT=y
CONFIG_UMOUNT=y
CONFIG_FEATURE_UMOUNT_ALL=y

#
# Common options for mount/umount
#
CONFIG_FEATURE_MOUNT_LOOP=y
CONFIG_FEATURE_MOUNT_LOOP_CREATE=y
# CONFIG_FEATURE_MTAB_SUPPORT is not set
CONFIG_VOLUMEID=y

#
# Filesystem/Volume identification
#
CONFIG_FEATURE_VOLUMEID_EXT=y
CONFIG_FEATURE_VOLUMEID_BTRFS=y
CONFIG_FEATURE_VOLUMEID_REISERFS=y
CONFIG_FEATURE_VOLUMEID_FAT=y
CONFIG_FEATURE_VOLUMEID_HFS=y
CONFIG_FEATURE_VOLUMEID_JFS=y
CONFIG_FEATURE_VOLUMEID_XFS=y
CONFIG_FEATURE_VOLUMEID_NTFS=y
CONFIG_FEATURE_VOLUMEID_ISO9660=y
CONFIG_FEATURE_VOLUMEID_UDF=y
CONFIG_FEATURE_VOLUMEID_LUKS=y
CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
CONFIG_FEATURE_VOLUMEID_CRAMFS=y
CONFIG_FEATURE_VOLUMEID_ROMFS=y
CONFIG_FEATURE_VOLUMEID_SYSV=y
CONFIG_FEATURE_VOLUMEID_OCFS2=y
CONFIG_FEATURE_VOLUMEID_LINUXRAID=y

#
# Miscellaneous Utilities
#
CONFIG_CONSPY=y
CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
CONFIG_FEATURE_LESS_BRACKETS=y
CONFIG_FEATURE_LESS_FLAGS=y
CONFIG_FEATURE_LESS_MARKS=y
CONFIG_FEATURE_LESS_REGEXP=y
CONFIG_FEATURE_LESS_WINCH=y
CONFIG_FEATURE_LESS_ASK_TERMINAL=y
CONFIG_FEATURE_LESS_DASHCMD=y
CONFIG_FEATURE_LESS_LINENUMS=y
# CONFIG_NANDWRITE is not set
# CONFIG_NANDDUMP is not set
CONFIG_SETSERIAL=y
# CONFIG_UBIATTACH is not set
# CONFIG_UBIDETACH is not set
CONFIG_UBIMKVOL=y
CONFIG_UBIRMVOL=y
CONFIG_UBIRSVOL=y
CONFIG_UBIUPDATEVOL=y
CONFIG_ADJTIMEX=y
CONFIG_BBCONFIG=y
CONFIG_FEATURE_COMPRESS_BBCONFIG=y
CONFIG_BEEP=y
CONFIG_FEATURE_BEEP_FREQ=4000
CONFIG_FEATURE_BEEP_LENGTH_MS=30
CONFIG_CHAT=y
CONFIG_FEATURE_CHAT_NOFAIL=y
# CONFIG_FEATURE_CHAT_TTY_HIFI is not set
CONFIG_FEATURE_CHAT_IMPLICIT_CR=y
CONFIG_FEATURE_CHAT_SWALLOW_OPTS=y
CONFIG_FEATURE_CHAT_SEND_ESCAPES=y
CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
CONFIG_FEATURE_CHAT_CLR_ABORT=y
# CONFIG_CHRT is not set
CONFIG_CROND=y
CONFIG_FEATURE_CROND_D=y
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
CONFIG_CRONTAB=y
# CONFIG_DC is not set
# CONFIG_FEATURE_DC_LIBM is not set
# CONFIG_DEVFSD is not set
# CONFIG_DEVFSD_MODLOAD is not set
# CONFIG_DEVFSD_FG_NP is not set
# CONFIG_DEVFSD_VERBOSE is not set
# CONFIG_FEATURE_DEVFS is not set
CONFIG_DEVMEM=y
# CONFIG_EJECT is not set
# CONFIG_FEATURE_EJECT_SCSI is not set
# CONFIG_FBSPLASH is not set
# CONFIG_FLASHCP is not set
# CONFIG_FLASH_LOCK is not set
# CONFIG_FLASH_UNLOCK is not set
# CONFIG_FLASH_ERASEALL is not set
CONFIG_IONICE=y
CONFIG_INOTIFYD=y
CONFIG_LAST=y
# CONFIG_FEATURE_LAST_SMALL is not set
CONFIG_FEATURE_LAST_FANCY=y
# CONFIG_HDPARM is not set
# CONFIG_FEATURE_HDPARM_GET_IDENTITY is not set
# CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set
# CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF is not set
# CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET is not set
# CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF is not set
# CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA is not set
CONFIG_MAKEDEVS=y
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
CONFIG_FEATURE_MAKEDEVS_TABLE=y
# CONFIG_MAN is not set
CONFIG_MICROCOM=y
CONFIG_MOUNTPOINT=y
# CONFIG_MT is not set
CONFIG_RAIDAUTORUN=y
# CONFIG_READAHEAD is not set
CONFIG_RFKILL=y
CONFIG_RUNLEVEL=y
CONFIG_RX=y
CONFIG_SETSID=y
CONFIG_STRINGS=y
# CONFIG_TASKSET is not set
# CONFIG_FEATURE_TASKSET_FANCY is not set
CONFIG_TIME=y
CONFIG_TIMEOUT=y
CONFIG_TTYSIZE=y
CONFIG_VOLNAME=y
CONFIG_WALL=y
CONFIG_WATCHDOG=y

#
# Networking Utilities
#
# CONFIG_NAMEIF is not set
# CONFIG_FEATURE_NAMEIF_EXTENDED is not set
CONFIG_NBDCLIENT=y
CONFIG_NC=y
CONFIG_NC_SERVER=y
CONFIG_NC_EXTRA=y
# CONFIG_NC_110_COMPAT is not set
CONFIG_PING=y
CONFIG_PING6=y
CONFIG_FEATURE_FANCY_PING=y
CONFIG_WHOIS=y
CONFIG_FEATURE_IPV6=y
# CONFIG_FEATURE_UNIX_LOCAL is not set
CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
CONFIG_VERBOSE_RESOLUTION_ERRORS=y
# CONFIG_ARP is not set
# CONFIG_ARPING is not set
# CONFIG_BRCTL is not set
# CONFIG_FEATURE_BRCTL_FANCY is not set
# CONFIG_FEATURE_BRCTL_SHOW is not set
CONFIG_DNSD=y
# CONFIG_ETHER_WAKE is not set
CONFIG_FAKEIDENTD=y
CONFIG_FTPD=y
CONFIG_FEATURE_FTP_WRITE=y
CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST=y
CONFIG_FTPGET=y
CONFIG_FTPPUT=y
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
CONFIG_HOSTNAME=y
# CONFIG_HTTPD is not set
# CONFIG_FEATURE_HTTPD_RANGES is not set
# CONFIG_FEATURE_HTTPD_USE_SENDFILE is not set
# CONFIG_FEATURE_HTTPD_SETUID is not set
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
# CONFIG_FEATURE_HTTPD_CGI is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
# CONFIG_FEATURE_HTTPD_ERROR_PAGES is not set
# CONFIG_FEATURE_HTTPD_PROXY is not set
# CONFIG_FEATURE_HTTPD_GZIP is not set
CONFIG_IFCONFIG=y
CONFIG_FEATURE_IFCONFIG_STATUS=y
CONFIG_FEATURE_IFCONFIG_SLIP=y
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
CONFIG_FEATURE_IFCONFIG_HW=y
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
CONFIG_IFENSLAVE=y
# CONFIG_IFPLUGD is not set
# CONFIG_IFUPDOWN is not set
CONFIG_IFUPDOWN_IFSTATE_PATH=""
# CONFIG_FEATURE_IFUPDOWN_IP is not set
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set
CONFIG_INETD=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN=y
# CONFIG_FEATURE_INETD_RPC is not set
CONFIG_IP=y
CONFIG_FEATURE_IP_ADDRESS=y
CONFIG_FEATURE_IP_LINK=y
CONFIG_FEATURE_IP_ROUTE=y
CONFIG_FEATURE_IP_TUNNEL=y
CONFIG_FEATURE_IP_RULE=y
CONFIG_FEATURE_IP_SHORT_FORMS=y
# CONFIG_FEATURE_IP_RARE_PROTOCOLS is not set
CONFIG_IPADDR=y
# CONFIG_IPLINK is not set
CONFIG_IPROUTE=y
CONFIG_IPTUNNEL=y
CONFIG_IPRULE=y
CONFIG_IPCALC=y
CONFIG_FEATURE_IPCALC_FANCY=y
CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y
CONFIG_NETSTAT=y
CONFIG_FEATURE_NETSTAT_WIDE=y
CONFIG_FEATURE_NETSTAT_PRG=y
# CONFIG_NSLOOKUP is not set
CONFIG_NTPD=y
# CONFIG_FEATURE_NTPD_SERVER is not set
CONFIG_PSCAN=y
CONFIG_ROUTE=y
CONFIG_SLATTACH=y
CONFIG_TCPSVD=y
CONFIG_TELNET=y
CONFIG_FEATURE_TELNET_TTYPE=y
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
# CONFIG_TELNETD is not set
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
CONFIG_TFTP=y
# CONFIG_TFTPD is not set

#
# Common options for tftp/tftpd
#
CONFIG_FEATURE_TFTP_GET=y
CONFIG_FEATURE_TFTP_PUT=y
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
# CONFIG_TFTP_DEBUG is not set
CONFIG_TRACEROUTE=y
CONFIG_TRACEROUTE6=y
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
CONFIG_TUNCTL=y
CONFIG_FEATURE_TUNCTL_UG=y
# CONFIG_UDHCPC6 is not set
# CONFIG_UDHCPD is not set
# CONFIG_DHCPRELAY is not set
# CONFIG_DUMPLEASES is not set
# CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set
# CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set
CONFIG_DHCPD_LEASES_FILE=""
CONFIG_UDHCPC=y
CONFIG_FEATURE_UDHCPC_ARPING=y
CONFIG_FEATURE_UDHCP_PORT=y
CONFIG_UDHCP_DEBUG=9
CONFIG_FEATURE_UDHCP_RFC3397=y
CONFIG_FEATURE_UDHCP_8021Q=y
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS=""
CONFIG_UDPSVD=y
CONFIG_VCONFIG=y
CONFIG_WGET=y
CONFIG_FEATURE_WGET_STATUSBAR=y
CONFIG_FEATURE_WGET_AUTHENTICATION=y
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
CONFIG_FEATURE_WGET_TIMEOUT=y
# CONFIG_ZCIP is not set

#
# Print Utilities
#
CONFIG_LPD=y
CONFIG_LPR=y
CONFIG_LPQ=y

#
# Mail Utilities
#
CONFIG_MAKEMIME=y
CONFIG_FEATURE_MIME_CHARSET="us-ascii"
CONFIG_POPMAILDIR=y
CONFIG_FEATURE_POPMAILDIR_DELIVERY=y
CONFIG_REFORMIME=y
CONFIG_FEATURE_REFORMIME_COMPAT=y
CONFIG_SENDMAIL=y

#
# Process Utilities
#
CONFIG_IOSTAT=y
CONFIG_LSOF=y
CONFIG_MPSTAT=y
CONFIG_NMETER=y
CONFIG_PMAP=y
CONFIG_POWERTOP=y
CONFIG_PSTREE=y
CONFIG_PWDX=y
CONFIG_SMEMCAP=y
CONFIG_UPTIME=y
CONFIG_FEATURE_UPTIME_UTMP_SUPPORT=y
CONFIG_FREE=y
CONFIG_FUSER=y
CONFIG_KILL=y
CONFIG_KILLALL=y
CONFIG_KILLALL5=y
CONFIG_PGREP=y
CONFIG_PIDOF=y
CONFIG_FEATURE_PIDOF_SINGLE=y
CONFIG_FEATURE_PIDOF_OMIT=y
CONFIG_PKILL=y
CONFIG_PS=y
# CONFIG_FEATURE_PS_WIDE is not set
# CONFIG_FEATURE_PS_LONG is not set
CONFIG_FEATURE_PS_TIME=y
CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=y
# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
CONFIG_RENICE=y
CONFIG_BB_SYSCTL=y
CONFIG_TOP=y
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
CONFIG_FEATURE_TOP_SMP_CPU=y
CONFIG_FEATURE_TOP_DECIMALS=y
CONFIG_FEATURE_TOP_SMP_PROCESS=y
CONFIG_FEATURE_TOPMEM=y
CONFIG_FEATURE_SHOW_THREADS=y
CONFIG_WATCH=y

#
# Runit Utilities
#
CONFIG_RUNSV=y
CONFIG_RUNSVDIR=y
CONFIG_FEATURE_RUNSVDIR_LOG=y
CONFIG_SV=y
CONFIG_SV_DEFAULT_SERVICE_DIR="/var/service"
CONFIG_SVLOGD=y
CONFIG_CHPST=y
CONFIG_SETUIDGID=y
CONFIG_ENVUIDGID=y
CONFIG_ENVDIR=y
CONFIG_SOFTLIMIT=y
# CONFIG_CHCON is not set
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
# CONFIG_GETENFORCE is not set
# CONFIG_GETSEBOOL is not set
# CONFIG_LOAD_POLICY is not set
# CONFIG_MATCHPATHCON is not set
# CONFIG_RESTORECON is not set
# CONFIG_RUNCON is not set
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
# CONFIG_SELINUXENABLED is not set
# CONFIG_SETENFORCE is not set
# CONFIG_SETFILES is not set
# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set
# CONFIG_SETSEBOOL is not set
# CONFIG_SESTATUS is not set

#
# Shells
#
CONFIG_ASH=y
CONFIG_ASH_BASH_COMPAT=y
# CONFIG_ASH_IDLE_TIMEOUT is not set
CONFIG_ASH_JOB_CONTROL=y
CONFIG_ASH_ALIAS=y
CONFIG_ASH_GETOPTS=y
CONFIG_ASH_BUILTIN_ECHO=y
CONFIG_ASH_BUILTIN_PRINTF=y
CONFIG_ASH_BUILTIN_TEST=y
CONFIG_ASH_CMDCMD=y
# CONFIG_ASH_MAIL is not set
CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
CONFIG_ASH_RANDOM_SUPPORT=y
CONFIG_ASH_EXPAND_PRMT=y
CONFIG_CTTYHACK=y
# CONFIG_HUSH is not set
CONFIG_HUSH_BASH_COMPAT=y
CONFIG_HUSH_BRACE_EXPANSION=y
CONFIG_HUSH_HELP=y
CONFIG_HUSH_INTERACTIVE=y
CONFIG_HUSH_SAVEHISTORY=y
CONFIG_HUSH_JOB=y
CONFIG_HUSH_TICK=y
CONFIG_HUSH_IF=y
CONFIG_HUSH_LOOPS=y
CONFIG_HUSH_CASE=y
CONFIG_HUSH_FUNCTIONS=y
CONFIG_HUSH_LOCAL=y
CONFIG_HUSH_RANDOM_SUPPORT=y
CONFIG_HUSH_EXPORT_N=y
CONFIG_HUSH_MODE_X=y
# CONFIG_MSH is not set
CONFIG_FEATURE_SH_IS_ASH=y
# CONFIG_FEATURE_SH_IS_HUSH is not set
# CONFIG_FEATURE_SH_IS_NONE is not set
# CONFIG_FEATURE_BASH_IS_ASH is not set
# CONFIG_FEATURE_BASH_IS_HUSH is not set
CONFIG_FEATURE_BASH_IS_NONE=y
CONFIG_SH_MATH_SUPPORT=y
CONFIG_SH_MATH_SUPPORT_64=y
CONFIG_FEATURE_SH_EXTRA_QUIET=y
# CONFIG_FEATURE_SH_STANDALONE is not set
# CONFIG_FEATURE_SH_NOFORK is not set
CONFIG_FEATURE_SH_HISTFILESIZE=y

#
# System Logging Utilities
#
# CONFIG_SYSLOGD is not set
# CONFIG_FEATURE_ROTATE_LOGFILE is not set
# CONFIG_FEATURE_REMOTE_LOG is not set
# CONFIG_FEATURE_SYSLOGD_DUP is not set
# CONFIG_FEATURE_SYSLOGD_CFG is not set
CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0
# CONFIG_FEATURE_IPC_SYSLOG is not set
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
# CONFIG_LOGREAD is not set
# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set
# CONFIG_KLOGD is not set
# CONFIG_FEATURE_KLOGD_KLOGCTL is not set
# CONFIG_LOGGER is not set


code:
if previously a dependency was already installed, butch would not
try if its dependencies are as well installed.

diff --git a/butch.c b/butch.c
index 4159d0b..70d8ba7 100644
--- a/butch.c
+++ b/butch.c
@@ -505,11 +505,6 @@ static void queue_package(pkgstate* state, stringptr* packagename, jobtype jt, i

 	if(is_in_queue(packagename, queue)) goto end;

-	if(!force && is_installed(state, packagename)) {
-		ulz_fprintf(1, "package %s is already installed, skipping %s\n", packagename->ptr, queue_names[jt]);
-		goto end;
-	}
-
 	uint32_t hash = stringptr_hash(packagename);
 	pkgdata* pkg = packagelist_get(state->package_list, packagename, hash);
 	unsigned i;
@@ -524,6 +519,11 @@ static void queue_package(pkgstate* state, stringptr* packagename, jobtype jt, i
 		pkg = packagelist_get(state->package_list, packagename, hash);
 	}

+	if(!force && is_installed(state, packagename)) {
+		ulz_fprintf(1, "package %s is already installed, skipping %s\n", packagename->ptr, queue_names[jt]);
+		goto end;
+	}
+
 	if(
 		// if sizeof mirrors is 0, it is a meta package
 		(jt == JT_DOWNLOAD && stringptrlist_getsize(pkg->mirrors))
--
2.7.3


code:
bugfix: update hashes in butch.db also when rebuilding

diff --git a/butch.c b/butch.c
index 70d8ba7..3da61b3 100644
--- a/butch.c
+++ b/butch.c
@@ -774,13 +774,13 @@ static void mark_finished(pkgstate* state, stringptr* name) {
 	if(idx == -1) {
 		stringptrlist_add_strdup(state->installed_packages.names, name);
 		stringptrlist_add_strdup(state->installed_packages.hashes, SPMAKE(hash, 128));
-		write_installed_dat(state);
 	} else { /* update hash */
 		stringptr* e = stringptrlist_get(state->installed_packages.hashes, idx);
 		free(e->ptr);
 		char* e2 = stringptr_strdup(SPMAKE(hash, 128));
 		stringptrlist_set(state->installed_packages.hashes, idx, e2, 128);
 	}
+	write_installed_dat(state);
 }

 static void prepare_update(pkgstate* state, stringptrlist* packages2install) {
--
2.7.3


code:
#!/bin/sh
%BUTCH_CONFIG
get_file_name() {
printf "%s" "$1" | awk '{n=split($0,a,"/");print a[n];}'
}
get_file_size() {
wc -c "$1" | cut -d " " -f 1
}
check_sha512() {
[ $(sha512sum "$2"|cut -d " " -f 1) = "$1" ] && return 0
return 1
}
fail() {
	printf "ERROR: %s\n" "$1" >&2
}

if [ -z "$tarball" ] ; then
for i in %BUTCH_MIRROR_URLS ; do
	tarball=$(get_file_name "$i")
	break
done
fi
if [ -e "$C"/"$tarball" ] ; then
	[ "$filesize" = $(get_file_size "$C"/"$tarball") ] && {
		echo "tarball existing, passed size check. exiting."
		exit 0
	}
	fail "tarball exists but size differs from recipe"
	exit 99
fi
retries=5
butch_cache_dir="$C"
tmp=/tmp/butchdl.$$
rc=0
append() {
eval "$1=\"\${$1} \$2\""
eval "$1=\${$1# }"
}

download() {
	local url="$1"
	local out="$2"
	if [ "$USE_CURL" = 1 ] ; then
		curl -c /dev/null -C - --retry $retries -k -L "$url" -o "$out"
	else
		if ! wget --help 2>&1 | grep BusyBox > /dev/null ; then
			append wgetflags "--tries=$retries"
			append wgetflags --no-check-certificate
		fi
		wget $wgetflags -O "$out" -c "$url"
	fi
}

cleanup() {
	[ -e "$tmp" ] && { cat $tmp ; rm $tmp ; }
}

FALLBACK_MIRROR=http://tar.sabotage.tech
FALLBACK=$FALLBACK_MIRROR/%BUTCH_PACKAGE_NAME/$tarball
echo "in case the download process was killed, see $tmp for wget/curl output"
for url in %BUTCH_MIRROR_URLS $FALLBACK ; do
if ! download "$url" "$butch_cache_dir/$tarball".wip >$tmp 2>&1 ; then
	rc=1
	grep 404 < $tmp > /dev/null && { rc=44 ; fail "HTTP 404 FILE NOT FOUND" ; }
	[ "$rc" = 1 ] && fail "UNKNOWN DL ERROR, SEE LOG"
	cleanup
else
	mv "$butch_cache_dir"/"$tarball".wip \
	   "$butch_cache_dir"/"$tarball"
	rc=0
	if [ -n "$filesize" ] && [ "$filesize" != $(get_file_size "$butch_cache_dir"/"$tarball") ] ; then
		rc=22
		fail "FILESIZE MISMATCH"
	fi
	if [ -n "$sha512" ] && ! check_sha512 "$sha512" "$butch_cache_dir"/"$tarball" ; then
		rc=11
		fail "SHA512 CHECKSUM MISMATCH"
	fi
	break
fi
done
cleanup
exit $rc


code:
#!/bin/sh

start=$(date +%s)
printf "%s: start\n" "`date`"

# ALL VARIABLES STARTING WITH % WILL BE REPLACED BY BUTCH
# WITH VALUES TAKEN FROM THE PKG FILE.

# BUTCH_CONFIG will get replaced by the environment variables
# that butch uses (R,S,C...).
%BUTCH_CONFIG
BUTCH_HAVE_TARBALL=false
[ -n "%BUTCH_MIRROR_URLS" ] || [ -n "$tarball" ] && BUTCH_HAVE_TARBALL=true
get_file_name() {
printf "%s" "$1" | awk '{n=split($0,a,"/");print a[n];}'
}
get_file_ext() {
printf "%s" "$1" | awk '{n=split($0,a,".");print a[n];}'
}
strip_file_ext() {
case "$1" in
*.tar.*) printf "%s" "$1"| sed 's/\.tar\.[0-9a-z]*$//' ;;
*) le=$(get_file_ext "$1"| wc -c)
   ls=$(printf "%s" "$1"|wc -c)
   l=$(($ls - $le))
   printf "%s" "$1"|cut -b -$l
   ;;
esac
}
if [ -z "$tarball" ] && $BUTCH_HAVE_TARBALL ; then
for i in %BUTCH_MIRROR_URLS ; do
	tarball=$(get_file_name "$i")
	break
done
fi

BUTCH_TARBALL="$tarball"
if [ -z "$tardir" ] && $BUTCH_HAVE_TARBALL ; then
	tardir=$(strip_file_ext "$tarball")
fi
BUTCH_TARDIR="$tardir"

[ -z "$B" ] && B=$S/build

# some settings to influence this script...
# note that you could set similar stuff using env variables.
butch_do_config_cache=true
butch_do_cleanup_builddir=true
butch_do_custom_destdir=true
# the options below all require a custom destdir to be set.
butch_do_cleanup_custom_destdir=true
[ -z "$butch_do_relocate" ] && butch_do_relocate=true
[ -z "$butch_do_filelists" ] && butch_do_filelists=true
[ -z "$butch_do_create_tarball" ] && butch_do_create_tarball=false
butch_do_separate_debug_info=true
[ -z "$butch_do_overwrite_on_copy" ] && butch_do_overwrite_on_copy=false

[ -z "$butch_filelists" ] && butch_filelists="$S/filelists/"
[ -z "$butch_tarballs_used" ] && butch_tarballs_used="$S/tarballs_used.txt"
[ -z "$butch_pack_dest" ] && butch_pack_dest="$S/dist/"

butch_package_name=%BUTCH_PACKAGE_NAME
butch_prefix=/

filelist="$butch_filelists/$butch_package_name.txt"

# making the prefix empty instead of / seems like a good idea to not get ugly double slashes
# when concatenating paths. however this leads to multiple issues in buggy packages,
# but these have been fixed now (see openssl-dynamic, perl, xcb-proto for reference).
[ "$butch_prefix" = "/" ] && butch_prefix=
# butch_root_dir contains the root path passed in $R.
# once inside the chroot, it is /. we use the butch variable in case a script overwrites $R,
# and in order to be able to swap it out easily once i decided to replace the variables with
# a config file or so.
# use it, if you need to reference something that lies in the directory structure.
butch_root_dir="$R"
# butch_staging_dir is where packages get installed into via DESTDIR
# and then linked into $R
[ -z "$butch_staging_dir" ] && butch_staging_dir=/opt
[ "$butch_root_dir" = "/" ] && butch_root_dir=
butch_custom_destdir_base="$butch_staging_dir"/$butch_package_name
butch_custom_destdir="$butch_root_dir""$butch_custom_destdir_base"

#currently passing a version from a package is not implemented.
butch_package_version=0.0.0

# if we unlink these packages nothing will work anymore
for i in butch busybox coreutils gcc454 gcc424 gcc447 gcc463 gcc464 gcc472 gcc473 gcc474 gcc485 gcc493 gcc520 gcc530 binutils musl-git musl sed make grep ; do
	[ "$butch_package_name" = "$i" ] && butch_do_cleanup_custom_destdir=false
done

# butch_install_dir denotes the DESTDIR passed to make
if $butch_do_custom_destdir ; then
	butch_install_dir="$butch_custom_destdir"
	if $butch_do_cleanup_custom_destdir ; then
		rm -rf "$butch_custom_destdir"
		if [ "$butch_do_filelists" ] && [ -e "$filelist" ] ; then
			"$K"/bin/butch-unlink "$butch_package_name"
			rm -f "$filelist"
		fi
	fi
else
	butch_install_dir=""
	butch_do_relocate=false
fi
[ -z "$butch_install_dir" ] || mkdir -p "$butch_install_dir"

#butch_cache_dir is the place where tarballs are found
butch_cache_dir="$C"

# this is were stuff gets extracted to and built in
butch_build_root="$B/$butch_package_name"
butch_build_dir="$butch_build_root/$BUTCH_TARDIR"

#this is the location of our optimized config.cache
butch_configure_cache="$K/config.cache"

[ -z "$CC" ]  && CC=cc
[ -z "$CXX" ]  && CXX=c++
[ -z "$HOSTCC" ]  && HOSTCC="$CC"
[ -z "$HOSTCXX" ]  && HOSTCXX="$CXX"

debug_build=0
if [ -f "$butch_root_dir"/etc/butch-optflags.sh ] ; then
	user_optimizations_file="$butch_root_dir"/etc/butch-optflags.sh
	printf "%s: sourcing user defined optimization config %s\n" "`date`" "$user_optimizations_file"
	. "$user_optimizations_file"
	printf "%s\n" "$optcflags" | \
		grep -E '(^|\s)[-]g[123]*($|\s)' >/dev/null && \
		debug_build=1
fi

if $butch_do_cleanup_builddir && [ -e "$butch_build_dir" ] ; then
	rm -rf "$butch_build_dir"
fi
[ -d "$butch_build_root" ] || mkdir -p "$butch_build_root"
cd "$butch_build_root"

# BUTCH_HAVE_TARBALL will be replaced by true or false
# depending on whether a tarball is used by the pkg
if $BUTCH_HAVE_TARBALL ; then

	printf '%s\n' "$BUTCH_TARBALL" >> "$butch_tarballs_used"
	printf "%s: starting to untar\n" "`date`"
	tarflags=
	case $(get_file_ext "$BUTCH_TARBALL") in
		xz) tarflags=xJf ;;
		lzma) tarflags=xaf ;;
		bz2) tarflags=xjf ;;
		gz) tarflags=xzf ;;
		tgz) tarflags=xzf ;;
	esac
	if [ -z $tarflags ] || ! tar $tarflags "$butch_cache_dir/$BUTCH_TARBALL" ; then
		case "$BUTCH_TARBALL" in
			*.tar.xz)
				# old gnu tar passes .xz to lzma instead of xz
				if ! xz -dc "$butch_cache_dir/$BUTCH_TARBALL" | tar x ; then
					echo "tarball error"
					exit 1
				fi ;;
			*.tar.*)
				echo "tarball error"
				exit 1 ;;
			*.zip)
				unzip "$butch_cache_dir/$BUTCH_TARBALL" || {
				echo "unzip error"
				exit 1 ; } ;;
			*)
				echo "seems we're not dealing with a tarball"
				echo "handing control to package file..." ;;
		esac
	fi
	printf "%s: untar done\n" "`date`"
	cd "$butch_build_dir"

	# this copies a config.cache template (gets installed by pkg/config-cache)
	# into the actual builddir, so configure skips some timewasting tests
	if $butch_do_config_cache ; then
		[ -e "$butch_configure_cache" ] && cp -f "$butch_configure_cache" . || true
	fi
fi

printf "%s: start build\n" "`date`"
# this will be replaced by the contents of the pkg's [build] section.
# note that all critical commands in the buildscript should use || exit 1
# so that it aborts on error!
set -e
%BUTCH_BUILDSCRIPT
set +e

printf "%s: end build\n" "`date`"
echo "post buildscript phase..."

# a package that doesn't want to be handled by the code below this line
# can just call exit 0 as the last statement
# if it wants to get some other stuff handled it could simply override
# butch_install_dir (e.g. for sabotages relocate_toolchain script)
cd "$butch_install_dir"
[ `ls | wc -l` = "0" ] && have_files=false || have_files=true
[ -d share/pkgconfig ] && {
echo "error: package installed pkgconfig files into /share"
echo "please fix package (examples: xtrans eudev libyajl usbutils shared-mime-info)"
exit 1
}
if $have_files ; then
	if $butch_do_separate_debug_info && [ "$debug_build" = 1 ] ; then
		printf "stripping debug info into external files..."
		mkdir -p lib/debug && chmod 775 lib/debug
		for i in lib/*.so* bin/* ; do
			printf "%s" "$i" | grep '\*'>/dev/null && continue
			[ -L "$i" ] || [ -d "$i" ] && continue
			case "$i" in bin*)
				elf=$(dd if="$i" bs=1 skip=1 count=3 2>/dev/null)
				[ "$elf" != "ELF" ] && continue
			esac
			name=$(printf "%s" "$i" | sed 's@/@_@')
			"$CROSS_COMPILE"objcopy --only-keep-debug "$i" lib/debug/"$name".dbg &&
			"$CROSS_COMPILE"strip --strip-debug --strip-unneeded "$i" &&
			"$CROSS_COMPILE"objcopy --add-gnu-debuglink=lib/debug/"$name".dbg "$i"
		done
		chmod 664 lib/debug/*
		echo done
	fi

	# here you could place some code that makes a tarball out of $butch_install_dir
	# moves the contents to / or create some sort of package file list.
	# e.g.
	if $butch_do_filelists ; then
		$K/bin/butch-genfilelist "$butch_package_name"
	fi

	if $butch_do_relocate ; then
		# now we make a symlink from each file into butch_prefix
		"$K"/bin/butch-relocate "$butch_package_name"
	fi

	if $butch_do_create_tarball ; then
		(
		mkdir -p "$butch_pack_dest" && cd "$butch_pack_dest" && \
		"$K"/bin/butch-pack --xz "$butch_package_name"
		)
	fi

fi

printf "%s: done.\n" "`date`"
[ -n "$start" ] && printf "total build time: %d seconds.\n" $(($(date +%s) - $start))


code:
--- bzip2-1.0.6.old/Makefile-libbz2_so
+++ bzip2-1.0.6/Makefile-libbz2_so
@@ -25,6 +25,7 @@
 CC=gcc
 BIGFILES=-D_FILE_OFFSET_BITS=64
 CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
+LDFLAGS=

 OBJS= blocksort.o  \
       huffman.o    \
@@ -35,8 +36,8 @@
       bzlib.o

 all: $(OBJS)
-	$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.6 $(OBJS)
-	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6
+	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.6 $(OBJS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.6
 	rm -f libbz2.so.1.0
 	ln -s libbz2.so.1.0.6 libbz2.so.1.0


code:
/* c_rehash.c - Create hash symlinks for certificates
 * C implementation based on the original Perl and shell versions
 *
 * Copyright (c) 2013-2014 Timo Teräs <timo.teras@iki.fi>
 * All rights reserved.
 *
 * This software is licensed under the MIT License.
 * Full license available at: http://opensource.org/licenses/MIT
 */

#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>

#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/x509.h>

#define MAX_COLLISIONS	256
#define countof(x) 	(sizeof(x) / sizeof(x[0]))

#if 0
#define DEBUG(args...) fprintf(stderr, args)
#else
#define DEBUG(args...)
#endif

struct entry_info {
	struct entry_info *next;
	char *filename;
	unsigned short old_id;
	unsigned char need_symlink;
	unsigned char digest[EVP_MAX_MD_SIZE];
};

struct bucket_info {
	struct bucket_info *next;
	struct entry_info *first_entry, *last_entry;
	unsigned int hash;
	unsigned short type;
	unsigned short num_needed;
};

enum Type {
	TYPE_CERT = 0,
	TYPE_CRL
};

static const char *symlink_extensions[] = { "", "r" };
static const char *file_extensions[] = { "pem", "crt", "cer", "crl" };

static int old_compat = 1;
static int evpmdsize;
static const EVP_MD *evpmd;

static struct bucket_info *hash_table[257];

static void bit_set(unsigned char *set, unsigned bit)
{
	set[bit / 8] |= 1 << (bit % 8);
}

static int bit_isset(unsigned char *set, unsigned bit)
{
	return set[bit / 8] & (1 << (bit % 8));
}

static void add_entry(
	int type, unsigned int hash,
	const char *filename, const unsigned char *digest,
	int need_symlink, unsigned short old_id)
{
	struct bucket_info *bi;
	struct entry_info *ei, *found = NULL;
	unsigned int ndx = (type + hash) % countof(hash_table);

	for (bi = hash_table[ndx]; bi; bi = bi->next)
		if (bi->type == type && bi->hash == hash)
			break;
	if (!bi) {
		bi = calloc(1, sizeof(*bi));
		if (!bi) return;
		bi->next = hash_table[ndx];
		bi->type = type;
		bi->hash = hash;
		hash_table[ndx] = bi;
	}

	for (ei = bi->first_entry; ei; ei = ei->next) {
		if (digest && memcmp(digest, ei->digest, evpmdsize) == 0) {
			fprintf(stderr,
				"WARNING: Skipping duplicate certificate in file %s\n",
				filename);
			return;
		}
		if (!strcmp(filename, ei->filename)) {
			found = ei;
			if (!digest) break;
		}
	}
	ei = found;
	if (!ei) {
		if (bi->num_needed >= MAX_COLLISIONS) return;
		ei = calloc(1, sizeof(*ei));
		if (!ei) return;

		ei->old_id = ~0;
		ei->filename = strdup(filename);
		if (bi->last_entry) bi->last_entry->next = ei;
		if (!bi->first_entry) bi->first_entry = ei;
		bi->last_entry = ei;
	}

	if (old_id < ei->old_id) ei->old_id = old_id;
	if (need_symlink && !ei->need_symlink) {
		ei->need_symlink = 1;
		bi->num_needed++;
		memcpy(ei->digest, digest, evpmdsize);
	}
}

static int handle_symlink(const char *filename, const char *fullpath)
{
	static char xdigit[] = {
		 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
		-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
		-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
		-1,10,11,12,13,14,15
	};
	char linktarget[NAME_MAX], *endptr;
	unsigned int hash = 0;
	unsigned char ch;
	int i, type, id;
	ssize_t n;

	for (i = 0; i < 8; i++) {
		ch = filename[i] - '0';
		if (ch >= countof(xdigit) || xdigit[ch] < 0)
			return -1;
		hash <<= 4;
		hash += xdigit[ch];
	}
	if (filename[i++] != '.') return -1;
	for (type = countof(symlink_extensions) - 1; type > 0; type--)
		if (strcasecmp(symlink_extensions[type], &filename[i]) == 0)
			break;
	i += strlen(symlink_extensions[type]);

	id = strtoul(&filename[i], &endptr, 10);
	if (*endptr != 0) return -1;

	n = readlink(fullpath, linktarget, sizeof(linktarget));
	if (n >= sizeof(linktarget) || n < 0) return -1;
	linktarget[n] = 0;

	DEBUG("Found existing symlink %s for %08x (%d), certname %s\n",
		filename, hash, type, linktarget);
	add_entry(type, hash, linktarget, NULL, 0, id);
	return 0;
}

static int handle_certificate(const char *filename, const char *fullpath)
{
	STACK_OF(X509_INFO) *inf;
	X509_INFO *x;
	BIO *b;
	const char *ext;
	unsigned char digest[EVP_MAX_MD_SIZE];
	X509_NAME *name = NULL;
	int i, type, ret = -1;

	ext = strrchr(filename, '.');
	if (ext == NULL) return 0;
	for (i = 0; i < countof(file_extensions); i++) {
		if (strcasecmp(file_extensions[i], ext+1) == 0)
			break;
	}
	if (i >= countof(file_extensions)) return -1;

	b = BIO_new_file(fullpath, "r");
	if (!b) return -1;
	inf = PEM_X509_INFO_read_bio(b, NULL, NULL, NULL);
	BIO_free(b);
	if (!inf) return -1;

	if (sk_X509_INFO_num(inf) == 1) {
		x = sk_X509_INFO_value(inf, 0);
		if (x->x509) {
			type = TYPE_CERT;
			name = X509_get_subject_name(x->x509);
			X509_digest(x->x509, evpmd, digest, NULL);
		} else if (x->crl) {
			type = TYPE_CRL;
			name = X509_CRL_get_issuer(x->crl);
			X509_CRL_digest(x->crl, evpmd, digest, NULL);
		}
		if (name)
			add_entry(type, X509_NAME_hash(name), filename, digest, 1, ~0);
		if (name && old_compat)
			add_entry(type, X509_NAME_hash_old(name), filename, digest, 1, ~0);
	} else {
		fprintf(stderr,
			"WARNING: %s does not contain exactly one certificate or CRL: skipping\n",
			filename);
	}

	sk_X509_INFO_pop_free(inf, X509_INFO_free);

	return ret;
}

static int hash_dir(const char *dirname)
{
	struct bucket_info *bi, *nextbi;
	struct entry_info *ei, *nextei;
	struct dirent *de;
	struct stat st;
	unsigned char idmask[MAX_COLLISIONS / 8];
	int i, n, nextid, buflen, ret = -1;
	const char *pathsep;
	char *buf;
	DIR *d;

	if (access(dirname, R_OK|W_OK|X_OK) != 0)
		return -1;

	buflen = strlen(dirname);
	pathsep = (buflen && dirname[buflen-1] == '/') ? "" : "/";
	buflen += NAME_MAX + 2;
	buf = malloc(buflen);
	if (buf == NULL)
		goto err;

	printf("Doing %s\n", dirname);
	d = opendir(dirname);
	if (!d) goto err;

	while ((de = readdir(d)) != NULL) {
		if (snprintf(buf, buflen, "%s%s%s", dirname, pathsep, de->d_name) >= buflen)
			continue;
		if (lstat(buf, &st) < 0)
			continue;
		if (S_ISLNK(st.st_mode) && handle_symlink(de->d_name, buf) == 0)
			continue;
		handle_certificate(de->d_name, buf);
	}
	closedir(d);

	for (i = 0; i < countof(hash_table); i++) {
		for (bi = hash_table[i]; bi; bi = nextbi) {
			nextbi = bi->next;
			DEBUG("Type %d, hash %08x, num entries %d:\n", bi->type, bi->hash, bi->num_needed);

			nextid = 0;
			memset(idmask, 0, (bi->num_needed+7)/8);
			for (ei = bi->first_entry; ei; ei = ei->next)
				if (ei->old_id < bi->num_needed)
					bit_set(idmask, ei->old_id);

			for (ei = bi->first_entry; ei; ei = nextei) {
				nextei = ei->next;
				DEBUG("\t(old_id %d, need_symlink %d) Cert %s\n",
					ei->old_id, ei->need_symlink,
					ei->filename);

				if (ei->old_id < bi->num_needed) {
					/* Link exists, and is used as-is */
					snprintf(buf, buflen, "%08x.%s%d", bi->hash, symlink_extensions[bi->type], ei->old_id);
					printf("%s => %s\n", buf, ei->filename);
				} else if (ei->need_symlink) {
					/* New link needed (it may replace something) */
					while (bit_isset(idmask, nextid))
						nextid++;

					snprintf(buf, buflen, "%s%s%n%08x.%s%d",
						 dirname, pathsep, &n, bi->hash,
						 symlink_extensions[bi->type],
						 nextid);
					printf("%s => %s\n", &buf[n], ei->filename);
					unlink(buf);
					symlink(ei->filename, buf);
				} else {
					/* Link to be deleted */
					snprintf(buf, buflen, "%s%s%n%08x.%s%d",
						 dirname, pathsep, &n, bi->hash,
						 symlink_extensions[bi->type],
						 ei->old_id);
					DEBUG("nuke %s\n", &buf[n]);
					unlink(buf);
				}
				free(ei->filename);
				free(ei);
			}
			free(bi);
		}
		hash_table[i] = NULL;
	}

	ret = 0;
err:
	free(buf);
	return ret;
}

int main(int argc, char **argv)
{
	const char *env;
	int i;

	evpmd = EVP_sha1();
	evpmdsize = EVP_MD_size(evpmd);

	if (argc > 1) {
		for (i = 1; i < argc; i++)
			hash_dir(argv[i]);
	} else if ((env = getenv("SSL_CERT_DIR")) != NULL) {
		char *e, *m;
		m = strdup(env);
		for (e = strtok(m, ":"); e != NULL; e = strtok(NULL, ":"))
			hash_dir(e);
		free(m);
	} else {
		hash_dir("/etc/ssl/certs");
	}

	return 0;
}


code:
diff -rupN capchroot-0.1/capchroot.c capchroot-0.1-patched/capchroot.c
--- capchroot-0.1/capchroot.c	2009-07-22 19:17:30.000000000 +0000
+++ capchroot-0.1-patched/capchroot.c	2012-07-19 16:29:17.000000000 +0000
@@ -29,41 +29,11 @@ void usage(const char *progname) {
 int allowed(const char *path) {
   int ret = 0;
   struct pathcfg cfg;
-  struct passwd *user;
-  struct group *g;
-  char **c, **gr;
-
-  user = getpwuid(getuid());
-  if(user == NULL) {
-    perror("getpwuid");
-  }
-
   /* Initialize the cfg structure */
   if(getconfig(path, &cfg)) {
-    /* Check if the user was explicitly allowed */
-    for(c = cfg.users; *c != NULL; ++c) {
-      if((ret = !strcmp(*c, user->pw_name)))
-        break;
-    }
-
-    if(!ret) {
-      for(c = cfg.groups; *c != NULL; ++c) {
-        g = getgrnam(*c);
-        if(g == NULL)
-          continue;
-        /* First check if the group name is the primary group */
-        if((ret = g->gr_gid == user->pw_gid))
-          break;
-        /* Iterate over all group members to see if the user is in the group */
-        for(gr = g->gr_mem; *gr != NULL; gr++) {
-          if((ret = !strcmp(*gr, user->pw_name))) {
-            break;
-          }
-        }
-      }
-    }
     /* Free the components of cfg */
     getconfig_free(&cfg);
+	ret = 1;
   }
   return ret;
 }
diff -rupN capchroot-0.1/Makefile capchroot-0.1-patched/Makefile
--- capchroot-0.1/Makefile	2009-07-22 19:17:30.000000000 +0000
+++ capchroot-0.1-patched/Makefile	2012-07-19 16:31:03.000000000 +0000
@@ -1,13 +1,13 @@
 CC ?= gcc
 CFLAGS ?= -O2 -pipe
-LDFLAGS ?=
+LDFLAGS ?= -static
 INSTALL ?= install
-CONFIGFILE = /etc/capchroot.allow
+CONFIGFILE = /opt/bedrock/etc/capchroot.allow

 all: capchroot

 capchroot: capchroot.o configfile.o
-	$(CC) -Wall -o capchroot $(LDFLAGS) -lcap capchroot.o configfile.o
+	$(CC) -Wall -o capchroot $(LDFLAGS) capchroot.o configfile.o -lcap

 capchroot.o: capchroot.c configfile.h
 	$(CC) -Wall -c $(CFLAGS) -DCONFIGFILE=\"$(CONFIGFILE)\" capchroot.c


code:
diff -Naur cddetect-2.1-1ORIG/cddetect.c cddetect-2.1-1/cddetect.c
--- cddetect-2.1-1ORIG/cddetect.c	2008-06-17 22:30:25.000000000 +0800
+++ cddetect-2.1-1/cddetect.c	2014-12-14 14:52:24.000000000 +0800
@@ -22,7 +22,7 @@
 #include <errno.h>
 #include <linux/cdrom.h>
 #include <linux/iso_fs.h>
-
+#include <limits.h>

 #define CDDEVICE "/dev/cdrom"


code:
/* Copyright (C) 2013, Felix Janda <felix.janda@posteo.de>

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.

SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>

void xwrite(FILE *f, void *p, size_t size)
{
  if (fwrite(p, 1, size, f) != size) err(1, 0);
}

int main(void)
{
  FILE *f;
  char cert[4096], ecert[4096*4/3 + 100];
  char *line = 0, *tmp, *filename, *label, *pcert = 0;
  ssize_t len;
  size_t size, certsize;
  int trust;
  char **blacklist = 0, **node;

  filename = "./blacklist.txt";
  if (!(f = fopen(filename, "r"))) err(1, "%s", filename);
  while ((len = getline(&line, &size, f)) != -1) {
    if ((line[0] != '#') && (len > 1)) {
      if (!(node = malloc(sizeof(void*) + len))) err(1, 0);
      *node = (char*)blacklist;
      memcpy(node + 1, line, len);
      blacklist = node;
    }
  }
  fclose(f);

  filename = "./certdata.txt";
  if (!(f = fopen(filename, "r"))) err(1, "%s", filename);
  while ((len = getline(&line, &size, f)) != -1) {
    tmp = line;
    if (line[0] == '#') continue;
    if (pcert) {
      if (!strcmp(line, "END\n")) {
        char *base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                       "abcdefghijklmnopqrstuvwxyz0123456789+/";
        size_t i, j, k, val;

        for (i = 0, val = 0, tmp = ecert; i < (size_t)(pcert - cert); i++) {
          val = (val << 8) + (unsigned char)cert[i];
          if (i % 3 == 2) {
            for (j = 0; j < 4; j++, val >>= 6) tmp[3 - j] = base64[val & 0x3f];
            tmp += 4;
          }
          if (i && !(i % 48)) {
            *tmp = '\n';
            tmp++;
          }
        }
        if (k = i % 3) {
          tmp[2] = '=';
          tmp[3] = '=';
          val <<= 6 - 2*k;
          for (j = 0; j < k + 1; j++, val >>= 6) tmp[k - j] = base64[val & 0x3f];
          tmp += 4;
        }
        certsize = tmp - ecert;
        pcert = 0;
      } else while (sscanf(tmp, "\\%hho", pcert) == 1) pcert++, tmp += 4;
    } else if (!memcmp(line, "CKA_LABEL UTF8 ", 15)) {

      char *p2, *tmp2;
      len -= 15;
      if (!(label = malloc(len))) err(1, 0);
      memcpy(label, line + 15, len);
      trust = 0;
      for (node = blacklist; node; node = (char**)*node)
        if (!strcmp(label, (char*)(node + 1))) trust = 4;
      if (!(p2 = malloc(len + 2))) err(1, 0);
      for (tmp = label + 1, tmp2 = p2; *tmp != '"'; tmp++, tmp2++) {
        switch (*tmp) {
        case '\\':
          if (sscanf(tmp, "\\x%hhx", tmp2)!=1) errx(1, "Bad triple: %s\n", tmp);
          tmp += 3;
          break;
        case '/':
        case ' ':
          *tmp2 = '_';
          break;
        case '(':
        case ')':
          *tmp2 = '=';
          break;
        default:
          *tmp2 = *tmp;
        }
      }
      strcpy(tmp2, ".crt");
      free(label);
      label = p2;
    } else if (!strcmp(line, "CKA_VALUE MULTILINE_OCTAL\n")) pcert = cert;
    else if (!memcmp(line, "CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_", 39)) {
      tmp += 39;
      if (!strcmp(tmp, "TRUSTED_DELEGATOR\n")) trust |= 1;
      else if (!strcmp(tmp, "NOT_TRUSTED\n")) trust |= 2;
    } else if (!memcmp(line,
                       "CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_", 44)) {
      tmp += 44;
      if (!strcmp(tmp, "TRUSTED_DELEGATOR\n")) trust |= 1;
      else if (!strcmp(tmp, "NOT_TRUSTED\n")) trust |= 2;
      if (!trust) printf("Ignoring %s\n", label);
      if (trust == 1) {
        FILE *out;
        if (!(out = fopen(label, "w"))) err(1, "%s", label);
        xwrite(out, "-----BEGIN CERTIFICATE-----\n", 28);
        xwrite(out, ecert, certsize);
        xwrite(out, "\n-----END CERTIFICATE-----\n", 27);
        fclose(out);
      }
    }
  }
  fclose(f);

  while (blacklist) {
    node = (char**)*blacklist;
    free(blacklist);
    blacklist = node;
  }
  free(line);
  free(label);
  return 0;
}