Skip to contentSkip to conversation

Download patches for Busybox

PATCH New Thomas Petazzoni 3 participants 6 messages Apr 24, 2013 – Apr 26, 2013

lore
Share & tools
lore
#0 lore raw

cover Download patches for Busybox

Hello,

As recently discussed on the list, here are two patches that let the busybox package download its patches, instead of storing them in Buildroot's source tree.

Thomas

Thomas Petazzoni (2):
package: use only the patch file name when applying patches
busybox: download patches instead of storing them in the source tree

 package/busybox/1.19.4/busybox-1.19.4-udhcp.patch  |  164 -----
 .../busybox/1.20.2/busybox-1.20.2-kernel_ver.patch |   25 -
 package/busybox/1.20.2/busybox-1.20.2-ntpd.patch   |   11 -
 .../1.20.2/busybox-1.20.2-pkg-config-selinux.patch |   67 --
 .../1.20.2/busybox-1.20.2-sys-resource.patch       |  123 ----
 package/busybox/1.21.0/busybox-1.21.0-mdev.patch   |  643 --------------------
 .../busybox/1.21.0/busybox-1.21.0-platform.patch   |   24 -
 package/busybox/1.21.0/busybox-1.21.0-xz.patch     |   84 ---
 package/busybox/busybox.mk                         |   12 +
 package/pkg-generic.mk                             |    2 +-
 10 files changed, 13 insertions(+), 1142 deletions(-)
 delete mode 100644 package/busybox/1.19.4/busybox-1.19.4-udhcp.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-kernel_ver.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-ntpd.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-pkg-config-selinux.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-sys-resource.patch
 delete mode 100644 package/busybox/1.21.0/busybox-1.21.0-mdev.patch
 delete mode 100644 package/busybox/1.21.0/busybox-1.21.0-platform.patch
 delete mode 100644 package/busybox/1.21.0/busybox-1.21.0-xz.patch
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 package: use only the patch file name when applying patches

Currently, the <pkg>_PATCH variable assumes that the patches listed are in the same directory as the downloaded tarball. This prevents to get patches in other locations on the same site, like is the case with Busybox patches: the tarball is at /downloads/, the patches are at /downloads/fixes-<version>/. So if you put BUSYBOX_PATCH = fixes-<version>/foobar.patch, the current logic downloads foobar.patch, but tries to apply fixes-<version>/foobar.patch, which doesn't make sense.

Therefore, we add a call to $(notdir ...) to get just the patch file name.

---
 package/pkg-generic.mk |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/pkg-generic.mk +1 -1
