From 8b67a2a9070a41396078f8381eb79b23c804db7d Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 2 Feb 2019 16:49:42 +0100 Subject: Allow running with sudo or as root instead of fakeroot It works around a problem with fakeroot as seen in github pull request #6. Pack rootfs tar: rootfs/usr/lib/opkg/info/dropbear.conffiles: Cannot readlink: Invalid argument tar: rootfs/usr/lib/opkg/info/dropbear.control: Cannot readlink: Invalid argument tar: Exiting with failure status due to previous errors Tarball built: bin/openwrt-18.06.1-x86-64-lxd.tar.gz --- README | 6 +++--- build.sh | 30 +++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/README b/README index 120672e..b589cee 100644 --- a/README +++ b/README @@ -19,11 +19,11 @@ Refer to the top of build.sh. Usage ----- -./build.sh [-a|--arch ] [-v|--version ] [-p|--packages ] [-f|--files] [--help] +./build.sh [-a|--arch x86_64|i686|aarch64] [-v|--version ] [-p|--packages ] [-f|--files] [-t|--type lxd|plain] [-s|--super fakeroot|sudo] [--help] Example ------- -./build.sh -v 18.06.1 -lxc image import bin/openwrt-18.06.1-x86-64-lxd.tar.gz --alias openwrt +./build.sh -v 18.06.2 +lxc image import bin/openwrt-18.06.2-x86-64-lxd.tar.gz --alias openwrt lxc launch openwrt router lxc exec router passwd root diff --git a/build.sh b/build.sh index fcbea7f..88d8162 100755 --- a/build.sh +++ b/build.sh @@ -6,16 +6,17 @@ arch_lxd=x86_64 ver=18.06.2 dist=openwrt type=lxd +super=fakeroot # Workaround for Debian/Ubuntu systems which use C.UTF-8 which is unsupported by OpenWrt export LC_ALL=C usage() { - echo "Usage: $0 [-a|--arch ] [-v|--version ] [-p|--packages ] [-f|--files] [-t|--type lxd|plain] [--help]" + echo "Usage: $0 [-a|--arch x86_64|i686|aarch64] [-v|--version ] [-p|--packages ] [-f|--files] [-t|--type lxd|plain] [-s|--super fakeroot|sudo] [--help]" exit 1 } -temp=$(getopt -o "a:v:p:f:t:" -l "arch:,version:,packages:,files:,type:,help" -- "$@") +temp=$(getopt -o "a:v:p:f:t:s:" -l "arch:,version:,packages:,files:,type:,super:,help" -- "$@") eval set -- "$temp" while true; do case "$1" in @@ -42,6 +43,16 @@ while true; do *) usage;; esac;; + -s|--super) + super="$2" + shift 2 + + case "$super" in + fakeroot|sudo) + ;; + *) + usage;; + esac;; --help) usage;; --) @@ -226,7 +237,20 @@ build_tarball() { for pkg in $pkgdir/*.ipk; do allpkgs=" $pkg" done - fakeroot scripts/build_rootfs.sh $rootfs $opts -o $tarball --arch=${arch} --subarch=${subarch} --packages="${allpkgs}" --files="${files}" + + local cmd="scripts/build_rootfs.sh" + if test `id -u` != 0; then + case "$super" in + sudo) + cmd="sudo --preserve-env=SDK $cmd" + ;; + *) + cmd="$super $cmd" + ;; + esac + fi + + $cmd $rootfs $opts -o $tarball --arch=${arch} --subarch=${subarch} --packages="${allpkgs}" --files="${files}" } build_metadata() { -- cgit v1.2.3