blob: 0baf497bea850d9bb93310b074641e2b9c175171 (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/bash
# Syncs Arch repos based on info contained in repo.db files
# License: GPLv3
# Principles
# * Get repo.db from an Arch-like repo
# * Generate a list of available packages
# * Create sync whitelist (based on package blacklist)
# * Get packages
# * Check package signatures
# * Check database signatures
# * Sync repo => repo
# eval this
BASEURL="ftp://ftp.archlinux.org/\$repo/os/\$arch/\$file"
# Generates an URL from BASE_URL
# _Params_
# * repo
# * arch
# * file
eval_url() {
repo="$1"
arch="$2"
file="$3"
eval "${BASE_URL}"
}
# Returns contents of a repo
get_repos() {
rsync -av --include="*.db*" --exclude="*" rsync://${mirror}/${mirror_path}/ cache/
}
get_repo_content() {
# Return all contents
bsdtar tf cache/$1/os/$2/$1.db.tar.* | \
cut -d "/" -f 1 | \
sort -u
}
# Get the database compression as an extension
get_repo_ext() {
file "$1" | tr A-Z a-z | sed -e "s/^[^:]\+: *\(.z\).*$/.tar.\1/" -e "s/bz/&2"
}
# Prints blacklisted packages
get_blacklist() {
cut -d ':' -f 1 "${BLACKLIST_FILE}"
}
# repo
# arch
get_repo_file() {
[ ! -f "cache/${1}/os/${2}/${1}.db.tar.*" ] && return 1
echo cache/${1}/os/${2}/${1}.db.tar.*
}
# Process the databases and get the libre packages
init() {
# Fail on every error
set -E
source $(dirname $0)/config
source $(dirname $0)/local_config
source $(dirname $0)/libremessages
# Get the blacklisted packages
blacklist=($(get_blacklist))
# Sync the repos databases
get_repos
# Traverse all repo-arch pairs
for _arch in ${ARCHARCHES[@]}; do
for _repo in ${ARCHREPOS[@]}; do
msg "Processing ${_repo}-${_arch}"
repo_file=$(get_repo_file ${_repo} ${_arch})
# Remove blacklisted packages and count them
msg2 "Removing blacklisted packages: $(
LC_ALL=C repo-remove ${repo_file} ${blacklist[@]} 2>&1 | \
grep "\-> Removing" 2>/dev/null| wc -l)"
# Get db contents
db=($(get_repo ${_repo} ${_arch}))
msg2 "Process clean db for syncing..."
# Create a whitelist
echo ${db[@]} | tr ' ' "\n" | sed "s|$|*|g" > /tmp/${_repo}-${_arch}.whitelist
# Sync excluding everything but blacklist
rsync -av --include-from=/tmp/${_repo}-${_arch}.whitelist --exclude="*"
# Cleanup
unset db
done
done
# Cleanup
unset blacklist _arch _repo repo_file
}
|