-
Notifications
You must be signed in to change notification settings - Fork 1
/
aptly-mc-mirror
executable file
·41 lines (34 loc) · 1.03 KB
/
aptly-mc-mirror
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
#!/bin/bash
# Creates separate mirrors for each component in a distribution.
# Useful until aptly implements mirror-as-is.
set -e
NAME="$1"
URL="$2"
DIST="$3"
ARCH="$4"
if [ -z "$DIST" ]; then
echo "Usage: $0 <name> <archive url> <distribution> [<architecture,architecture>]"
echo "Example: $0 trusty http://archive.ubuntu.com trusty amd64,source"
exit 1
fi
if [[ -n "$ARCH" ]]; then
if [[ "$ARCH" != ${ARCH/,source/} ]]; then
ARCHITECTURE="-architectures=${ARCH/,source/} -with-sources"
else
ARCHITECTURE="-architectures=$ARCH"
fi
fi
if [ -n "$5" ]
then
COMPONENTS="$5"
else
COMPONENTS=$(curl -s "$URL/dists/$DIST/Release" | grep "^Components: " | cut -d' ' -f2-)
fi
if [ -z "$COMPONENTS" ]
then
echo "Warning: COMPONENTS:<${COMPONENTS}> from ${DIST} from Archive ${URL} seem to be empty"
fi
for COMPONENT in $COMPONENTS; do
echo aptly $ARCHITECTURE mirror create "$NAME#$COMPONENT" "$URL" "$DIST" "$COMPONENT"
aptly $ARCHITECTURE mirror create "$NAME#$COMPONENT" "$URL" "$DIST" "$COMPONENT"
done