index e6bc955..5dcfc8d 100644
@@ -86,7 +86,7 @@ $(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $($(PKG)_DIR_PREFIX)/$(RAWNAME)
 $(BUILD_DIR)/%/.stamp_patched:
 	@$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
 	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
-	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(p)$(sep))
+	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(notdir $(p))$(sep))
 	$(Q)( \
 	for D in $(PATCH_BASE_DIRS); do \
 	  if test -d $${D}; then \
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 busybox: download patches instead of storing them in the source tree

In reply to Thomas Petazzoni
---
 package/busybox/1.19.4/busybox-1.19.4-udhcp.patch  |  164 -----
 .../busybox/1.20.2/busybox-1.20.2-kernel_ver.patch |   25 -
 package/busybox/1.20.2/busybox-1.20.2-ntpd.patch   |   11 -
 .../1.20.2/busybox-1.20.2-pkg-config-selinux.patch |   67 --
 .../1.20.2/busybox-1.20.2-sys-resource.patch       |  123 ----
 package/busybox/1.21.0/busybox-1.21.0-mdev.patch   |  643 --------------------
 .../busybox/1.21.0/busybox-1.21.0-platform.patch   |   24 -
 package/busybox/1.21.0/busybox-1.21.0-xz.patch     |   84 ---
 package/busybox/busybox.mk                         |   12 +
 9 files changed, 12 insertions(+), 1141 deletions(-)
 delete mode 100644 package/busybox/1.19.4/busybox-1.19.4-udhcp.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-kernel_ver.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-ntpd.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-pkg-config-selinux.patch
 delete mode 100644 package/busybox/1.20.2/busybox-1.20.2-sys-resource.patch
 delete mode 100644 package/busybox/1.21.0/busybox-1.21.0-mdev.patch
 delete mode 100644 package/busybox/1.21.0/busybox-1.21.0-platform.patch
 delete mode 100644 package/busybox/1.21.0/busybox-1.21.0-xz.patch
package/busybox/1.19.4/busybox-1.19.4-udhcp.patch deleted +0 -164
deleted file mode 100644
index 94d5f34..0000000
@@ -1,164 +0,0 @@
---- busybox-1.19.4/networking/udhcp/common.c
-+++ busybox-1.19.4-udhcp/networking/udhcp/common.c
-@@ -29,16 +29,16 @@ const struct dhcp_optflag dhcp_optflags[
- //	{ OPTION_IP | OPTION_LIST                 , 0x07 }, /* DHCP_LOG_SERVER    */
- //	{ OPTION_IP | OPTION_LIST                 , 0x08 }, /* DHCP_COOKIE_SERVER */
- 	{ OPTION_IP | OPTION_LIST                 , 0x09 }, /* DHCP_LPR_SERVER    */
--	{ OPTION_STRING               | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME     */
-+	{ OPTION_STRING_HOST          | OPTION_REQ, 0x0c }, /* DHCP_HOST_NAME     */
- 	{ OPTION_U16                              , 0x0d }, /* DHCP_BOOT_SIZE     */
--	{ OPTION_STRING               | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME   */
-+	{ OPTION_STRING_HOST          | OPTION_REQ, 0x0f }, /* DHCP_DOMAIN_NAME   */
- 	{ OPTION_IP                               , 0x10 }, /* DHCP_SWAP_SERVER   */
- 	{ OPTION_STRING                           , 0x11 }, /* DHCP_ROOT_PATH     */
- 	{ OPTION_U8                               , 0x17 }, /* DHCP_IP_TTL        */
- 	{ OPTION_U16                              , 0x1a }, /* DHCP_MTU           */
- 	{ OPTION_IP                   | OPTION_REQ, 0x1c }, /* DHCP_BROADCAST     */
- 	{ OPTION_IP_PAIR | OPTION_LIST            , 0x21 }, /* DHCP_ROUTES        */
--	{ OPTION_STRING                           , 0x28 }, /* DHCP_NIS_DOMAIN    */
-+	{ OPTION_STRING_HOST                      , 0x28 }, /* DHCP_NIS_DOMAIN    */
- 	{ OPTION_IP | OPTION_LIST                 , 0x29 }, /* DHCP_NIS_SERVER    */
- 	{ OPTION_IP | OPTION_LIST     | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER    */
- 	{ OPTION_IP | OPTION_LIST                 , 0x2c }, /* DHCP_WINS_SERVER   */
-@@ -46,7 +46,7 @@ const struct dhcp_optflag dhcp_optflags[
- 	{ OPTION_IP                               , 0x36 }, /* DHCP_SERVER_ID     */
- 	{ OPTION_STRING                           , 0x38 }, /* DHCP_ERR_MESSAGE   */
- //TODO: must be combined with 'sname' and 'file' handling:
--	{ OPTION_STRING                           , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
-+	{ OPTION_STRING_HOST                      , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
- 	{ OPTION_STRING                           , 0x43 }, /* DHCP_BOOT_FILE     */
- //TODO: not a string, but a set of LASCII strings:
- //	{ OPTION_STRING                           , 0x4D }, /* DHCP_USER_CLASS    */
-@@ -143,6 +143,7 @@ const uint8_t dhcp_option_lengths[] ALIG
- 	[OPTION_IP_PAIR] = 8,
- //	[OPTION_BOOLEAN] = 1,
- 	[OPTION_STRING] =  1,  /* ignored by udhcp_str2optset */
-+	[OPTION_STRING_HOST] = 1,  /* ignored by udhcp_str2optset */
- #if ENABLE_FEATURE_UDHCP_RFC3397
- 	[OPTION_DNS_STRING] = 1,  /* ignored by both udhcp_str2optset and xmalloc_optname_optval */
- 	[OPTION_SIP_SERVERS] = 1,
-@@ -411,7 +412,9 @@ static NOINLINE void attach_option(
- 			/* actually 255 is ok too, but adding a space can overlow it */
- 
- 			existing->data = xrealloc(existing->data, OPT_DATA + 1 + old_len + length);
--			if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING) {
-+			if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING
-+			 || (optflag->flags & OPTION_TYPE_MASK) == OPTION_STRING_HOST
-+			) {
- 				/* add space separator between STRING options in a list */
- 				existing->data[OPT_DATA + old_len] = ' ';
- 				old_len++;
-@@ -475,6 +478,7 @@ int FAST_FUNC udhcp_str2optset(const cha
- 				retval = udhcp_str2nip(val, buffer + 4);
- 			break;
- 		case OPTION_STRING:
-+		case OPTION_STRING_HOST:
- #if ENABLE_FEATURE_UDHCP_RFC3397
- 		case OPTION_DNS_STRING:
- #endif
---- busybox-1.19.4/networking/udhcp/common.h
-+++ busybox-1.19.4-udhcp/networking/udhcp/common.h
-@@ -80,6 +80,9 @@ enum {
- 	OPTION_IP = 1,
- 	OPTION_IP_PAIR,
- 	OPTION_STRING,
-+	/* Opts of STRING_HOST type will be sanitized before they are passed
-+	 * to udhcpc script's environment: */
-+	OPTION_STRING_HOST,
- //	OPTION_BOOLEAN,
- 	OPTION_U8,
- 	OPTION_U16,
---- busybox-1.19.4/networking/udhcp/dhcpc.c
-+++ busybox-1.19.4-udhcp/networking/udhcp/dhcpc.c
-@@ -101,6 +101,7 @@ static const uint8_t len_of_option_as_st
- 	[OPTION_IP_PAIR         ] = sizeof("255.255.255.255 ") * 2,
- 	[OPTION_STATIC_ROUTES   ] = sizeof("255.255.255.255/32 255.255.255.255 "),
- 	[OPTION_STRING          ] = 1,
-+	[OPTION_STRING_HOST     ] = 1,
- #if ENABLE_FEATURE_UDHCP_RFC3397
- 	[OPTION_DNS_STRING      ] = 1, /* unused */
- 	/* Hmmm, this severely overestimates size if SIP_SERVERS option
-@@ -135,6 +136,63 @@ static int mton(uint32_t mask)
- 	return i;
- }
- 
-+/* Check if a given label represents a valid DNS label
-+ * Return pointer to the first character after the label upon success,
-+ * NULL otherwise.
-+ * See RFC1035, 2.3.1
-+ */
-+/* We don't need to be particularly anal. For example, allowing _, hyphen
-+ * at the end, or leading and trailing dots would be ok, since it
-+ * can't be used for attacks. (Leading hyphen can be, if someone uses
-+ * cmd "$hostname"
-+ * in the script: then hostname may be treated as an option)
-+ */
-+static const char *valid_domain_label(const char *label)
-+{
-+	unsigned char ch;
-+	unsigned pos = 0;
-+
-+	for (;;) {
-+		ch = *label;
-+		if ((ch|0x20) < 'a' || (ch|0x20) > 'z') {
-+			if (pos == 0) {
-+				/* label must begin with letter */
-+				return NULL;
-+			}
-+			if (ch < '0' || ch > '9') {
-+				if (ch == '\0' || ch == '.')
-+					return label;
-+				/* DNS allows only '-', but we are more permissive */
-+				if (ch != '-' && ch != '_')
-+					return NULL;
-+			}
-+		}
-+		label++;
-+		pos++;
-+		//Do we want this?
-+		//if (pos > 63) /* NS_MAXLABEL; labels must be 63 chars or less */
-+		//	return NULL;
-+	}
-+}
-+
-+/* Check if a given name represents a valid DNS name */
-+/* See RFC1035, 2.3.1 */
-+static int good_hostname(const char *name)
-+{
-+	//const char *start = name;
-+
-+	for (;;) {
-+		name = valid_domain_label(name);
-+		if (!name)
-+			return 0;
-+		if (!name[0])
-+			return 1;
-+			//Do we want this?
-+			//return ((name - start) < 1025); /* NS_MAXDNAME */
-+		name++;
-+	}
-+}
-+
- /* Create "opt_name=opt_value" string */
- static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name)
- {
-@@ -185,8 +243,11 @@ static NOINLINE char *xmalloc_optname_op
- 			break;
- 		}
- 		case OPTION_STRING:
-+		case OPTION_STRING_HOST:
- 			memcpy(dest, option, len);
- 			dest[len] = '\0';
-+			if (type == OPTION_STRING_HOST && !good_hostname(dest))
-+				safe_strncpy(dest, "bad", len);
- 			return ret;	 /* Short circuit this case */
- 		case OPTION_STATIC_ROUTES: {
- 			/* Option binary format:
-@@ -314,6 +375,7 @@ static char **fill_envp(struct dhcp_pack
- 	/* +1 element for each option, +2 for subnet option: */
- 	if (packet) {
- 		/* note: do not search for "pad" (0) and "end" (255) options */
-+//TODO: change logic to scan packet _once_
- 		for (i = 1; i < 255; i++) {
- 			temp = udhcp_get_option(packet, i);
- 			if (temp) {
package/busybox/1.20.2/busybox-1.20.2-kernel_ver.patch deleted +0 -25
deleted file mode 100644
index 456fb08..0000000
@@ -1,25 +0,0 @@
---- busybox-1.20.2/libbb/kernel_version.c
-+++ busybox-1.20.2-kernel_ver/libbb/kernel_version.c
-@@ -20,18 +20,15 @@
- int FAST_FUNC get_linux_version_code(void)
- {
- 	struct utsname name;
--	char *s;
-+	char *s, *t;
- 	int i, r;
- 
--	if (uname(&name) == -1) {
--		bb_perror_msg("can't get system information");
--		return 0;
--	}
--
-+	uname(&name); /* never fails */
- 	s = name.release;
- 	r = 0;
- 	for (i = 0; i < 3; i++) {
--		r = r * 256 + atoi(strtok(s, "."));
-+		t = strtok(s, ".");
-+		r = r * 256 + (t ? atoi(t) : 0);
- 		s = NULL;
- 	}
- 	return r;
package/busybox/1.20.2/busybox-1.20.2-ntpd.patch deleted +0 -11
deleted file mode 100644
index 17fc0b1..0000000
@@ -1,11 +0,0 @@
---- busybox-1.20.2/networking/ntpd.c
-+++ busybox-1.20.2-ntpd/networking/ntpd.c
-@@ -1840,7 +1840,7 @@ recv_and_process_client_pkt(void /*int f
- 
- 	/* Build a reply packet */
- 	memset(&msg, 0, sizeof(msg));
--	msg.m_status = G.stratum < MAXSTRAT ? G.ntp_status : LI_ALARM;
-+	msg.m_status = G.stratum < MAXSTRAT ? (G.ntp_status & LI_MASK) : LI_ALARM;
- 	msg.m_status |= (query_status & VERSION_MASK);
- 	msg.m_status |= ((query_status & MODE_MASK) == MODE_CLIENT) ?
- 			 MODE_SERVER : MODE_SYM_PAS;
package/busybox/1.20.2/busybox-1.20.2-pkg-config-selinux.patch deleted +0 -67

67 lines not on this page · raw message

package/busybox/1.20.2/busybox-1.20.2-sys-resource.patch deleted +0 -123

123 lines not on this page · raw message

package/busybox/1.21.0/busybox-1.21.0-mdev.patch deleted +0 -643

643 lines not on this page · raw message

package/busybox/1.21.0/busybox-1.21.0-platform.patch deleted +0 -24
deleted file mode 100644
index 9be6cb8..0000000
@@ -1,24 +0,0 @@
---- busybox-1.21.0/archival/libarchive/decompress_unxz.c
-+++ busybox-1.21.0-platform/archival/libarchive/decompress_unxz.c
-@@ -30,8 +30,8 @@ static uint32_t xz_crc32(const uint8_t *
- /* We use arch-optimized unaligned accessors */
- #define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); })
- #define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); })
--#define put_unaligned_le32(val, buf) move_to_unaligned16(buf, SWAP_LE32(val))
--#define put_unaligned_be32(val, buf) move_to_unaligned16(buf, SWAP_BE32(val))
-+#define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val))
-+#define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val))
- 
- #include "unxz/xz_dec_bcj.c"
- #include "unxz/xz_dec_lzma2.c"
---- busybox-1.21.0/include/platform.h
-+++ busybox-1.21.0-platform/include/platform.h
-@@ -228,7 +228,7 @@ typedef uint32_t bb__aliased_uint32_t FI
- # define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4))
- # define move_to_unaligned16(u16p, v) do { \
- 	uint16_t __t = (v); \
--	memcpy((u16p), &__t, 4); \
-+	memcpy((u16p), &__t, 2); \
- } while (0)
- # define move_to_unaligned32(u32p, v) do { \
- 	uint32_t __t = (v); \
package/busybox/1.21.0/busybox-1.21.0-xz.patch deleted +0 -84

84 lines not on this page · raw message

package/busybox/busybox.mk +12 -0
index 985203c..bb82074 100644
@@ -15,6 +15,18 @@ BUSYBOX_SOURCE = busybox-$(BUSYBOX_VERSION).tar.bz2
 BUSYBOX_LICENSE = GPLv2
 BUSYBOX_LICENSE_FILES = LICENSE
 
+ifeq ($(BUSYBOX_VERSION),1.21.0)
+BUSYBOX_PATCHES = mdev platform xz
+else ifeq ($(BUSYBOX_VERSION),1.20.2)
+BUSYBOX_PATCHES = kernel_ver ntpd pkg-config-selinux sys-resource
+else ifeq ($(BUSYBOX_VERSION),1.19.4)
+BUSYBOX_PATCHES = udhcp
+endif
+
+BUSYBOX_PATCH = \
+	$(foreach p,$(BUSYBOX_PATCHES),\
+		fixes-$(BUSYBOX_VERSION)/busybox-$(BUSYBOX_VERSION)-$(p).patch)
+
 BUSYBOX_CFLAGS = \
 	$(TARGET_CFLAGS) \
 	-I$(LINUX_HEADERS_DIR)/include
Signature · 1 line
1.7.9.5
#3 lore raw

cover Download patches for Busybox

In reply to Thomas Petazzoni
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Thomas> Hello,
Thomas> As recently discussed on the list, here are two patches that Thomas> let the busybox package download its patches, instead of Thomas> storing them in Buildroot's source tree.

Thanks. There's one big problem with busybox though. Denys tends to update the patches without renaming them if more problems are found in those applets - So we end up with different results depending on when you build.

Perhaps we can convince him to do otherwise, but until then I would prefer to keep it like it is.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

cover Download patches for Busybox

Dear Peter Korsgaard,

Quoted 9 lines · Peter Korsgaard

Thomas> Hello,
Thomas> As recently discussed on the list, here are two patches that Thomas> let the busybox package download its patches, instead of Thomas> storing them in Buildroot's source tree.

Thanks. There's one big problem with busybox though. Denys tends to update the patches without renaming them if more problems are found in those applets - So we end up with different results depending on when you build.

Yerk, this is ugly.

Quoted 2 lines

Perhaps we can convince him to do otherwise, but until then I would prefer to keep it like it is.

Indeed, in this case, we don't have much choice.

Best regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw

cover Download patches for Busybox

In reply to Peter Korsgaard
Quoted 7 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Thomas> Hello,
Thomas> As recently discussed on the list, here are two patches that Thomas> let the busybox package download its patches, instead of Thomas> storing them in Buildroot's source tree.

Quoted 7 lines

Thanks. There's one big problem with busybox though. Denys tends to update the patches without renaming them if more problems are found in those applets - So we end up with different results depending on when you build.

Perhaps we can convince him to do otherwise, but until then I would prefer to keep it like it is.

I'd still include patch 1/2, though.

Or actually, there's another patch still pending that allows a full URL
as the patch name; that would be even more interesting. I'll quickly ack that patch.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F