2007-09-23 08:04:48 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2013-05-06 12:48:46 +00:00
|
|
|
## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2007-09-23 08:04:48 +00:00
|
|
|
|
|
|
|
Restore_cache ()
|
|
|
|
{
|
2007-09-23 08:04:49 +00:00
|
|
|
DIRECTORY="${1}"
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
2007-09-23 08:04:49 +00:00
|
|
|
if [ -d "${DIRECTORY}" ]
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
|
|
|
# Restore old cache
|
2008-04-15 15:16:28 +00:00
|
|
|
if [ "$(stat --printf %d ${DIRECTORY})" = "$(stat --printf %d chroot/var/cache/apt/archives)" ]
|
|
|
|
then
|
|
|
|
# with hardlinks
|
2012-10-27 21:37:35 +00:00
|
|
|
find "${DIRECTORY}" -name "*.deb" | xargs cp -fl -t chroot/var/cache/apt/archives
|
2008-04-15 15:16:28 +00:00
|
|
|
else
|
|
|
|
# without hardlinks
|
2012-10-27 21:37:35 +00:00
|
|
|
find "${DIRECTORY}" -name "*.deb" | xargs cp -t chroot/var/cache/apt/archives
|
2008-04-15 15:16:28 +00:00
|
|
|
fi
|
2007-09-23 08:04:48 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
Save_cache ()
|
|
|
|
{
|
2007-09-23 08:04:49 +00:00
|
|
|
DIRECTORY="${1}"
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
|
|
|
# Cleaning current cache
|
2011-07-19 09:13:17 +00:00
|
|
|
# In case of interrupted or incomplete builds, this may return an error,
|
|
|
|
# but we still do want to save the cache.
|
|
|
|
Chroot chroot "apt-get autoclean" || true
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
if ls chroot/var/cache/apt/archives/*.deb > /dev/null 2>&1
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
|
|
|
# Creating cache directory
|
2007-09-23 08:05:11 +00:00
|
|
|
mkdir -p "${DIRECTORY}"
|
2007-09-23 08:04:48 +00:00
|
|
|
|
|
|
|
# Saving new cache
|
2008-04-19 15:39:44 +00:00
|
|
|
for PACKAGE in chroot/var/cache/apt/archives/*.deb
|
|
|
|
do
|
|
|
|
if [ -e "${DIRECTORY}"/"$(basename ${PACKAGE})" ]
|
|
|
|
then
|
|
|
|
rm -f "${PACKAGE}"
|
|
|
|
else
|
|
|
|
mv "${PACKAGE}" "${DIRECTORY}"
|
|
|
|
fi
|
|
|
|
done
|
2007-09-23 08:04:48 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Purging current cache
|
|
|
|
rm -f chroot/var/cache/apt/archives/*.deb
|
|
|
|
fi
|
|
|
|
}
|