From b0008dd048b171e83e0eb2fe94bf1589190bc777 Mon Sep 17 00:00:00 2001 From: Nemanja Boric <4burgos@gmail.com> Date: Sat, 25 Aug 2018 19:13:02 +0200 Subject: [PATCH] Copy packages to pool if hardlinking is not supported On filesystems where hardlinking is not supported, freight-cache will failback to copy to add packages into the pool, which will support serving repositories from these filesystems (such as cloud storage mounted with fuse). --- lib/freight/apt.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index f8b8cd5..9929a7b 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -334,14 +334,15 @@ EOF SOURCE="$(apt_binary_sourcename "$CONTROL")" FILENAME="${NAME}_${VERSION##*:}_${ARCH}.deb" - # Link this package into the pool. + # Link or copy this package into the pool. POOL="pool/$DIST/$COMP/$PREFIX/$SOURCE" mkdir -p "$VARCACHE/$POOL" if [ ! -f "$VARCACHE/$POOL/$FILENAME" ]; then if [ "$PACKAGE" != "$FILENAME" ]; then echo "# [freight] adding $PACKAGE to pool (as $FILENAME)" >&2 else echo "# [freight] adding $PACKAGE to pool" >&2 fi - ln "$DISTCACHE/.refs/$COMP/$PACKAGE" "$VARCACHE/$POOL/$FILENAME" + ln "$DISTCACHE/.refs/$COMP/$PACKAGE" "$VARCACHE/$POOL/$FILENAME" >/dev/null 2>&1 || + cp "$DISTCACHE/.refs/$COMP/$PACKAGE" "$VARCACHE/$POOL/$FILENAME" fi # Build a list of the one-or-more `Packages` files to append with @@ -418,13 +419,14 @@ apt_cache_source() { # Package properties. Remove the epoch from the version number # in the package filename, as is customary. - # Link this source package into the pool. + # Link or copy this source package into the pool. POOL="pool/$DIST/$COMP/$(apt_prefix "$NAME")/$NAME" mkdir -p "$VARCACHE/$POOL" for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME"; do if [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" ] && ! [ -f "$VARCACHE/$POOL/$FILENAME" ]; then echo "# [freight] adding $FILENAME to pool" >&2 - ln "$DISTCACHE/.refs/$COMP/$FILENAME" "$VARCACHE/$POOL" + ln "$DISTCACHE/.refs/$COMP/$FILENAME" "$VARCACHE/$POOL" >/dev/null 2>&1 || + cp "$DISTCACHE/.refs/$COMP/$FILENAME" "$VARCACHE/$POOL" fi done