-
Notifications
You must be signed in to change notification settings - Fork 8
/
sabayon-buildpackages
executable file
·111 lines (97 loc) · 6.7 KB
/
sabayon-buildpackages
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
#!/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
SAB_WORKSPACE="${SAB_WORKSPACE:-$PWD}"
DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/builder-amd64}"
SAB_ARCH="${SAB_ARCH:-intel}"
DOCKER_PULL_IMAGE="${DOCKER_PULL_IMAGE:-0}"
MAKE_CONF="${MAKE_CONF:-$SAB_WORKSPACE/specs/make.conf}"
OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/portage_artifacts/}"
LOCAL_OVERLAY="${LOCAL_OVERLAY:-$SAB_WORKSPACE/local_overlay}"
ENTROPY_REPOSITORY="${ENTROPY_REPOSITORY:-main}" # Can be weekly, main, testing
DOCKER_OPTS="${DOCKER_OPTS:--ti --rm --cap-add=SYS_PTRACE}"
. /sbin/sabayondevkit-functions.sh
if [ $# -eq 0 ]
then
echo "No arguments supplied, at least you should provide some package you wish to compile. e.g. $0 app-text/tree"
exit 1
fi
docker_env=(-e "LC_ALL=en_US.UTF-8")
docker_volumes=( -v "$OUTPUT_DIR:/usr/portage/packages" )
[ -z "$PORTAGE_CACHE" ] || docker_volumes+=(-v "$PORTAGE_CACHE:/usr/portage")
[ -z "$BUILDER_PROFILE" ] || docker_env+=(-e "BUILDER_PROFILE=$BUILDER_PROFILE")
[ -z "$EMERGE_SPLIT_INSTALL" ] || docker_env+=(-e "EMERGE_SPLIT_INSTALL=$EMERGE_SPLIT_INSTALL")
[ -z "$BUILDER_JOBS" ] || docker_env+=(-e "BUILDER_JOBS=$BUILDER_JOBS")
[ -z "$USE_EQUO" ] || docker_env+=(-e "USE_EQUO=$USE_EQUO")
[ -z "$PRESERVED_REBUILD" ] || docker_env+=(-e "PRESERVED_REBUILD=$PRESERVED_REBUILD")
[ -z "$EQUO_INSTALL_ATOMS" ] || docker_env+=(-e "EQUO_INSTALL_ATOMS=$EQUO_INSTALL_ATOMS")
[ -z "$DEPENDENCY_SCAN_DEPTH" ] || docker_env+=(-e "DEPENDENCY_SCAN_DEPTH=$DEPENDENCY_SCAN_DEPTH")
[ -z "$FEATURES" ] || docker_env+=(-e "FEATURES=$FEATURES")
[ -z "$EMERGE_DEFAULTS_ARGS" ] || docker_env+=(-e "EMERGE_DEFAULTS_ARGS=$EMERGE_DEFAULTS_ARGS")
[ -z "$EQUO_INSTALL_VERSION" ] || docker_env+=(-e "EQUO_INSTALL_VERSION=$EQUO_INSTALL_VERSION")
[ -z "$EQUO_SPLIT_INSTALL" ] || docker_env+=(-e "EQUO_SPLIT_INSTALL=$EQUO_SPLIT_INSTALL")
[ -z "$ARTIFACTS_DIR" ] || docker_env+=(-e "ARTIFACTS_DIR=$ARTIFACTS_DIR")
[ -z "$ENTROPY_REPOSITORY" ] || docker_env+=(-e "ENTROPY_REPOSITORY=$ENTROPY_REPOSITORY")
[ -z "$SKIP_PORTAGE_SYNC" ] || docker_env+=(-e "SKIP_PORTAGE_SYNC=$SKIP_PORTAGE_SYNC")
[ -z "$EQUO_MIRRORSORT" ] || docker_env+=(-e "EQUO_MIRRORSORT=$EQUO_MIRRORSORT")
[ -z "$WEBRSYNC" ] || docker_env+=(-e "WEBRSYNC=$WEBRSYNC")
[ -z "$ENMAN_REPOSITORIES" ] || docker_env+=(-e "ENMAN_REPOSITORIES=$ENMAN_REPOSITORIES")
[ -z "$REMOVE_ENMAN_REPOSITORIES" ] || docker_env+=(-e "REMOVE_ENMAN_REPOSITORIES=$REMOVE_ENMAN_REPOSITORIES")
[ -z "$DISTFILES" ] || docker_volumes+=(-v "$DISTFILES:/usr/portage/distfiles")
[ -z "$INTERNAL_BUILDER" ] || docker_volumes+=(-v "$INTERNAL_BUILDER:/usr/sbin/builder")
[ -z "$ENTROPY_DOWNLOADED_PACKAGES" ] || docker_volumes+=(-v "$ENTROPY_DOWNLOADED_PACKAGES:/var/lib/entropy/client/packages")
[ -z "$DISTCC_HOSTS" ] || docker_env+=(-e "DISTCC_HOSTS=$DISTCC_HOSTS")
[ -z "${PRUNE_VIRTUALS}" ] || docker_env+=(-e "PRUNE_VIRTUALS=$PRUNE_VIRTUALS")
[ -z "$REPOSITORY_NAME" ] || docker_env+=(-e "REPOSITORY_NAME=$REPOSITORY_NAME")
[ -z "$ENMAN_ADD_SELF" ] || docker_env+=(-e "ENMAN_ADD_SELF=$ENMAN_ADD_SELF")
[ -z "$EQUO_MASKS" ] || docker_env+=(-e "EQUO_MASKS=$EQUO_MASKS")
[ -z "$EQUO_UNMASKS" ] || docker_env+=(-e "EQUO_UNMASKS=$EQUO_UNMASKS")
[ -z "$EMERGE_REMOVE" ] || docker_env+=(-e "EMERGE_REMOVE=$EMERGE_REMOVE")
[ -z "$REMOTE_OVERLAY" ] || docker_env+=(-e "REMOTE_OVERLAY=$REMOTE_OVERLAY")
[ -z "$REMOVE_LAYMAN_OVERLAY" ] || docker_env+=(-e "REMOVE_LAYMAN_OVERLAY=$REMOVE_LAYMAN_OVERLAY")
[ -z "$REMOVE_REMOTE_OVERLAY" ] || docker_env+=(-e "REMOVE_REMOTE_OVERLAY=$REMOVE_REMOTE_OVERLAY")
[ -z "$QA_CHECKS" ] || docker_env+=(-e "QA_CHECKS=$QA_CHECKS")
[ -z "$REMOTE_CONF_PORTDIR" ] || docker_env+=(-e "REMOTE_CONF_PORTDIR=$REMOTE_CONF_PORTDIR")
[ -z "$REMOTE_PORTDIR" ] || docker_env+=(-e "REMOTE_PORTDIR=$REMOTE_PORTDIR")
[ -z "$ETP_NOCACHE" ] || docker_env+=(-e "ETP_NOCACHE=$ETP_NOCACHE")
[ -z "$PRETEND" ] || docker_env+=(-e "PRETEND=$PRETEND")
[ -z "$BUILDER_VERBOSE" ] || docker_env+=(-e "BUILDER_VERBOSE=$BUILDER_VERBOSE")
[ -z "$DETECT_OBSOLETE" ] || docker_env+=(-e "DETECT_OBSOLETE=$DETECT_OBSOLETE")
[ -z "$TARGET_OVERLAY" ] || docker_env+=(-e "TARGET_OVERLAY=$TARGET_OVERLAY")
[ -d "$LOCAL_OVERLAY" ] && docker_volumes+=(-v "$LOCAL_OVERLAY:/usr/local/local_portage")
[ -z "$SHARE_WORKSPACE" ] || docker_volumes+=(-v "$SAB_WORKSPACE:/devkit-workspace")
[ -z "$PRE_SCRIPT" ] || docker_volumes+=(-v "$PRE_SCRIPT:/pre-script")
[ -z "$POST_SCRIPT" ] || docker_volumes+=(-v "$POST_SCRIPT:/post-script")
if [ -e $MAKE_CONF ]; then
echo "You specified a make.conf. I hope you know what are you doing"
docker_volumes+=(-v "$MAKE_CONF:/etc/portage/make.conf.custom") # file make.conf.custom is in the docker container
docker_env+=(-e "MAKE_CONF=/etc/portage/make.conf.custom") # tell to the builder where is our custom make.conf
fi
check_docker_requirements
[ $DOCKER_PULL_IMAGE -eq 1 ] && docker pull $DOCKER_IMAGE
if [ -d "$SAB_WORKSPACE"/specs ]; then
[ -e "$SAB_WORKSPACE"/specs/custom.mask ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/custom.mask:/opt/sabayon-build/conf/$SAB_ARCH/portage/package.mask/99-custom.mask")
[ -e "$SAB_WORKSPACE"/specs/custom.unmask ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/custom.unmask:/opt/sabayon-build/conf/$SAB_ARCH/portage/package.unmask/99-custom.unmask")
[ -e "$SAB_WORKSPACE"/specs/custom.use ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/custom.use:/opt/sabayon-build/conf/$SAB_ARCH/portage/package.use/99-custom.use")
[ -e "$SAB_WORKSPACE"/specs/custom.env ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/custom.env:/opt/sabayon-build/conf/$SAB_ARCH/portage/package.env")
[ -e "$SAB_WORKSPACE"/specs/custom.keywords ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/custom.keywords:/opt/sabayon-build/conf/$SAB_ARCH/portage/package.keywords/99-custom.keywords")
[ -d "$SAB_WORKSPACE"/specs/env ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/env/:/opt/sabayon-build/conf/$SAB_ARCH/portage/env/")
[ -d "/vagrant" ] && docker_volumes+=(-v "/vagrant:/vagrant")
fi
echo "Spawning the package builder container for '$@'."
echo ""
echo "docker run $DOCKER_OPTS \"${docker_env[@]}\" \"${docker_volumes[@]}\" $DOCKER_IMAGE $@"
docker run $DOCKER_OPTS "${docker_env[@]}" "${docker_volumes[@]}" $DOCKER_IMAGE "$@"