-
Notifications
You must be signed in to change notification settings - Fork 8
/
sabayon-createrepo-cleanup
executable file
·115 lines (93 loc) · 3.71 KB
/
sabayon-createrepo-cleanup
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
109
110
111
112
113
114
115
#!/bin/bash
# Copyright 2016-2018 See AUTHORS file
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
. /sbin/sabayondevkit-functions.sh
SAB_WORKSPACE="${SAB_WORKSPACE:-$PWD}"
entropysrv=$(mktemp)
createrepo=$(mktemp)
REPOSITORY_NAME="${REPOSITORY_NAME:-default}"
REPOSITORY_DESCRIPTION="${REPOSITORY_DESCRIPTION:-My Sabayon repository}"
DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/eit-amd64}"
PORTAGE_ARTIFACTS="${PORTAGE_ARTIFACTS:-$SAB_WORKSPACE/portage_artifacts}"
OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/entropy_artifacts}"
DOCKER_OPTS="${DOCKER_OPTS:--ti --rm}"
args=("$@")
EDITOR=cat
docker_env=(-e "EDITOR=$EDITOR"
-e "REPOSITORY=$REPOSITORY_NAME"
-e "LC_ALL=en_US.UTF-8")
docker_volumes=(
-v "$OUTPUT_DIR:/sabayon/artifacts"
-v "$createrepo:/sabayon/bin/create_repo.sh"
-v "$entropysrv:/etc/entropy/server.conf"
-v "$PORTAGE_ARTIFACTS:/usr/portage/packages" )
[ -z "$PUBKEY" ] || docker_volumes+=(-v "$PUBKEY:/etc/entropy/mykeys/key.pub")
[ -z "$PRIVATEKEY" ] || docker_volumes+=(-v "$PRIVATEKEY:/etc/entropy/mykeys/private.key")
check_docker_requirements
echo "Repository: $REPOSITORY_NAME"
echo "Repository Description: $REPOSITORY_DESCRIPTION"
echo "Remove: ${args[@]}"
# Creating the building script on-the-fly
cat >$createrepo <<EOF
#!/bin/bash
set -e
repo="\${REPOSITORY:-default}"
if [ -d "/sabayon/artifacts/standard" ]; then
eit unlock \$repo || true
eit pull --quick \$repo || true
#eit sync \$repo
else
echo "ouch no repository there" && exit 3;
fi
[ -f "/etc/entropy/mykeys/key.pub" ] && [ -f "/etc/entropy/mykeys/private.key" ] && { ! eit key status \$repo; } && \
eit key import \$repo /etc/entropy/mykeys/private.key /etc/entropy/mykeys/key.pub && { eit key sign \$repo || true; } && { echo "=== Repository key imported successfully ==="; }
eit clean --quick || { echo "ouch unable to remove" && exit 3; }
eit vacuum --quick || { echo "ouch unable to remove" && exit 3; }
echo "Yes Yes Yes" | eit commit --quick
eit push --quick --force
EOF
chmod +x $createrepo
# Creating the entropy repository configuration on-the-fly
cat >$entropysrv <<EOF
# expiration-days = <internal value>
community-mode = enable
weak-package-files = disable
database-format = bz2
# sync-speed-limit =
# server-basic-languages = en_US C
# disabled-eapis = 1,2
# expiration-based-scope = disable
# nonfree-packages-directory-support = disable
rss-feed = disable
changelog = disable
rss-name = packages.rss
rss-base-url = http://packages.sabayon.org/?quicksearch=
rss-website-url = http://www.sabayon.org/
max-rss-entries = 10000
# max-rss-light-entries = 100
rss-light-name = updates.rss
managing-editor =
broken-reverse-deps = disable
default-repository = $REPOSITORY_NAME
repository=$REPOSITORY_NAME|$REPOSITORY_DESCRIPTION|file:///sabayon/artifacts
EOF
function cleanup {
rm -rf $createrepo
rm -rf $entropysrv
}
trap cleanup EXIT
echo "docker run $DOCKER_OPTS --entrypoint /bin/bash ${docker_env[@]} ${docker_volumes[@]} $DOCKER_IMAGE /sabayon/bin/create_repo.sh"
docker run $DOCKER_OPTS --entrypoint /bin/bash "${docker_env[@]}" "${docker_volumes[@]}" $DOCKER_IMAGE /sabayon/bin/create_repo.sh || true