forked from tuna/tunasync-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapt_test.sh
executable file
·39 lines (30 loc) · 1.08 KB
/
apt_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# reqires: wget, yum-utils
set -e
set -o pipefail
_here=`dirname $(realpath $0)`
_here=`dirname ${_here}`
. ${_here}/helpers/apt-download
APT_VERSIONS=("debian-jessie" "debian-stretch" "ubuntu-xenial")
BASE_PATH="${TUNASYNC_WORKING_DIR}"
APT_PATH="${BASE_PATH}/apt/repo"
mkdir -p ${APT_PATH}
# APT mirror
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"
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}