-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsabayon-createrepo
executable file
·151 lines (124 loc) · 4.59 KB
/
sabayon-createrepo
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/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"
)
[ -z "$PUBKEY" ] || docker_volumes+=(-v "$PUBKEY:/etc/entropy/mykeys/key.pub")
[ -z "$PRIVATEKEY" ] || docker_volumes+=(-v "$PRIVATEKEY:/etc/entropy/mykeys/private.key")
if [ $# -eq 0 ]
then
docker_volumes+=(-v "$PORTAGE_ARTIFACTS:/usr/portage/packages" )
else
echo "Packages directory: ${args[0]}"
docker_volumes+=(-v "${args[0]}:/usr/portage/packages" )
fi
check_docker_requirements
echo "Repository: $REPOSITORY_NAME"
echo "Repository Description: $REPOSITORY_DESCRIPTION"
# Creating the building script on-the-fly
cat >$createrepo <<EOF
#!/bin/bash
set -e
built_pkgs=\$(find /usr/portage/packages -name "*.tbz2" | xargs)
repo="\${REPOSITORY:-default}"
mkdir -p /sabayon/artifacts
[[ -z "\${built_pkgs}" ]] && echo "ERROR: no tbz2s found" && exit 2
if [ -d "/sabayon/artifacts/standard" ]; then
echo "=== Repository already exists, syncronizing ==="
eit unlock \$repo || true
eit pull --quick \$repo || true
#eit sync \$repo
else
echo "=== Repository is empty, intializing ==="
echo "Yes" | eit init --quick \$repo
eit push --quick --force
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 ==="; }
echo "=== Injecting packages ==="
eit inject --quick \${built_pkgs} || { echo "ouch unable to inject" && exit 3; }
eit commit --quick
echo "=== Pushing built packages locally ==="
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 = enable
changelog = enable
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 $DOCKER_OPTS ${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
if [ -d "$OUTPUT_DIR/standard" ]; then
echo "The Sabayon repository files are in $OUTPUT_DIR"
echo "Now you can upload its content where you want"
echo ""
echo "Here it is the repository file how will look like "
echo "(if you plan to upload it to a webserver, modify the URI accordingly)"
echo "
[$REPOSITORY_NAME]
desc = $REPOSITORY_DESCRIPTION
repo=file://$OUTPUT_DIR#bz2
enabled = true
pkg = file://$OUTPUT_DIR
"
else
echo "Something failed :("
fi
rm -rf $createrepo
rm -rf $entropysrv