Wrap all vboot utilities with futility.
This moves all the old userspace utilities generated by vboot_reference into
a subdirectory not in $PATH, and replaces them with symlinks to a single
executable named 'futility'. At the moment that utility just execs the
original utilities (optionally logging that fact first).
Ultimately, the old utilities will be subsumed into a single binary instead
of multiple separate executables.
There is a matching CL needed to make the recovery image creation work.
BUG=chromium-os:37062
BRANCH=none
CQ-DEPEND=CL:44864
TEST=auto
To test, build everything, test everything. It should work as before in all
cases. I have built normal images, test images, factory installers, recovery
images; they all seem to work.
I've run trybots on daisy-paladin link-paladin lumpy-paladin and alex-paladin.
Change-Id: Ie93db676f2ed2a64e4b13b3b5dc6b65a77db0f8c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44871
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/Makefile b/Makefile
index a7101cc..cd39114 100644
--- a/Makefile
+++ b/Makefile
@@ -37,22 +37,29 @@
# We should only run pwd once, not every time we refer to ${BUILD}.
SRCDIR := $(shell pwd)
-BUILD ?= $(SRCDIR)/build
+BUILD = $(SRCDIR)/build
export BUILD
# Stuff for 'make install'
-INSTALL ?= install
-DESTDIR ?= /usr/local/bin
+INSTALL = install
+DESTDIR = /usr/local/bin
+OLDDIR = old_bins
+# Where exactly do the pieces go?
+# FT_DIR = futility target directory - where it will be on the target
+# F_DIR = futility install directory - where it gets put right now
+# UB_DIR = userspace binary directory for futility's exec() targets
+# VB_DIR = target vboot directory - for dev-mode-only helpers, keys, etc.
ifeq (${MINIMAL},)
# Host install just puts everything in one place
-UB_DIR=${DESTDIR}
-SB_DIR=${DESTDIR}
-VB_DIR=${DESTDIR}
+FT_DIR=${DESTDIR}
+F_DIR=${DESTDIR}
+UB_DIR=${DESTDIR}/${OLDDIR}
else
# Target install puts things into DESTDIR subdirectories
-UB_DIR=${DESTDIR}/usr/bin
-SB_DIR=${DESTDIR}/sbin
+FT_DIR=/usr/bin
+F_DIR=${DESTDIR}${FT_DIR}
+UB_DIR=${F_DIR}/${OLDDIR}
VB_DIR=${DESTDIR}/usr/share/vboot/bin
endif
@@ -127,6 +134,10 @@
CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror # HEY: always want last two?
endif
+ifneq (${OLDDIR},)
+CFLAGS += -DOLDDIR=${OLDDIR}
+endif
+
ifneq (${DEBUG},)
CFLAGS += -DVBOOT_DEBUG
endif
@@ -135,6 +146,10 @@
CFLAGS += -DNDEBUG
endif
+ifneq (${FORCE_LOGGING_ON},)
+CFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON}
+endif
+
# Create / use dependency files
CFLAGS += -MMD -MF $@.d
@@ -429,8 +444,13 @@
# The unified firmware utility will eventually replace all the others
FUTIL_BIN = ${BUILD}/futility/futility
+# These are the others it will replace.
+FUTIL_OLD = $(notdir ${CGPT} ${UTIL_BINS} ${UTIL_SCRIPTS} \
+ ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV})
+
FUTIL_SRCS = \
- futility/IGNOREME.c
+ futility/futility.c \
+ futility/cmd_foo.c
FUTIL_LDS = futility/futility.lds
@@ -696,13 +716,15 @@
# And some signing stuff for the target
.PHONY: signing_install
signing_install: ${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV} ${SIGNING_COMMON}
-ifneq (${MINIMAL},)
@printf " INSTALL SIGNING\n"
${Q}mkdir -p ${UB_DIR}
${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS}
+ ${Q}${INSTALL} -t ${UB_DIR} ${SIGNING_SCRIPTS_DEV}
+ ${Q}${INSTALL} -t ${UB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
+ifneq (${VB_DIR},)
${Q}mkdir -p ${VB_DIR}
- ${Q}${INSTALL} -t ${VB_DIR} ${SIGNING_SCRIPTS_DEV}
- ${Q}${INSTALL} -t ${VB_DIR} -m 'u=rw,go=r,a-s' ${SIGNING_COMMON}
+ ${Q}for prog in $(notdir ${SIGNING_SCRIPTS_DEV}); do \
+ ln -sf "${FT_DIR}/futility" "${VB_DIR}/$$prog"; done
endif
# ----------------------------------------------------------------------------
@@ -718,9 +740,10 @@
.PHONY: futil_install
futil_install: ${FUTIL_BIN}
@printf " INSTALL futility\n"
- ${Q}mkdir -p ${UB_DIR}
- ${Q}${INSTALL} -t ${UB_DIR} $^
-
+ ${Q}mkdir -p ${F_DIR}
+ ${Q}${INSTALL} -t ${F_DIR} ${FUTIL_BIN}
+ ${Q}for prog in ${FUTIL_OLD}; do \
+ ln -sf futility "${F_DIR}/$$prog"; done
# ----------------------------------------------------------------------------
# Utility to generate TLCL structure definition header file.
@@ -791,6 +814,10 @@
# GBB utility needs C++ linker. TODO: It shouldn't.
${BUILD}/utility/gbb_utility: LD = ${CXX}
+# Because we play some clever linker script games to add new commands without
+# changing any header files, futility must be linked with ld.bfd, not gold.
+${FUTIL_BIN}: LDFLAGS += -fuse-ld=bfd
+
# Some utilities need external crypto functions
${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
@@ -855,7 +882,7 @@
ifeq (${MINIMAL},)
# Bitmap utility isn't compiled for minimal variant
-test_targets:: runbmptests
+test_targets:: runbmptests runfutiltests
# Scripts don't work under qemu testing
# TODO: convert scripts to makefile so they can be called directly
test_targets:: runtestscripts
@@ -938,9 +965,9 @@
${RUNTEST} ${BUILD_RUN}/tests/vboot_nvstorage_test
.PHONY: runfutiltests
-runfutiltests: DESTDIR := ${TEST_INSTALL_DIR}
+runfutiltests: override DESTDIR = ${TEST_INSTALL_DIR}
runfutiltests: test_setup install
- @echo "$@ passed"
+ futility/tests/run_futility_tests.sh ${DESTDIR}
# Run long tests, including all permutations of encryption keys (instead of
# just the ones we use) and tests of currently-unused code.
@@ -987,4 +1014,3 @@
else
coverage: coverage_init runtests coverage_html
endif
-