diff --git a/docker.sh b/docker.sh index e64fd1f..b303ff6 100755 --- a/docker.sh +++ b/docker.sh @@ -55,24 +55,17 @@ rm $cfg if [[ ! -z ${DRY_RUN:-} ]]; then export APT_DRY_RUN=1 fi + base_url="https://apt.dockerproject.org/repo" -remote_filelist="${APT_PATH}/filelist.remote" -local_filelist="${APT_PATH}/filelist.local" +remote_filelist="${APT_PATH}/filelist" +[[ -f $remote_filelist ]] && rm $remote_filelist for version in ${APT_VERSIONS[@]}; do apt-download-binary ${base_url} "$version" "main" "amd64" "${APT_PATH}" ${remote_filelist} || true apt-download-binary ${base_url} "$version" "main" "i386" "${APT_PATH}" ${remote_filelist} || true done -APT_BACKUP_PATH="${BASE_PATH}/backup/apt" -mkdir -p ${APT_BACKUP_PATH} -(cd ${APT_PATH}; find . -type f -iname "*.deb") | sed 's+^\./++' > ${local_filelist} -comm <(sort $remote_filelist) <(sort $local_filelist) -13 | while read file; do - echo "deleting ${file}" - mv "${APT_PATH}/$file" ${APT_BACKUP_PATH} -done - -rm ${remote_filelist} ${local_filelist} +apt-delete-old-debs ${APT_PATH} $remote_filelist # sync_docker "http://apt.dockerproject.org/" "${TUNASYNC_WORKING_DIR}/apt" # sync_docker "http://yum.dockerproject.org/" "${TUNASYNC_WORKING_DIR}/yum" diff --git a/helpers/apt-download b/helpers/apt-download index 2476722..2c58c1c 100644 --- a/helpers/apt-download +++ b/helpers/apt-download @@ -172,4 +172,20 @@ function apt-download-binary() { return $ERROR } +function apt-delete-old-debs { + local base_dir=$1 + local remote_filelist=$2 + + [[ ! -d ${base_dir} ]] && return 1 + [[ ! -f ${remote_filelist} ]] && return 1 + + local_filelist="${base_dir}/filelist.local" + (cd ${base_dir}; find . -type f -iname "*.deb") | sed 's+^\./++' > ${local_filelist} + comm <(sort $remote_filelist) <(sort $local_filelist) -13 | while read file; do + echo "deleting ${file}" + rm ${file} + done + rm $local_filelist +} + # vim: ts=4 sts=4 sw=4 diff --git a/termux.sh b/termux.sh index 1b25074..48d0b84 100755 --- a/termux.sh +++ b/termux.sh @@ -11,20 +11,14 @@ base_url=${TUNASYNC_UPSTREAM_URL:-"https://termux.net"} ARCHES=("aarch64" "all" "arm" "i686") -remote_filelist="${BASE_PATH}/filelist.remote" -local_filelist="${BASE_PATH}/filelist.local" +remote_filelist="${BASE_PATH}/filelist" +[[ -f $remote_filelist ]] && rm $remote_filelist for arch in ${ARCHES[@]}; do echo "start syncing: ${arch}" apt-download-binary "${base_url}" "stable" "main" "${arch}" "${BASE_PATH}" ${remote_filelist} || true done -BACKUP_PATH="${BASE_PATH}/backup/" -mkdir -p ${BACKUP_PATH} -(cd ${BASE_PATH}; find . -type f -iname "*.deb") | sed 's+^\./++' > ${local_filelist} -comm <(sort $remote_filelist) <(sort $local_filelist) -13 | while read file; do - echo "deleting ${file}" - mv "${BASE_PATH}/$file" ${BACKUP_PATH} -done +apt-delete-old-debs ${BASE_PATH} $remote_filelist echo "finished"