Skip to content

Commit e207496

Browse files
authored
Merge pull request #119 from jandryuk/config-install
part2: Allow installing into /config
2 parents 29bf935 + 2a60993 commit e207496

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

part2/stages/Functions/install-main

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,10 @@ mount_dom0()
496496
mount_config()
497497
{
498498
# mount /config in the proper place if we can, bind it if already mounted
499-
if is_mounted /config ; then
499+
if is_mounted "${DOM0_MOUNT}/config" ; then
500+
echo "mount_config: skipping - \"${DOM0_MOUNT}/config\" already mounted" >&2
501+
return 0
502+
elif is_mounted /config ; then
500503
echo "mount_config: /config mounted, binding to ${DOM0_MOUNT}/config" >&2
501504
do_mount -o bind /config ${DOM0_MOUNT}/config
502505
return $?
@@ -872,16 +875,27 @@ install_file()
872875
local SRC="$1"
873876
local DST="$2"
874877
local PACKAGE_TYPE="$3"
878+
local config_mounted="0"
879+
local RET="0"
875880

876-
mkdir -p $(dirname "${DOM0_MOUNT}/${DST}") || return 1
881+
if [ "$( expr substr "${DST}" 1 8 )" = "/config/" ] ; then
882+
mount_config || return 1
883+
config_mounted="1"
884+
fi
885+
886+
mkdir -p $(dirname "${DOM0_MOUNT}/${DST}") || RET="1"
877887
rm -f "${DOM0_MOUNT}/${DST}.new" 2>/dev/null # ignore errors on this command.
878888
if [ "${PACKAGE_TYPE}" = "gz" ] ; then
879-
do_cmd gunzip -c "${SRC}" > "${DOM0_MOUNT}/${DST}.new" || return 1
889+
do_cmd gunzip -c "${SRC}" > "${DOM0_MOUNT}/${DST}.new" || RET="1"
880890
else
881-
cp "${SRC}" "${DOM0_MOUNT}/${DST}.new" || return 1
891+
cp "${SRC}" "${DOM0_MOUNT}/${DST}.new" || RET="1"
882892
fi
883893

884-
return 0
894+
if [ "$config_mounted" = "1" ] ; then
895+
do_umount "${DOM0_MOUNT}/config"
896+
fi
897+
898+
return "${RET}"
885899
}
886900

887901
commit_file()
@@ -891,11 +905,22 @@ commit_file()
891905
# the system may be left in a broken state.
892906

893907
local DST="$1"
908+
local RET=0
909+
local config_mounted=0
910+
911+
if [ "$( expr substr "${DST}" 1 8 )" = "/config/" ] ; then
912+
mount_config || return 1
913+
config_mounted="1"
914+
fi
894915

895916
rm -f "${DOM0_MOUNT}/${DST}"
896-
mv "${DOM0_MOUNT}/${DST}.new" "${DOM0_MOUNT}/${DST}" || return 1
917+
mv "${DOM0_MOUNT}/${DST}.new" "${DOM0_MOUNT}/${DST}" || RET=1
897918

898-
return 0
919+
if [ "$config_mounted" = "1" ] ; then
920+
do_umount "${DOM0_MOUNT}/config"
921+
fi
922+
923+
return "${RET}"
899924
}
900925

901926
exec_install_file()

0 commit comments

Comments
 (0)