summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2010-09-15 20:54:15 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2010-09-15 20:54:15 +0200
commit4422cda575db22275b067e07ad4b585572d91756 (patch)
tree04557c9f49a6088540cdedc7c68e04dd61132531
parent30fc540d30f82c534a3bdfff265f8b62cb770551 (diff)
rebuild packages on flavour or choices change
add new target rebuild. make cpio and pacch quiet. Use bin/tools for cpio and mkcrypt.
-rw-r--r--mk/build.mk5
-rw-r--r--mk/buildhlp.mk6
-rw-r--r--mk/image.mk4
-rw-r--r--mk/package.mk7
-rw-r--r--mk/pkg-bottom.mk2
-rw-r--r--mk/vars.mk4
-rw-r--r--package/Makefile11
-rw-r--r--package/base-files/Makefile8
-rw-r--r--package/busybox/Makefile8
-rw-r--r--tools/adk/Makefile5
-rw-r--r--tools/adk/pkgrebuild.c234
-rw-r--r--tools/cpio/Makefile6
-rw-r--r--tools/cpio/src/cpio.c2
-rw-r--r--tools/mkcrypt/Makefile6
14 files changed, 271 insertions, 37 deletions
diff --git a/mk/build.mk b/mk/build.mk
index 150d3de25..a2e05ca1a 100644
--- a/mk/build.mk
+++ b/mk/build.mk
@@ -64,8 +64,9 @@ noconfig_targets:= menuconfig \
defconfig \
tags
-POSTCONFIG= -@ \
+POSTCONFIG= -@\
if [ -f .config.old ];then \
+ $(TOPDIR)/bin/tools/pkgrebuild;\
rebuild=0; \
if [ "$$(grep ^BUSYBOX .config|md5sum)" != "$$(grep ^BUSYBOX .config.old|md5sum)" ];then \
touch .rebuild.busybox;\
@@ -76,7 +77,7 @@ POSTCONFIG= -@ \
rebuild=1;\
fi; \
if [ $$rebuild -eq 1 ];then \
- cp .config .config.old; \
+ cp .config .config.old;\
fi; \
fi
diff --git a/mk/buildhlp.mk b/mk/buildhlp.mk
index 4df712fcb..14cee191d 100644
--- a/mk/buildhlp.mk
+++ b/mk/buildhlp.mk
@@ -29,7 +29,7 @@ post-extract:
ifeq ($(strip ${NO_DISTFILES}),1)
${WRKDIST}/.extract_done:
rm -rf ${WRKDIST} ${WRKSRC} ${WRKBUILD}
- mkdir -p ${WRKDIR} ${WRKDIST}
+ @mkdir -p ${WRKDIR} ${WRKDIST}
${MAKE} do-extract
@${MAKE} post-extract
touch $@
@@ -57,9 +57,9 @@ ifeq ($(strip ${__use_generic_patch_target}),42)
post-patch:
${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
[ ! -d ./patches/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
- '{patch-!(*.orig),*.patch}'
+ '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
[ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
- '{patch-!(*.orig),*.patch}'
+ '{patch-!(*.orig),*.patch}' $(MAKE_TRACE)
[ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
$(MAKE_TRACE)
@${MAKE} post-patch $(MAKE_TRACE)
diff --git a/mk/image.mk b/mk/image.mk
index 6c3b1e5f9..3937ee5f9 100644
--- a/mk/image.mk
+++ b/mk/image.mk
@@ -51,7 +51,7 @@ ${BIN_DIR}/${ROOTFSUSERTARBALL}: ${TARGET_DIR}
${BIN_DIR}/${INITRAMFS}: ${TARGET_DIR}
cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
sed "s#\(.*\)#:0:0::::::\1#" | sort | \
- ${STAGING_TOOLS}/bin/cpio -o -C512 -Hnewc -P | \
+ ${TOPDIR}/bin/tools/cpio -o -C512 -Hnewc -P | \
${ADK_COMPRESSION_TOOL} >$@ 2>/dev/null
${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
@@ -59,7 +59,7 @@ ${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
$(LINUX_DIR)/.config
cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
sed "s#\(.*\)#:0:0::::::\1#" | sort | \
- ${STAGING_TOOLS}/bin/cpio -o -C512 -Hnewc -P >$@ 2>/dev/null
+ ${TOPDIR}/bin/tools/cpio -o -C512 -Hnewc -P >$@ 2>/dev/null
${BIN_DIR}/${ROOTFSSQUASHFS}: ${TARGET_DIR}
${STAGING_TOOLS}/bin/mksquashfs ${TARGET_DIR} \
diff --git a/mk/package.mk b/mk/package.mk
index 1f582b3d1..cd84e4c08 100644
--- a/mk/package.mk
+++ b/mk/package.mk
@@ -117,6 +117,11 @@ patch: ${_PATCH_COOKIE}
configure: ${_CONFIGURE_COOKIE}
build: ${_BUILD_COOKIE}
fake: ${_FAKE_COOKIE}
+rebuild:
+ @if [ -f ${TOPDIR}/.rebuild.${PKG_NAME} ];then \
+ $(MAKE) clean; \
+ rm -f ${TOPDIR}/.rebuild.${PKG_NAME}; \
+ fi
# our recursive build entry point
build-all-pkgs: ${_IPKGS_COOKIE}
@@ -220,7 +225,7 @@ endif
find usr ! -type d 2>/dev/null | \
grep -v -e '^usr/share' -e '^usr/man' -e '^usr/info' -e '^usr/lib/libc.so' | \
tee '$${STAGING_PARENT}/pkg/$(1)' | \
- cpio -padlmu '$${STAGING_DIR}'
+ $(TOPDIR)/bin/tools/cpio -padlmu '$${STAGING_DIR}'
@cd '$${STAGING_DIR}'; grep 'usr/lib/.*\.la$$$$' \
'$${STAGING_PARENT}/pkg/$(1)' | while read fn; do \
chmod u+w $$$$fn; \
diff --git a/mk/pkg-bottom.mk b/mk/pkg-bottom.mk
index 101a240a9..e68607f9d 100644
--- a/mk/pkg-bottom.mk
+++ b/mk/pkg-bottom.mk
@@ -165,7 +165,7 @@ endif
find usr ! -type d 2>/dev/null | \
grep -v -e '^usr/share' -e '^usr/man' -e '^usr/info' -e '^usr/lib/libc.so' | \
tee '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
- cpio -padlmu '${STAGING_DIR}'
+ $(TOPDIR)/bin/tools/cpio -padlmu '${STAGING_DIR}'
@cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$' \
'${STAGING_PARENT}/pkg/${PKG_NAME}' | while read fn; do \
chmod u+w $$fn; \
diff --git a/mk/vars.mk b/mk/vars.mk
index 6f38db944..40226b254 100644
--- a/mk/vars.mk
+++ b/mk/vars.mk
@@ -102,7 +102,7 @@ EXTRACT_CMD= mkdir -p ${WRKDIR}; \
cd ${WRKDIR} && \
for file in ${FULLDISTFILES}; do case $$file in \
*.cpio) \
- cat $$file | $(STAGING_TOOLS)/bin/cpio -i -d ;; \
+ cat $$file | $(TOPDIR)/bin/tools/cpio -i -d ;; \
*.tar) \
tar -xf $$file ;; \
*.cpio.Z | *.cpio.gz | *.cgz | *.mcz) \
@@ -114,7 +114,7 @@ EXTRACT_CMD= mkdir -p ${WRKDIR}; \
*.tar.bz2 | *.tbz | *.tbz2) \
bzip2 -dc $$file | tar -xf - ;; \
*.zip) \
- cat $$file | $(STAGING_TOOLS)/bin/cpio -ivd -H zip ;; \
+ cat $$file | $(TOPDIR)/bin/tools/cpio -ivd -H zip ;; \
*.arm) \
cp $$file ${WRKDIR} ;; \
*) \
diff --git a/package/Makefile b/package/Makefile
index d9a015494..e271216dd 100644
--- a/package/Makefile
+++ b/package/Makefile
@@ -28,6 +28,7 @@ endif
include $(TOPDIR)/package/Depends.mk
DOWNLOAD:=$(patsubst %,%-download,$(package-y) $(package-m))
+REBUILD_PACKAGES:=$(patsubst %,%-rebuild,$(package-y) $(package-m))
COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m))
INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y))
@@ -35,10 +36,10 @@ all: compile
download: $(DOWNLOAD)
clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m) base-files)
ifeq ($(ADK_TOOLCHAIN_ONLY),y)
-compile: $(COMPILE_PACKAGES)
+compile: $(REBUILD_PACKAGES) $(COMPILE_PACKAGES)
install: $(INSTALL_PACKAGES)
else
-compile: base-files-compile $(COMPILE_PACKAGES)
+compile: base-files-compile $(REBUILD_PACKAGES) $(COMPILE_PACKAGES)
install: base-files-install $(INSTALL_PACKAGES)
endif
@@ -57,6 +58,12 @@ $(TARGET_DIR):
$(CMD_TRACE) " done"
$(END_TRACE)
+%-rebuild:
+ $(START_TRACE) "package/$(patsubst %-rebuild,%,$@)-rebuild: "
+ $(MAKE) -C $(patsubst %-rebuild,%,$@) rebuild
+ $(CMD_TRACE) " done"
+ $(END_TRACE)
+
%-install:
@$(START_TRACE) "package/$(patsubst %-install,%,$@)-install: "
@$(MAKE) -C $(patsubst %-install,%,$@) install
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index db1162946..0bc6bb079 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -77,12 +77,4 @@ ifneq (${ADK_PACKAGE_CONFIG_IN_ETC},)
chmod 600 $(IDIR_BASE_FILES)/etc/adkconfig.gz
endif
-rebuild:
- @if [ -f ${TOPDIR}/.rebuild.${PKG_NAME} ];then \
- rm ${WRKBUILD}/.build_done; \
- rm ${TOPDIR}/.rebuild.${PKG_NAME}; \
- fi
-
-fake: rebuild
-
include ${TOPDIR}/mk/pkg-bottom.mk
diff --git a/package/busybox/Makefile b/package/busybox/Makefile
index 35007df31..1f56f057b 100644
--- a/package/busybox/Makefile
+++ b/package/busybox/Makefile
@@ -82,12 +82,4 @@ udhcpd-install:
${INSTALL_DIR} ${IDIR_UDHCPD}/etc/
${INSTALL_DATA} ./files/udhcpd.conf ${IDIR_UDHCPD}/etc/
-rebuild:
- @if [ -f ${TOPDIR}/.rebuild.${PKG_NAME} ];then \
- rm ${WRKBUILD}/.build_done; \
- rm ${TOPDIR}/.rebuild.${PKG_NAME}; \
- fi
-
-fake: rebuild
-
include ${TOPDIR}/mk/pkg-bottom.mk
diff --git a/tools/adk/Makefile b/tools/adk/Makefile
index 28d8787ce..3f2048e68 100644
--- a/tools/adk/Makefile
+++ b/tools/adk/Makefile
@@ -6,6 +6,9 @@ include $(TOPDIR)/rules.mk
${TOPDIR}/bin/tools/depmaker:
$(HOSTCC) -o $(TOPDIR)/bin/tools/depmaker depmaker.c
-install: ${TOPDIR}/bin/tools/depmaker
+${TOPDIR}/bin/tools/pkgrebuild:
+ $(HOSTCC) -o $(TOPDIR)/bin/tools/pkgrebuild pkgrebuild.c strmap.c
+
+install: ${TOPDIR}/bin/tools/depmaker ${TOPDIR}/bin/tools/pkgrebuild
include $(TOPDIR)/mk/tools.mk
diff --git a/tools/adk/pkgrebuild.c b/tools/adk/pkgrebuild.c
new file mode 100644
index 000000000..5a8f438c1
--- /dev/null
+++ b/tools/adk/pkgrebuild.c
@@ -0,0 +1,234 @@
+/*
+ * pkgrebuild - recognize required package rebuilds in OpenADK
+ *
+ * Copyright (C) 2010 Waldemar Brodkorb <wbx@openadk.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <ctype.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "strmap.h"
+
+StrMap *configmap, *configoldmap, *pkgmap;
+
+static void iter(const char *key, const char *value, const void *obj) {
+ fprintf(stderr, "key: %s value: %s\n", key, value);
+}
+
+static void iter_disabled(const char *key, const char *value, const void *obj) {
+
+ char hvalue[256];
+ char tfile[256];
+ int fd;
+
+ memset(hvalue, 0, 256);
+ if (strmap_exists(configmap, key) == 0) {
+ //fprintf(stderr, "disabled variables: %s\n", key);
+ if (strmap_get(pkgmap, key, hvalue, sizeof(hvalue)) == 1) {
+ //fprintf(stderr, "Symbol is a flavour/choice: %s\n", hvalue);
+ if (snprintf(tfile, 256, ".rebuild.%s", hvalue) < 0)
+ perror("can not create file variable.");
+ fd = open(tfile, O_RDWR | O_CREAT);
+ close(fd);
+ }
+ }
+
+}
+
+static void iter_enabled(const char *key, const char *value, const void *obj) {
+
+ char hvalue[256];
+ char tfile[256];
+ int fd;
+
+ memset(hvalue, 0, 256);
+ if (strmap_exists(configoldmap, key) == 0) {
+ //fprintf(stderr, "enabled variables: %s\n", key);
+ if (strmap_get(pkgmap, key, hvalue, sizeof(hvalue)) == 1) {
+ //fprintf(stderr, "Symbol is a flavour/choice\n");
+ if (snprintf(tfile, 256, ".rebuild.%s", hvalue) < 0)
+ perror("can not create file variable.");
+ fd = open(tfile, O_RDWR | O_CREAT);
+ close(fd);
+ }
+ }
+}
+
+static char *toupperstr(char *string) {
+
+ int i;
+ char *str;
+
+ /* transform to uppercase variable name */
+ str = strdup(string);
+ for (i=0; i<(int)strlen(str); i++) {
+ if (str[i] == '+')
+ str[i] = 'X';
+ if (str[i] == '-')
+ str[i] = '_';
+ str[i] = toupper(str[i]);
+ }
+ return(str);
+}
+
+
+
+int main() {
+
+ FILE *config, *configold, *pkg;
+ char *key, *value, *string, *token;
+ char *pkg_name, *keystr;
+ char buf[128];
+ char path[320];
+ char pbuf[320];
+ DIR *pkgdir;
+ struct dirent *pkgdirp;
+
+ pkg_name = NULL;
+ /* read Makefile's for all packages */
+ pkgmap = strmap_new(1024);
+ pkgdir = opendir("package");
+ while ((pkgdirp = readdir(pkgdir)) != NULL) {
+ /* skip dotfiles */
+ if (strncmp(pkgdirp->d_name, ".", 1) > 0) {
+ if (snprintf(path, 320, "package/%s/Makefile", pkgdirp->d_name) < 0)
+ perror("can not create path variable.");
+ pkg = fopen(path, "r");
+ if (pkg == NULL)
+ continue;
+
+ while (fgets(pbuf, 320, pkg) != NULL) {
+ if (strncmp(pbuf, "PKG", 3) == 0) {
+ string = strstr(pbuf, "PKG_NAME:=");
+ if (string != NULL) {
+ string[strlen(string)-1] = '\0';
+ key = strtok(string, ":=");
+ value = strtok(NULL, "=\t");
+ if (value != NULL)
+ pkg_name = strdup(value);
+ }
+ string = strstr(pbuf, "PKG_FLAVOURS:=");
+ if (string != NULL) {
+ string[strlen(string)-1] = '\0';
+ key = strtok(string, ":=");
+ value = strtok(NULL, "=\t");
+ token = strtok(value, " ");
+ while (token != NULL) {
+ keystr = malloc(256);
+ memset(keystr, 0, 256);
+ strncat(keystr, "ADK_PACKAGE_", 12);
+ strncat(keystr, toupperstr(pkg_name), strlen(pkg_name));
+ strncat(keystr, "_", 1);
+ strncat(keystr, token, strlen(token));
+ strmap_put(pkgmap, keystr, pkgdirp->d_name);
+ token = strtok(NULL, " ");
+ free(keystr);
+ keystr = NULL;
+ }
+ }
+ string = strstr(pbuf, "PKG_CHOICES:=");
+ if (string != NULL) {
+ string[strlen(string)-1] = '\0';
+ key = strtok(string, ":=");
+ value = strtok(NULL, "=\t");
+ token = strtok(value, " ");
+ while (token != NULL) {
+ keystr = malloc(256);
+ memset(keystr, 0, 256);
+ strncat(keystr, "ADK_PACKAGE_", 12);
+ strncat(keystr, toupperstr(pkg_name), strlen(pkg_name));
+ strncat(keystr, "_", 1);
+ strncat(keystr, token, strlen(token));
+ strmap_put(pkgmap, keystr, pkgdirp->d_name);
+ token = strtok(NULL, " ");
+ free(keystr);
+ keystr = NULL;
+ }
+ }
+ string = strstr(pbuf, "PKG_FLAVOURS+=");
+ if (string != NULL) {
+ string[strlen(string)-1] = '\0';
+ key = strtok(string, "+=");
+ value = strtok(NULL, "=\t");
+ token = strtok(value, " ");
+ while (token != NULL) {
+ keystr = malloc(256);
+ memset(keystr, 0, 256);
+ strncat(keystr, "ADK_PACKAGE_", 12);
+ strncat(keystr, toupperstr(pkg_name), strlen(pkg_name));
+ strncat(keystr, "_", 1);
+ strncat(keystr, token, strlen(token));
+ strmap_put(pkgmap, keystr, pkgdirp->d_name);
+ token = strtok(NULL, " ");
+ free(keystr);
+ keystr = NULL;
+ }
+ }
+ }
+ }
+ fclose(pkg);
+ }
+ }
+ closedir(pkgdir);
+
+ config = fopen(".config", "r");
+ if (config == NULL)
+ perror(".config is missing.");
+
+ configmap = strmap_new(1024);
+ while (fgets(buf, 128, config) != NULL) {
+ if (strncmp(buf, "ADK_PACKAGE", 11) == 0) {
+ key = strtok(buf, "=");
+ value = strtok(NULL, "=");
+ strmap_put(configmap, key, value);
+ }
+ }
+ fclose(config);
+
+ configold = fopen(".config.old", "r");
+ if (configold == NULL)
+ perror(".config.old is missing.");
+
+ configoldmap = strmap_new(1024);
+ while (fgets(buf, 128, configold) != NULL) {
+ if (strncmp(buf, "ADK_PACKAGE", 11) == 0) {
+ key = strtok(buf, "=");
+ value = strtok(NULL, "=");
+ strmap_put(configoldmap, key, value);
+ }
+ }
+ fclose(configold);
+
+ //fprintf(stdout, "Config Count: %d\n", strmap_get_count(configmap));
+ //fprintf(stdout, "Config Old Count: %d\n", strmap_get_count(configoldmap));
+
+ strmap_enum(configoldmap, iter_disabled, NULL);
+ strmap_enum(configmap, iter_enabled, NULL);
+ //strmap_enum(pkgmap, iter, NULL);
+
+ strmap_delete(pkgmap);
+ strmap_delete(configmap);
+ strmap_delete(configoldmap);
+
+ return(0);
+}
diff --git a/tools/cpio/Makefile b/tools/cpio/Makefile
index d14fb56df..142f65b70 100644
--- a/tools/cpio/Makefile
+++ b/tools/cpio/Makefile
@@ -27,9 +27,9 @@ SRCS+= \
src/nonpax.c \
src/cpio.c
-${STAGING_TOOLS}/bin/cpio: ${SRCS}
- ${HOSTCC} ${HOSTCFLAGS} -D_GNU_SOURCE -Isrc -o $@ $^
+${TOPDIR}/bin/tools/cpio: ${SRCS}
+ @${HOSTCC} ${HOSTCFLAGS} -D_GNU_SOURCE -Isrc -o $@ $^
-install: ${STAGING_TOOLS}/bin/cpio
+install: ${TOPDIR}/bin/tools/cpio
include $(TOPDIR)/mk/tools.mk
diff --git a/tools/cpio/src/cpio.c b/tools/cpio/src/cpio.c
index d91f25dc1..cf9cb0ef8 100644
--- a/tools/cpio/src/cpio.c
+++ b/tools/cpio/src/cpio.c
@@ -1000,7 +1000,7 @@ main(int argc, char **argv)
prdot(1);
if (pax != PAX_TYPE_CPIO)
pax_onexit();
- fprintf(stderr, "%llu blocks\n", blocks + ((bytes + 0777) >> 9));
+ //fprintf(stderr, "%llu blocks\n", blocks + ((bytes + 0777) >> 9));
mclose();
if (errcnt && sysv3 == 0)
fprintf(stderr, "%llu error(s)\n", errcnt);
diff --git a/tools/mkcrypt/Makefile b/tools/mkcrypt/Makefile
index 3b1924c5b..4baf56c44 100644
--- a/tools/mkcrypt/Makefile
+++ b/tools/mkcrypt/Makefile
@@ -3,9 +3,9 @@
include $(TOPDIR)/rules.mk
-${STAGING_TOOLS}/bin/mkcrypt:
- $(HOSTCC) -o $(STAGING_TOOLS)/bin/mkcrypt mkcrypt.c
+${TOPDIR}/bin/tools/mkcrypt:
+ $(HOSTCC) -o $(TOPDIR)/bin/tools/mkcrypt mkcrypt.c
-install: ${STAGING_TOOLS}/bin/mkcrypt
+install: ${TOPDIR}/bin/tools/mkcrypt
include $(TOPDIR)/mk/tools.mk