From cb404a944b419d61de18e1df4f0b68da048c2073 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 13 Oct 2015 00:57:10 +0200 Subject: [PATCH 1/5] build: remove vermagic hack As the Gluon kernel won't be compatible with the OpenWrt upstream anymore, we don't need the vermagic hack anymore. --- Makefile | 18 +----------------- docs/dev/hardware.rst | 12 ------------ include/Makefile.target | 2 +- targets/ar71xx-generic/vermagic | 1 - targets/ar71xx-nand/vermagic | 1 - targets/brcm2708-bcm2708/vermagic | 1 - targets/brcm2708-bcm2709/vermagic | 1 - targets/mpc85xx-generic/vermagic | 1 - targets/ramips-rt305x/vermagic | 1 - targets/sunxi/vermagic | 1 - targets/x86-64/vermagic | 1 - targets/x86-generic/vermagic | 1 - targets/x86-kvm_guest/vermagic | 1 - targets/x86-xen_domu/vermagic | 1 - 14 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 targets/ar71xx-generic/vermagic delete mode 100644 targets/ar71xx-nand/vermagic delete mode 100644 targets/brcm2708-bcm2708/vermagic delete mode 100644 targets/brcm2708-bcm2709/vermagic delete mode 100644 targets/mpc85xx-generic/vermagic delete mode 100644 targets/ramips-rt305x/vermagic delete mode 100644 targets/sunxi/vermagic delete mode 100644 targets/x86-64/vermagic delete mode 100644 targets/x86-generic/vermagic delete mode 100644 targets/x86-kvm_guest/vermagic delete mode 100644 targets/x86-xen_domu/vermagic diff --git a/Makefile b/Makefile index 08c4babb..d3e36862 100644 --- a/Makefile +++ b/Makefile @@ -103,13 +103,6 @@ manifest: FORCE mkdir -p $(GLUON_IMAGEDIR)/sysupgrade mv $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp $(GLUON_IMAGEDIR)/sysupgrade/$(GLUON_BRANCH).manifest -update-vermagic: FORCE - @$(CheckExternal) - +($(foreach GLUON_TARGET,$(GLUON_TARGETS), \ - $(GLUONMAKE_EARLY) maybe-prepare-target GLUON_TARGET='$(GLUON_TARGET)' V=s$(OPENWRT_VERBOSE) && \ - $(GLUONMAKE) update-vermagic GLUON_TARGET='$(GLUON_TARGET)' V=s$(OPENWRT_VERBOSE) && \ - ) :) - dirclean : FORCE for dir in build_dir dl staging_dir tmp; do \ rm -rf $(GLUON_ORIGOPENWRTDIR)/$$dir; \ @@ -447,15 +440,6 @@ manifest: FORCE ) : \ ) >> $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp -update-vermagic: FORCE - mkdir -p '$(BOARD_BUILDDIR)' - echo '$(DEFAULT_OPKG_REPO)' > '$(BOARD_BUILDDIR)/default_opkg_repo' - $(VERSION_SED) '$(BOARD_BUILDDIR)/default_opkg_repo' - wget -q -O- "$$(cat '$(BOARD_BUILDDIR)/default_opkg_repo')/base/Packages.gz" \ - | gzip -d \ - | awk '/Depends: kernel / { match($$3,/[[:xdigit:]]{32}/,m); print m[0]; exit }' \ - > $(GLUONDIR)/targets/$(GLUON_TARGET)/vermagic - -.PHONY: all images prepare clean gluon-tools manifest update-vermagic +.PHONY: all images prepare clean gluon-tools manifest endif diff --git a/docs/dev/hardware.rst b/docs/dev/hardware.rst index 2e8e2491..3bd62a3d 100644 --- a/docs/dev/hardware.rst +++ b/docs/dev/hardware.rst @@ -76,21 +76,9 @@ A directory for the new target must be created under ``targets``, and it must be to ``targets/targets.mk``. In the new target directory, the following files must be created: * profiles.mk -* vermagic * config (optional) For ``profiles.mk``, see :ref:`hardware-adding-profiles`. The file ``config`` can be used to add additional, target-specific options to the OpenWrt config. -The files ``vermagic`` must have the correct content so kernel modules from the upstream repositories -can be installed without dependency issues. The OpenWrt version a Gluon release is based on is defined by the upstream package repo URL in ``include/gluon.mk`` -(in the variable ``DEFAULT_OPKG_REPO``); at the time this documentation was written, this was ``barrier_breaker/14.07``; whenever -the package repo is updated, all ``vermagic`` files must be updated as well. The command ``make update-vermagic`` can be used to get the correct -vermagic, or update the values when ``DEFAULT_OPKG_REPO`` has changed. - -The content is a hash which is part of the version number of the kernel package. So in the case of ``ar71xx-generic`` on -``barrier_breaker``, we look for the kernel package in the directory ``https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/base/``. -As the kernel package is called ``kernel_3.10.49-1-0114c71ed85677c9c1e4911437af4743_ar71xx.ipk``, the correct ``vermagic`` string -is ``0114c71ed85677c9c1e4911437af4743``. - After this, is should be sufficient to call ``make GLUON_TARGET=`` to build the images for the new target. diff --git a/include/Makefile.target b/include/Makefile.target index a78a4044..9a913f0c 100644 --- a/include/Makefile.target +++ b/include/Makefile.target @@ -12,7 +12,7 @@ override define Kernel/Configure $(call Kernel/SetNoInitramfs) rm -rf $(KERNEL_BUILD_DIR)/modules $(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install - cp $(GLUONDIR)/targets/$(GLUON_TARGET)/vermagic $(LINUX_DIR)/.vermagic + $(SH_FUNC) grep '=[ym]' $(LINUX_DIR)/.config | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic endef # The Makefile included here is $(TOPDIR)/target/linux/$(BOARD)/Makefile diff --git a/targets/ar71xx-generic/vermagic b/targets/ar71xx-generic/vermagic deleted file mode 100644 index ff475475..00000000 --- a/targets/ar71xx-generic/vermagic +++ /dev/null @@ -1 +0,0 @@ -7bed08fa9c06eb8089e82c200340ec66 diff --git a/targets/ar71xx-nand/vermagic b/targets/ar71xx-nand/vermagic deleted file mode 100644 index bde150ed..00000000 --- a/targets/ar71xx-nand/vermagic +++ /dev/null @@ -1 +0,0 @@ -a44d8090b8f752ec1d96871dbbb8988a diff --git a/targets/brcm2708-bcm2708/vermagic b/targets/brcm2708-bcm2708/vermagic deleted file mode 100644 index f6367189..00000000 --- a/targets/brcm2708-bcm2708/vermagic +++ /dev/null @@ -1 +0,0 @@ -57d4b7d13c23edd1a689dd6d6adc65ad diff --git a/targets/brcm2708-bcm2709/vermagic b/targets/brcm2708-bcm2709/vermagic deleted file mode 100644 index 5264819c..00000000 --- a/targets/brcm2708-bcm2709/vermagic +++ /dev/null @@ -1 +0,0 @@ -0fec8065ae15bf9934ffbe2512e8e39f diff --git a/targets/mpc85xx-generic/vermagic b/targets/mpc85xx-generic/vermagic deleted file mode 100644 index 5ca6009d..00000000 --- a/targets/mpc85xx-generic/vermagic +++ /dev/null @@ -1 +0,0 @@ -521812ea85032e662b3d3469a3a10df8 diff --git a/targets/ramips-rt305x/vermagic b/targets/ramips-rt305x/vermagic deleted file mode 100644 index 3bc73d5e..00000000 --- a/targets/ramips-rt305x/vermagic +++ /dev/null @@ -1 +0,0 @@ -c8b57a131072a3198e594822481af3e0 diff --git a/targets/sunxi/vermagic b/targets/sunxi/vermagic deleted file mode 100644 index ef11e4c3..00000000 --- a/targets/sunxi/vermagic +++ /dev/null @@ -1 +0,0 @@ -3c199b535784c56bd7a6b4d6ad82b91f diff --git a/targets/x86-64/vermagic b/targets/x86-64/vermagic deleted file mode 100644 index cc552ff2..00000000 --- a/targets/x86-64/vermagic +++ /dev/null @@ -1 +0,0 @@ -30da46d39f906146155850351fa0acd9 diff --git a/targets/x86-generic/vermagic b/targets/x86-generic/vermagic deleted file mode 100644 index 3c2f8d1b..00000000 --- a/targets/x86-generic/vermagic +++ /dev/null @@ -1 +0,0 @@ -8549f8163c15d79b053f26aa0d52e96f diff --git a/targets/x86-kvm_guest/vermagic b/targets/x86-kvm_guest/vermagic deleted file mode 100644 index b0031811..00000000 --- a/targets/x86-kvm_guest/vermagic +++ /dev/null @@ -1 +0,0 @@ -d0d2aab265f2535385cf8d756315d27c diff --git a/targets/x86-xen_domu/vermagic b/targets/x86-xen_domu/vermagic deleted file mode 100644 index 1e646eda..00000000 --- a/targets/x86-xen_domu/vermagic +++ /dev/null @@ -1 +0,0 @@ -bce85557e89d5a4f30d6d723503b1a61 From 515dfa2b507e391601b096159eee9ff195bba7bc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 13 Oct 2015 01:00:46 +0200 Subject: [PATCH 2/5] Increment LINUX_RELEASE The upstream builds always use LINUX_RELEASE=1. By setting it to 2 we ensure that our modules are always preferred as long as our kernel version is at least as high as the upstream one. --- include/gluon.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/gluon.mk b/include/gluon.mk index 44aad1ec..3ef3f132 100644 --- a/include/gluon.mk +++ b/include/gluon.mk @@ -16,6 +16,11 @@ BOARD_KDIR = $(BOARD_BUILDDIR)/kernel export BOARD_BUILDDIR + +LINUX_RELEASE := 2 +export LINUX_RELEASE + + GLUON_OPENWRTDIR = $(BOARD_BUILDDIR)/openwrt From 53a7cf31f92230d0602811257ca96176a124818b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 13 Oct 2015 01:18:03 +0200 Subject: [PATCH 3/5] build: add GLUON_OUTPUTDIR, move GLUON_IMAGEDIR default below it We'll soon have other output besides the images, having a single directory for all output makes sense. --- .gitignore | 2 +- docs/features/autoupdater.rst | 4 ++-- docs/user/getting_started.rst | 11 +++++++---- include/gluon.mk | 6 ++++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 7a4602a1..2b6cabec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *~ /build -/images +/output /site /openwrt /packages diff --git a/docs/features/autoupdater.rst b/docs/features/autoupdater.rst index fdc511d9..8f35efb8 100644 --- a/docs/features/autoupdater.rst +++ b/docs/features/autoupdater.rst @@ -30,10 +30,10 @@ A fully automated nightly build could use the following commands: make clean make -j5 GLUON_TARGET=ar71xx-generic GLUON_BRANCH=experimental make manifest GLUON_BRANCH=experimental - contrib/sign.sh $SECRETKEY images/sysupgrade/experimental.manifest + contrib/sign.sh $SECRETKEY output/images/sysupgrade/experimental.manifest rm -rf /where/to/put/this/experimental - cp -r images /where/to/put/this/experimental + cp -r output/images /where/to/put/this/experimental Infrastructure diff --git a/docs/user/getting_started.rst b/docs/user/getting_started.rst index 10489978..658d98c5 100644 --- a/docs/user/getting_started.rst +++ b/docs/user/getting_started.rst @@ -86,7 +86,7 @@ In case of errors read the messages carefully and try to fix the stated issues ( ``ar71xx-generic`` is the most common target and will generated images for most of the supported hardware. To see a complete list of supported targets, call ``make`` without setting ``GLUON_TARGET``. -The built images can be found in the directory `images`. Of these, the factory +The built images can be found in the directory `output/images`. Of these, the factory images are to be used when flashing from the original firmware a device came with, and sysupgrade is to upgrade from other versions of Gluon or any other OpenWRT-based system. @@ -117,12 +117,15 @@ Gluon's build process can be controlled by various environment variables. GLUON_SITEDIR Path to the site configuration. Defaults to ``site/``. -GLUON_IMAGEDIR - Path where images will be stored. Defaults to ``images/``. - GLUON_BUILDDIR Working directory during build. Defaults to ``build/``. +GLUON_OUTPUTDIR + Path where output files will be stored. Defaults to ``output/``. + +GLUON_IMAGEDIR + Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images/``. + So all in all, to update and rebuild a Gluon build tree, the following commands should be used (repeat the ``make clean`` and ``make`` for all targets you want to build): diff --git a/include/gluon.mk b/include/gluon.mk index 3ef3f132..ceaa2850 100644 --- a/include/gluon.mk +++ b/include/gluon.mk @@ -2,13 +2,15 @@ ifneq ($(__gluon_inc),1) __gluon_inc=1 GLUON_SITEDIR ?= $(GLUONDIR)/site -GLUON_IMAGEDIR ?= $(GLUONDIR)/images GLUON_BUILDDIR ?= $(GLUONDIR)/build GLUON_ORIGOPENWRTDIR := $(GLUONDIR)/openwrt GLUON_SITE_CONFIG := $(GLUON_SITEDIR)/site.conf -export GLUONDIR GLUON_SITEDIR GLUON_SITE_CONFIG GLUON_IMAGEDIR GLUON_BUILDDIR +GLUON_OUTPUTDIR ?= $(GLUONDIR)/output +GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images + +export GLUONDIR GLUON_SITEDIR GLUON_BUILDDIR GLUON_SITE_CONFIG GLUON_OUTPUTDIR GLUON_IMAGEDIR BOARD_BUILDDIR = $(GLUON_BUILDDIR)/$(GLUON_TARGET) From cbe66e9388de22d21d3ab3ea8461f69b817d4ec6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 13 Oct 2015 21:36:19 +0200 Subject: [PATCH 4/5] build: add `make modules` make target `make modules` will generate a opkg repository containing kernel modules matching the kernel of the Gluon images. --- Makefile | 31 +++++++++++++++++-------------- docs/user/getting_started.rst | 3 +++ include/Makefile.target | 19 ------------------- include/config | 2 +- include/gluon.mk | 3 ++- 5 files changed, 23 insertions(+), 35 deletions(-) delete mode 100644 include/Makefile.target diff --git a/Makefile b/Makefile index d3e36862..f548dd1d 100644 --- a/Makefile +++ b/Makefile @@ -68,11 +68,12 @@ prepare-target: FORCE all: prepare-target +@$(GLUONMAKE) prepare +@$(GLUONMAKE) images + +@$(GLUONMAKE) modules prepare: prepare-target +@$(GLUONMAKE) $@ -clean download images: FORCE +clean download images modules: FORCE @$(CheckExternal) @$(CheckTarget) +@$(GLUONMAKE_EARLY) maybe-prepare-target @@ -178,6 +179,10 @@ override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET) target_prepared_stamp := $(BOARD_BUILDDIR)/target-prepared gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared +PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp)) +IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE) +MODULE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE) + include $(INCLUDE_DIR)/target.mk @@ -228,13 +233,6 @@ config: FORCE | sed -e 's/ /\n/g'; \ ) > $(BOARD_BUILDDIR)/config.tmp scripts/config/conf --defconfig=$(BOARD_BUILDDIR)/config.tmp Config.in - mv .config $(BOARD_BUILDDIR)/config - - echo 'CONFIG_ALL_KMODS=y' >> $(BOARD_BUILDDIR)/config.tmp - scripts/config/conf --defconfig=$(BOARD_BUILDDIR)/config.tmp Config.in - mv .config $(BOARD_BUILDDIR)/config-allmods - - cp $(BOARD_BUILDDIR)/config .config prepare-target: FORCE rm $(GLUON_OPENWRTDIR)/tmp || true @@ -284,8 +282,8 @@ toolchain: $(toolchain/stamp-install) $(tools/stamp-install) include $(INCLUDE_DIR)/kernel.mk kernel: FORCE - +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.image TARGET_BUILD=1 - +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.modules TARGET_BUILD=1 + +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) $(LINUX_DIR)/.image TARGET_BUILD=1 + +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) $(LINUX_DIR)/.modules TARGET_BUILD=1 packages: $(package/stamp-compile) $(_SINGLE)$(SUBMAKE) -r package/index @@ -313,6 +311,14 @@ prepare: FORCE $(gluon_prepared_stamp): +$(GLUONMAKE) prepare +modules: FORCE $(gluon_prepared_stamp) + -rm -f $(GLUON_MODULEDIR)/*/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)/* + -rmdir -p $(GLUON_MODULEDIR)/*/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic) + mkdir -p $(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic) + cp $(PACKAGE_DIR)/kmod-*.ipk $(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic) + + $(_SINGLE)$(SUBMAKE) -r package/index PACKAGE_DIR=$(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic) + include $(INCLUDE_DIR)/package-ipkg.mk @@ -325,9 +331,6 @@ BIN_DIR = $(PROFILE_BUILDDIR)/images TARGET_DIR = $(PROFILE_BUILDDIR)/root -PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp)) -IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE) - OPKG:= \ IPKG_TMP="$(TMP_DIR)/ipkgtmp" \ IPKG_INSTROOT="$(TARGET_DIR)" \ @@ -440,6 +443,6 @@ manifest: FORCE ) : \ ) >> $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp -.PHONY: all images prepare clean gluon-tools manifest +.PHONY: all images prepare modules clean gluon-tools manifest endif diff --git a/docs/user/getting_started.rst b/docs/user/getting_started.rst index 658d98c5..db038bd5 100644 --- a/docs/user/getting_started.rst +++ b/docs/user/getting_started.rst @@ -126,6 +126,9 @@ GLUON_OUTPUTDIR GLUON_IMAGEDIR Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images/``. +GLUON_MODULEDIR + Path where the kernel module opkg repository will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/modules``. + So all in all, to update and rebuild a Gluon build tree, the following commands should be used (repeat the ``make clean`` and ``make`` for all targets you want to build): diff --git a/include/Makefile.target b/include/Makefile.target deleted file mode 100644 index 9a913f0c..00000000 --- a/include/Makefile.target +++ /dev/null @@ -1,19 +0,0 @@ -# code adjusted from openwrt/include/kernel-defaults.mk - -override define Kernel/Configure - $(LINUX_CONF_CMD) > $(LINUX_DIR)/.config.target -# copy CONFIG_KERNEL_* settings over to .config.target - awk '/^(#[[:space:]]+)?CONFIG_KERNEL/{sub("CONFIG_KERNEL_","CONFIG_");print}' $(BOARD_BUILDDIR)/config-allmods >> $(LINUX_DIR)/.config.target - echo "# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR)/.config.target - echo "# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR)/.config.target - echo "# CONFIG_KALLSYMS_UNCOMPRESSED is not set" >> $(LINUX_DIR)/.config.target - $(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(BOARD_BUILDDIR)/config-allmods $(KERNEL_PATCHVER) > $(LINUX_DIR)/.config.override - $(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config - $(call Kernel/SetNoInitramfs) - rm -rf $(KERNEL_BUILD_DIR)/modules - $(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install - $(SH_FUNC) grep '=[ym]' $(LINUX_DIR)/.config | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic -endef - -# The Makefile included here is $(TOPDIR)/target/linux/$(BOARD)/Makefile -include Makefile diff --git a/include/config b/include/config index ac1a4f8d..8476ec64 100644 --- a/include/config +++ b/include/config @@ -1,7 +1,7 @@ CONFIG_IMAGEOPT=y # CONFIG_PER_FEED_REPO is not set - CONFIG_DEVEL=y +CONFIG_ALL_KMODS=y CONFIG_BUSYBOX_CUSTOM=y CONFIG_BUSYBOX_CONFIG_SHA512SUM=y diff --git a/include/gluon.mk b/include/gluon.mk index ceaa2850..3534ae22 100644 --- a/include/gluon.mk +++ b/include/gluon.mk @@ -9,8 +9,9 @@ GLUON_SITE_CONFIG := $(GLUON_SITEDIR)/site.conf GLUON_OUTPUTDIR ?= $(GLUONDIR)/output GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images +GLUON_MODULEDIR ?= $(GLUON_OUTPUTDIR)/modules -export GLUONDIR GLUON_SITEDIR GLUON_BUILDDIR GLUON_SITE_CONFIG GLUON_OUTPUTDIR GLUON_IMAGEDIR +export GLUONDIR GLUON_SITEDIR GLUON_BUILDDIR GLUON_SITE_CONFIG GLUON_OUTPUTDIR GLUON_IMAGEDIR GLUON_MODULEDIR BOARD_BUILDDIR = $(GLUON_BUILDDIR)/$(GLUON_TARGET) From 4b120deaee5c15c47aab8b6155563febfc1bfb30 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 14 Oct 2015 20:12:52 +0200 Subject: [PATCH 5/5] build: improve handling of repository signing keys --- Makefile | 76 ++++++++++++++++++++++------------- docs/user/getting_started.rst | 46 +++++++++++++++++++-- include/gluon.mk | 2 + 3 files changed, 93 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index f548dd1d..890fdfc8 100644 --- a/Makefile +++ b/Makefile @@ -59,30 +59,37 @@ CheckTarget := [ -n '$(GLUON_TARGET)' -a -n '$(GLUON_TARGET_$(GLUON_TARGET)_BOAR CheckExternal := test -d $(GLUON_ORIGOPENWRTDIR) || (echo 'You don'"'"'t seem to have obtained the external repositories needed by Gluon; please call `make update` first!'; false) +create-key: FORCE + @$(CheckExternal) + +@$(GLUONMAKE_EARLY) create-key + prepare-target: FORCE @$(CheckExternal) @$(CheckTarget) +@$(GLUONMAKE_EARLY) prepare-target - all: prepare-target + +@$(GLUONMAKE) build-key +@$(GLUONMAKE) prepare +@$(GLUONMAKE) images +@$(GLUONMAKE) modules prepare: prepare-target + +@$(GLUONMAKE) build-key +@$(GLUONMAKE) $@ clean download images modules: FORCE @$(CheckExternal) @$(CheckTarget) +@$(GLUONMAKE_EARLY) maybe-prepare-target + +@$(GLUONMAKE) build-key +@$(GLUONMAKE) $@ toolchain/% package/% target/% image/%: FORCE @$(CheckExternal) @$(CheckTarget) +@$(GLUONMAKE_EARLY) maybe-prepare-target + +@$(GLUONMAKE) build-key +@$(GLUONMAKE) $@ manifest: FORCE @@ -170,23 +177,6 @@ GLUON_$(1)_MODEL_$(2)_ALIASES += $(3) endef -include $(GLUONDIR)/targets/targets.mk -include $(GLUONDIR)/targets/$(GLUON_TARGET)/profiles.mk - -BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD) -override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET) - -target_prepared_stamp := $(BOARD_BUILDDIR)/target-prepared -gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared - -PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp)) -IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE) -MODULE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE) - - -include $(INCLUDE_DIR)/target.mk - - prereq: FORCE +$(NO_TRACE_MAKE) prereq @@ -214,7 +204,43 @@ feeds: FORCE gluon-tools: FORCE +$(GLUONMAKE_EARLY) tools/sed/install - +$(GLUONMAKE_EARLY) package/lua/host/install + +$(GLUONMAKE_EARLY) package/lua/host/install package/usign/host/install + + +prepare-early: FORCE + for dir in build_dir dl staging_dir; do \ + mkdir -p $(GLUON_ORIGOPENWRTDIR)/$$dir; \ + done + + +$(GLUONMAKE_EARLY) feeds + +$(GLUONMAKE_EARLY) gluon-tools + +create-key: prepare-early + [ -s $(GLUON_OPKG_KEY) -a -s $(GLUON_OPKG_KEY).pub ] || \ + $(STAGING_DIR_HOST)/bin/usign -G -s $(GLUON_OPKG_KEY) -p $(GLUON_OPKG_KEY).pub -c "Gluon opkg key" + +include $(GLUONDIR)/targets/targets.mk + +ifneq ($(GLUON_TARGET),) + +include $(GLUONDIR)/targets/$(GLUON_TARGET)/profiles.mk + +BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD) +override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET) + +target_prepared_stamp := $(BOARD_BUILDDIR)/target-prepared +gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared + +PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp)) +IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE) +MODULE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE) + + +include $(INCLUDE_DIR)/target.mk + +build-key: FORCE + ln -sf $(GLUON_OPKG_KEY) $(BUILD_KEY) + ln -sf $(GLUON_OPKG_KEY).pub $(BUILD_KEY).pub config: FORCE +$(NO_TRACE_MAKE) scripts/config/conf OPENWRT_BUILD= QUIET=0 @@ -234,23 +260,18 @@ config: FORCE ) > $(BOARD_BUILDDIR)/config.tmp scripts/config/conf --defconfig=$(BOARD_BUILDDIR)/config.tmp Config.in -prepare-target: FORCE +prepare-target: create-key rm $(GLUON_OPENWRTDIR)/tmp || true mkdir -p $(GLUON_OPENWRTDIR)/tmp - for dir in build_dir dl staging_dir; do \ - mkdir -p $(GLUON_ORIGOPENWRTDIR)/$$dir; \ - done for link in build_dir config Config.in dl include Makefile package rules.mk scripts staging_dir target toolchain tools; do \ ln -sf $(GLUON_ORIGOPENWRTDIR)/$$link $(GLUON_OPENWRTDIR); \ done - +$(GLUONMAKE_EARLY) feeds - +$(GLUONMAKE_EARLY) gluon-tools +$(GLUONMAKE) config touch $(target_prepared_stamp) -$(target_prepared_stamp): +$(target_prepared_stamp): create-key +$(GLUONMAKE_EARLY) prepare-target maybe-prepare-target: $(target_prepared_stamp) @@ -443,6 +464,7 @@ manifest: FORCE ) : \ ) >> $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp -.PHONY: all images prepare modules clean gluon-tools manifest +.PHONY: all create-key prepare images modules clean gluon-tools manifest endif +endif diff --git a/docs/user/getting_started.rst b/docs/user/getting_started.rst index db038bd5..d7100e71 100644 --- a/docs/user/getting_started.rst +++ b/docs/user/getting_started.rst @@ -109,22 +109,60 @@ will clean the entire tree, so the toolchain will be rebuilt as well, which is not necessary in most cases, and will take a while. +opkg repositories +----------------- + +Gluon is mostly compatible with OpenWrt, so the normal OpenWrt package repositories +can be used for Gluon as well. It is advisable to setup a mirror or reverse proxy +reachable over IPv6 and add it to ``site.conf`` as http://downloads.openwrt.org/ does +not support IPv6. + +This is not true for kernel modules; the Gluon kernel is incompatible with the +kernel of the default OpenWrt images. Therefore, Gluon will not only generate images, +but also an opkg repositoy containing all kernel modules provided by OpenWrt/Gluon +for the kernel of the generated images. + +Signing keys +............ + +Gluon does not support HTTPS for downloading packages; fortunately, opkg deploys +public-key cryptography to ensure package integrity. + +The Gluon images will contain two public keys: the official OpenWrt signing key +(to allow installing userspace packages) and a Gluon-specific key (which is used +to sign the generated module repository). + +By default, Gluon will handle the generation and handling of the keys itself. +When making firmware releases based on Gluon, it might make sense to store the +the keypair, so updating the module repository later is possible. + +The location the keys are stored at and read from can be changed +(see :ref:`getting-started-environment-variables`). To only generate the keypair +at the configured location without doing a full build, use ``make create-key``. + +.. _getting-started-environment-variables: + Environment variables --------------------- Gluon's build process can be controlled by various environment variables. GLUON_SITEDIR - Path to the site configuration. Defaults to ``site/``. + Path to the site configuration. Defaults to ``site``. GLUON_BUILDDIR - Working directory during build. Defaults to ``build/``. + Working directory during build. Defaults to ``build``. + +GLUON_OPKG_KEY + Path key file used to sign the module opkg repository. Defaults to ``$(GLUON_BULDDIR)/gluon-opkg-key``. + + The private key will be stored as ``$(GLUON_OPKG_KEY)``, the public key as ``$(GLUON_OPKG_KEY).pub``. GLUON_OUTPUTDIR - Path where output files will be stored. Defaults to ``output/``. + Path where output files will be stored. Defaults to ``output``. GLUON_IMAGEDIR - Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images/``. + Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images``. GLUON_MODULEDIR Path where the kernel module opkg repository will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/modules``. diff --git a/include/gluon.mk b/include/gluon.mk index 3534ae22..d49dc13f 100644 --- a/include/gluon.mk +++ b/include/gluon.mk @@ -11,6 +11,8 @@ GLUON_OUTPUTDIR ?= $(GLUONDIR)/output GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images GLUON_MODULEDIR ?= $(GLUON_OUTPUTDIR)/modules +GLUON_OPKG_KEY ?= $(GLUON_BUILDDIR)/gluon-opkg-key + export GLUONDIR GLUON_SITEDIR GLUON_BUILDDIR GLUON_SITE_CONFIG GLUON_OUTPUTDIR GLUON_IMAGEDIR GLUON_MODULEDIR