Improving .deb caching by using hardlinks (if possible).

This commit is contained in:
Daniel Baumann 2008-04-15 17:16:28 +02:00
parent 214ad680d3
commit fd818bdd1d
1 changed files with 16 additions and 2 deletions

View File

@ -18,9 +18,16 @@ Restore_cache ()
if [ -d "${DIRECTORY}" ]
then
# Restore old cache
if [ "$(stat --printf %d ${DIRECTORY})" = "$(stat --printf %d chroot/var/cache/apt/archives)" ]
then
# with hardlinks
cp -fl "${DIRECTORY}"/*.deb chroot/var/cache/apt/archives
else
# without hardlinks
cp "${DIRECTORY}"/*.deb chroot/var/cache/apt/archives
fi
fi
fi
}
Save_cache ()
@ -38,8 +45,15 @@ Save_cache ()
mkdir -p "${DIRECTORY}"
# Saving new cache
if [ "$(stat --printf %d ${DIRECTORY})" = "$(stat --printf %d chroot/var/cache/apt/archives)" ]
then
# with hardlinks
cp --force -l chroot/var/cache/apt/archives/*.deb "${DIRECTORY}"
else
# without hardlinks
mv -f chroot/var/cache/apt/archives/*.deb "${DIRECTORY}"
fi
fi
else
# Purging current cache
rm -f chroot/var/cache/apt/archives/*.deb