[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1085265: local-apt-repository: use caching



Package: local-apt-repository
Version: 0.9
Followup-For: Bug #1085265
X-Debbugs-Cc: okgomdjgbmoij@gmail.com

Dear Maintainer,


in the previous one, the loop doesn't do its job. fix
#!/bin/bash

set -e

DEBS=/srv/local-apt-repository
REPO=/var/lib/local-apt-repository

if ! test -d $DEBS
then
  # We still need ot create the files lest apt will complain
  > $REPO/Packages
  > $REPO/Sources

else

  # We want to cater for the possibility that something is added to $DEBS as we
  # run, or that a file is slowly written. In this case, we want to wait a bit
  # and restart. But lets bound this to 10 runs.
  for n in $(seq 0 10)
  do
      # This is the second round alreay, lets wait a while
      if [ "$n" != "0" ]
      then
        echo "Further changes are coming in, waiting..."
        sleep 10
      fi

      # Relative paths work better than absolute
      (cd $REPO
      apt-ftparchive packages --db cache.db ../../../$DEBS > $REPO/Packages
      apt-ftparchive sources --db cache.db ../../../$DEBS > $REPO/Sources
      ) && break || true
      # ^ this can fail during a partial write to the directory (which
      #   would be detected by the loop), so ignore errors here

  done

fi

apt-ftparchive \
	-o "APT::FTPArchive::Release::Origin=local-apt-repository" \
	-o "APT::FTPArchive::Release::Description=Local repository created by local-apt-repository" \
	release $REPO > $REPO/Release


Reply to: