simplify STAGE checks - use In_List

Closes: #952917
This commit is contained in:
jnqnfe 2015-01-06 03:43:43 +00:00 committed by Lyndon Brown
parent 62b3efa686
commit ed2d70bde1
3 changed files with 101 additions and 109 deletions

View File

@ -61,22 +61,19 @@ esac
# Creating directory
mkdir -p binary/${INITFS}
for STAGE in ${LB_CACHE_STAGES}
do
if [ "${STAGE}" = "rootfs" ] && [ -d cache/binary_rootfs ]
then
# Removing old chroot
rm -rf binary/"${INITFS}"/filesystem.*
if In_list "rootfs" ${LB_CACHE_STAGES} && [ -d cache/binary_rootfs ]
then
# Removing old chroot
rm -rf binary/"${INITFS}"/filesystem.*
# Restoring old cache
mkdir -p binary/"${INITFS}"
cp -a cache/binary_rootfs/filesystem.* binary/"${INITFS}"
# Restoring old cache
mkdir -p binary/"${INITFS}"
cp -a cache/binary_rootfs/filesystem.* binary/"${INITFS}"
# Creating stage file
Create_stagefile .build/binary_rootfs
exit 0
fi
done
# Creating stage file
Create_stagefile .build/binary_rootfs
exit 0
fi
case "${LB_CHROOT_FILESYSTEM}" in
ext2|ext3|ext4)
@ -443,20 +440,17 @@ case "${LB_CHROOT_FILESYSTEM}" in
esac
for STAGE in ${LB_CACHE_STAGES}
do
if [ "${STAGE}" = "rootfs" ]
if In_list "rootfs" ${LB_CACHE_STAGES}
then
rm -rf cache/binary_rootfs
mkdir -p cache/binary_rootfs
if [ "${LB_CHROOT_FILESYSTEM}" != "none" ]
then
rm -rf cache/binary_rootfs
mkdir -p cache/binary_rootfs
if [ "${LB_CHROOT_FILESYSTEM}" != "none" ]
then
cp -a binary/"${INITFS}"/filesystem.* cache/binary_rootfs
fi
cp -a binary/"${INITFS}"/filesystem.* cache/binary_rootfs
fi
done
fi
# Creating stage file
Create_stagefile .build/binary_rootfs

View File

@ -27,60 +27,59 @@ Set_defaults
# Check architecture
Check_crossarchitectures
for STAGE in ${LB_CACHE_STAGES}
do
if [ "${STAGE}" = "bootstrap" ]
then
case "${1}" in
restore)
# Checking stage file
Check_stagefile .build/bootstrap_cache.restore
if ! In_list "bootstrap" ${LB_CACHE_STAGES}
then
exit 0
fi
if [ -d cache/bootstrap ]
then
Echo_message "Restoring bootstrap stage from cache..."
case "${1}" in
restore)
# Checking stage file
Check_stagefile .build/bootstrap_cache.restore
# Checking lock file
Check_lockfile .lock
if [ -d cache/bootstrap ]
then
Echo_message "Restoring bootstrap stage from cache..."
# Creating lock file
Create_lockfile .lock
# Checking lock file
Check_lockfile .lock
# Removing old chroot
rm -rf chroot
# Creating lock file
Create_lockfile .lock
# Restoring old cache
cp -a cache/bootstrap chroot
# Removing old chroot
rm -rf chroot
# Creating stage file
Create_stagefile .build/bootstrap_cache.restore
Create_stagefile .build/bootstrap
# Restoring old cache
cp -a cache/bootstrap chroot
exit 0
fi
;;
# Creating stage file
Create_stagefile .build/bootstrap_cache.restore
Create_stagefile .build/bootstrap
save)
Echo_message "Saving bootstrap stage to cache..."
exit 0
fi
;;
# Checking stage file
Check_stagefile .build/bootstrap_cache.save
save)
Echo_message "Saving bootstrap stage to cache..."
# Checking lock file
Check_lockfile .lock
# Checking stage file
Check_stagefile .build/bootstrap_cache.save
# Creating lock file
Create_lockfile .lock
# Checking lock file
Check_lockfile .lock
rm -rf cache/bootstrap
# Creating lock file
Create_lockfile .lock
mkdir -p cache
rm -rf cache/bootstrap
cp -a chroot cache/bootstrap
mkdir -p cache
# Creating stage file
Create_stagefile .build/bootstrap_cache.save
;;
esac
fi
done
cp -a chroot cache/bootstrap
# Creating stage file
Create_stagefile .build/bootstrap_cache.save
;;
esac

View File

@ -24,59 +24,58 @@ Arguments "${@}"
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
Set_defaults
for STAGE in ${LB_CACHE_STAGES}
do
if [ "${STAGE}" = "chroot" ]
then
case "${1}" in
restore)
Echo_message "Restoring chroot stage from cache..."
if ! In_list "chroot" ${LB_CACHE_STAGES}
then
exit 0
fi
# Checking stage file
Check_stagefile .build/chroot_cache.restore
case "${1}" in
restore)
Echo_message "Restoring chroot stage from cache..."
if [ -d cache/chroot ]
then
# Checking lock file
Check_lockfile .lock
# Checking stage file
Check_stagefile .build/chroot_cache.restore
# Creating lock file
Create_lockfile .lock
if [ -d cache/chroot ]
then
# Checking lock file
Check_lockfile .lock
# Removing old chroot
rm -rf chroot
# Creating lock file
Create_lockfile .lock
# Restoring old cache
cp -a cache/chroot chroot
# Removing old chroot
rm -rf chroot
# Creating stage file
Create_stagefile .build/chroot_cache.restore
# Restoring old cache
cp -a cache/chroot chroot
exit 0
fi
;;
# Creating stage file
Create_stagefile .build/chroot_cache.restore
save)
Echo_message "Saving chroot stage to cache..."
exit 0
fi
;;
# Checking stage file
Check_stagefile .build/chroot_cache.save
save)
Echo_message "Saving chroot stage to cache..."
# Checking lock file
Check_lockfile .lock
# Checking stage file
Check_stagefile .build/chroot_cache.save
# Creating lock file
Create_lockfile .lock
# Checking lock file
Check_lockfile .lock
rm -rf cache/chroot
# Creating lock file
Create_lockfile .lock
mkdir -p cache
rm -rf cache/chroot
cp -a chroot cache/chroot
mkdir -p cache
# Creating stage file
Create_stagefile .build/chroot_cache.save
;;
esac
fi
done
cp -a chroot cache/chroot
# Creating stage file
Create_stagefile .build/chroot_cache.save
;;
esac