summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-02-02 16:49:42 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2019-02-02 16:53:14 +0100
commit8b67a2a9070a41396078f8381eb79b23c804db7d (patch)
tree16c18eb3819ee89870be026be21b4d549e2e85e1 /build.sh
parent36879338f9ff5100eebb30f8c6b48fd32d4df852 (diff)
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
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh30
1 files changed, 27 insertions, 3 deletions
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 <x86_64|i686|aarch64>] [-v|--version <version>] [-p|--packages <packages>] [-f|--files] [-t|--type lxd|plain] [--help]"
+ echo "Usage: $0 [-a|--arch x86_64|i686|aarch64] [-v|--version <version>] [-p|--packages <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() {