-
Notifications
You must be signed in to change notification settings - Fork 0
/
az-repo-apt-add
executable file
·82 lines (66 loc) · 1.74 KB
/
az-repo-apt-add
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
#!/bin/sh -e
# Needs AZURE_STORAGE_SAS_TOKEN to be set
: "${AZ_STORAGE_ACCOUNT:=packageskaitai}"
: "${AZ_STORAGE_CONTAINER=test3}"
: "${REPO_DIR=repo0}"
: "${PKGS_SRC:=all_pkgs/*.deb}"
SCRIPT_DIR=$(dirname $0)
show_summary_info()
{
cat <<EOF
"# az-repo-apt-add
- AZ_STORAGE_ACCOUNT: $AZ_STORAGE_ACCOUNT
- AZ_STORAGE_CONTAINER: $AZ_STORAGE_CONTAINER
- REPO_DIR: $REPO_DIR
- PKGS_SRC: $PKGS_SRC
EOF
for I in $PKGS_SRC; do
ls -al "$I"
done
echo -n '- GPG_PRIV_KEY: '
[ -n "$GPG_PRIV_KEY" ] && echo '(set)' || echo '(not set)'
echo -n '- GPG_PASSPHRASE: '
[ -n "$GPG_PASSPHRASE" ] && echo '(set)' || echo '(not set)'
}
download_existing_repo()
{
echo "## Downloading existing repo"
mkdir -p "$REPO_DIR/dists/stable/main/binary-all"
az storage blob download \
--account-name "$AZ_STORAGE_ACCOUNT" \
--container-name "$AZ_STORAGE_CONTAINER" \
--name "dists/stable/main/binary-all/Packages.gz" \
--file "$REPO_DIR/dists/stable/main/binary-all/Packages.gz"
}
build_local_repo()
{
echo "## Building local repo"
if [ -n "$GPG_PRIV_KEY" ]; then
mkdir -p /gpg
export GPG_KEY_FILE=/gpg/privkey.asc
echo "* Saving GPG key as $GPG_KEY_FILE"
echo -n "$GPG_PRIV_KEY" >"$GPG_KEY_FILE"
fi
if [ -n "$GPG_PASSPHRASE" ]; then
export GPG_KEY_PASSPHRASE_FILE=/gpg/key-password
echo "* Saving GPG passphrase as $GPG_KEY_PASSPHRASE_FILE"
echo -n "$GPG_PASSPHRASE" >"$GPG_KEY_PASSPHRASE_FILE"
fi
export REPO_DIR
export PKGS_SRC
"$SCRIPT_DIR/repo-apt-handle"
}
upload_repo()
{
echo "## Uploading repo"
ls -alR "$REPO_DIR"
az storage blob upload-batch \
--account-name "$AZ_STORAGE_ACCOUNT" \
--destination "$AZ_STORAGE_CONTAINER" \
--overwrite \
--source "$REPO_DIR"
}
show_summary_info
download_existing_repo || :
build_local_repo
upload_repo