2007-09-23 08:04:48 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2020-03-11 09:07:21 -01:00
|
|
|
## Copyright (C) 2016-2020 The Debian Live team
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
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
|
|
|
|
2015-01-06 02:46:37 -01:00
|
|
|
Restore_package_cache ()
|
2007-09-23 08:04:48 +00:00
|
|
|
{
|
2020-02-20 05:58:11 -01:00
|
|
|
local DIRECTORY="cache/packages.${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
|
2014-04-27 10:28:29 +00:00
|
|
|
if [ -e "${DIRECTORY}" ]
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
|
|
|
# Restore old cache
|
2015-08-10 19:45:00 +00:00
|
|
|
if [ "$(stat --printf %d ${DIRECTORY}/)" = "$(stat --printf %d chroot/var/cache/apt/archives/)" ]
|
2008-04-15 15:16:28 +00:00
|
|
|
then
|
|
|
|
# with hardlinks
|
2021-02-04 19:37:46 -01:00
|
|
|
find "${DIRECTORY}" -name "*.deb" -print0 | xargs -0 --no-run-if-empty cp -fl -t chroot/var/cache/apt/archives
|
2008-04-15 15:16:28 +00:00
|
|
|
else
|
|
|
|
# without hardlinks
|
2021-02-04 19:37:46 -01:00
|
|
|
find "${DIRECTORY}" -name "*.deb" -print0 | xargs -0 --no-run-if-empty 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
|
|
|
|
}
|
|
|
|
|
2015-01-06 02:46:37 -01:00
|
|
|
Save_package_cache ()
|
2007-09-23 08:04:48 +00:00
|
|
|
{
|
2020-02-20 05:58:11 -01:00
|
|
|
local DIRECTORY="cache/packages.${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
|
2020-02-20 05:58:11 -01:00
|
|
|
local PACKAGE
|
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
|
|
|
|
}
|