base-files: automatically handle paths and symlinks for RAMFS_COPY_BIN
Depending on busybox applet selection, paths of basic utiilties may differ, and may not work as symlinks to busybox. Simply using whatever binary is found in PATH and detecting symlinks automatically is more robust and easier to maintain. The list of binaries is also slightly cleaned up and duplicates are removed. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
parent
f464da623d
commit
438dcbfe74
10 changed files with 40 additions and 46 deletions
|
@ -6,28 +6,33 @@ RAM_ROOT=/tmp/root
|
||||||
libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; }
|
libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; }
|
||||||
|
|
||||||
install_file() { # <file> [ <file> ... ]
|
install_file() { # <file> [ <file> ... ]
|
||||||
|
local target dest dir
|
||||||
for file in "$@"; do
|
for file in "$@"; do
|
||||||
|
if [ -L "$file" ]; then
|
||||||
|
target="$(readlink -f "$file")"
|
||||||
|
dest="$RAM_ROOT/$file"
|
||||||
|
[ ! -f "$dest" ] && {
|
||||||
|
dir="$(dirname "$dest")"
|
||||||
|
mkdir -p "$dir"
|
||||||
|
ln -s "$target" "$dest"
|
||||||
|
}
|
||||||
|
file="$target"
|
||||||
|
fi
|
||||||
dest="$RAM_ROOT/$file"
|
dest="$RAM_ROOT/$file"
|
||||||
[ -f $file -a ! -f $dest ] && {
|
[ -f "$file" -a ! -f "$dest" ] && {
|
||||||
dir="$(dirname $dest)"
|
dir="$(dirname "$dest")"
|
||||||
mkdir -p "$dir"
|
mkdir -p "$dir"
|
||||||
cp $file $dest
|
cp "$file" "$dest"
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
install_bin() { # <file> [ <symlink> ... ]
|
install_bin() {
|
||||||
|
local src files
|
||||||
src=$1
|
src=$1
|
||||||
files=$1
|
files=$1
|
||||||
[ -x "$src" ] && files="$src $(libs $src)"
|
[ -x "$src" ] && files="$src $(libs $src)"
|
||||||
install_file $files
|
install_file $files
|
||||||
shift
|
|
||||||
for link in "$@"; do {
|
|
||||||
dest="$RAM_ROOT/$link"
|
|
||||||
dir="$(dirname $dest)"
|
|
||||||
mkdir -p "$dir"
|
|
||||||
[ -f "$dest" ] || ln -s $src $dest
|
|
||||||
}; done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_hooks() {
|
run_hooks() {
|
||||||
|
|
|
@ -17,6 +17,9 @@ export VERBOSE=1
|
||||||
export CONFFILES=/tmp/sysupgrade.conffiles
|
export CONFFILES=/tmp/sysupgrade.conffiles
|
||||||
export CONF_TAR=/tmp/sysupgrade.tgz
|
export CONF_TAR=/tmp/sysupgrade.tgz
|
||||||
|
|
||||||
|
RAMFS_COPY_BIN= # extra programs for temporary ramfs root
|
||||||
|
RAMFS_COPY_DATA= # extra data files
|
||||||
|
|
||||||
|
|
||||||
[ -f "$CONF_TAR" ] || export SAVE_CONFIG=0
|
[ -f "$CONF_TAR" ] || export SAVE_CONFIG=0
|
||||||
[ -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap ] && export SAVE_PARTITIONS=0
|
[ -f /tmp/sysupgrade.always.overwrite.bootdisk.partmap ] && export SAVE_PARTITIONS=0
|
||||||
|
@ -41,32 +44,20 @@ supivot() { # <new_root> <old_root>
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_to_ramfs() {
|
switch_to_ramfs() {
|
||||||
install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
|
for binary in \
|
||||||
/sbin/pivot_root /sbin/reboot /bin/sync /bin/dd /bin/grep \
|
/bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
|
||||||
/bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" /bin/dd \
|
pivot_root mount_root reboot sync kill sleep \
|
||||||
/bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \
|
md5sum hexdump cat zcat bzcat dd tar \
|
||||||
/bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc \
|
ls basename find cp mv rm mkdir rmdir mknod touch chmod \
|
||||||
/bin/cut /usr/bin/printf /bin/sync /bin/mkdir /bin/rmdir \
|
'[' printf wc grep awk sed cut \
|
||||||
/bin/rm /usr/bin/basename /bin/kill /bin/chmod /usr/bin/find \
|
mtd partx losetup mkfs.ext4 \
|
||||||
/bin/mknod /bin/touch /bin/sed
|
ubiupdatevol ubiattach ubiblock ubiformat \
|
||||||
|
ubidetach ubirsvol ubirmvol ubimkvol \
|
||||||
install_bin /sbin/mtd
|
snapshot snapshot_tool \
|
||||||
install_bin /sbin/mount_root
|
$RAMFS_COPY_BIN
|
||||||
install_bin /sbin/snapshot
|
do
|
||||||
install_bin /sbin/snapshot_tool
|
local file="$(which "$binary" 2>/dev/null)"
|
||||||
install_bin /usr/sbin/ubiupdatevol
|
[ -n "$file" ] && install_bin "$file"
|
||||||
install_bin /usr/sbin/ubiattach
|
|
||||||
install_bin /usr/sbin/ubiblock
|
|
||||||
install_bin /usr/sbin/ubiformat
|
|
||||||
install_bin /usr/sbin/ubidetach
|
|
||||||
install_bin /usr/sbin/ubirsvol
|
|
||||||
install_bin /usr/sbin/ubirmvol
|
|
||||||
install_bin /usr/sbin/ubimkvol
|
|
||||||
install_bin /usr/sbin/partx
|
|
||||||
install_bin /usr/sbin/losetup
|
|
||||||
install_bin /usr/sbin/mkfs.ext4
|
|
||||||
for file in $RAMFS_COPY_BIN; do
|
|
||||||
install_bin ${file//:/ }
|
|
||||||
done
|
done
|
||||||
install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
|
install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
. /lib/functions/system.sh
|
. /lib/functions/system.sh
|
||||||
|
|
||||||
# initialize defaults
|
# initialize defaults
|
||||||
RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
|
|
||||||
RAMFS_COPY_DATA="" # extra data files
|
|
||||||
export MTD_CONFIG_ARGS=""
|
export MTD_CONFIG_ARGS=""
|
||||||
export INTERACTIVE=0
|
export INTERACTIVE=0
|
||||||
export VERBOSE=1
|
export VERBOSE=1
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
PART_NAME=firmware
|
PART_NAME=firmware
|
||||||
RAMFS_COPY_DATA=/lib/ar71xx.sh
|
RAMFS_COPY_DATA=/lib/ar71xx.sh
|
||||||
[ -x /usr/sbin/nandwrite ] && RAMFS_COPY_BIN=/usr/sbin/nandwrite
|
RAMFS_COPY_BIN='nandwrite'
|
||||||
|
|
||||||
CI_BLKSZ=65536
|
CI_BLKSZ=65536
|
||||||
CI_LDADR=0x80060000
|
CI_LDADR=0x80060000
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
RAMFS_COPY_BIN='/usr/bin/osafeloader /usr/bin/oseama'
|
RAMFS_COPY_BIN='osafeloader oseama'
|
||||||
|
|
||||||
PART_NAME=firmware
|
PART_NAME=firmware
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
PART_NAME=firmware
|
PART_NAME=firmware
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
|
|
||||||
RAMFS_COPY_BIN='/usr/sbin/fw_printenv /usr/sbin/fw_setenv'
|
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
||||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||||
|
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
. /lib/kirkwood.sh
|
. /lib/kirkwood.sh
|
||||||
|
|
||||||
RAMFS_COPY_BIN='/usr/sbin/fw_printenv /usr/sbin/fw_setenv'
|
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
||||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||||
|
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
. /lib/mvebu.sh
|
. /lib/mvebu.sh
|
||||||
|
|
||||||
RAMFS_COPY_BIN='/usr/sbin/fw_printenv /usr/sbin/fw_setenv'
|
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
||||||
RAMFS_COPY_DATA='/lib/mvebu.sh /etc/fw_env.config /var/lock/fw_printenv.lock'
|
RAMFS_COPY_DATA='/lib/mvebu.sh /etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# See /LICENSE for more information.
|
# See /LICENSE for more information.
|
||||||
#
|
#
|
||||||
|
|
||||||
RAMFS_COPY_BIN="/usr/sbin/fw_printenv /usr/sbin/fw_setenv /bin/mkdir /bin/dmesg /bin/sed /bin/grep"
|
RAMFS_COPY_BIN='fw_printenv fw_setenv dmesg'
|
||||||
RAMFS_COPY_DATA="/etc/fw_env.config"
|
RAMFS_COPY_DATA="/etc/fw_env.config"
|
||||||
REQUIRE_IMAGE_METADATA=0
|
REQUIRE_IMAGE_METADATA=0
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
RAMFS_COPY_BIN=/usr/sbin/nandwrite
|
RAMFS_COPY_BIN='nandwrite'
|
||||||
CI_KERNPART=none
|
CI_KERNPART=none
|
||||||
|
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
|
|
Loading…
Reference in a new issue