diff --git a/builder/Dockerfile b/builder/Dockerfile new file mode 100644 index 0000000..bba790e --- /dev/null +++ b/builder/Dockerfile @@ -0,0 +1,26 @@ +FROM sabayon/armhfp + +MAINTAINER mudler + +# Set locales to en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 + +# Perform post-upgrade tasks (mirror sorting, updating repository db) +ADD ./script/post-upgrade.sh /post-upgrade.sh +RUN /bin/bash /post-upgrade.sh && rm -rf /post-upgrade.sh +ADD ./script/depcheck /usr/local/bin/depcheck +# Adding our builder script that will run also as entrypoint +ADD ./script/builder /builder +RUN chmod +x /builder + +# Set environment variables. +ENV HOME /root + +# Define working directory. +WORKDIR / + +# Define standard volumes +VOLUME ["/usr/portage", "/usr/portage/distfiles", "/usr/portage/packages", "/var/lib/entropy/client/packages"] + +# Define default command. +ENTRYPOINT ["/builder"] diff --git a/builder/README.md b/builder/README.md new file mode 100644 index 0000000..7285389 --- /dev/null +++ b/builder/README.md @@ -0,0 +1,119 @@ +# Sabayon Builder: a Docker Project # + +[![Circle CI](https://circleci.com/gh/Sabayon/docker-builder-amd64.svg?style=svg)](https://circleci.com/gh/Sabayon/docker-builder-amd64) + +Attention! It's under strong development + +State: Alpha + +The purpose of this project is to provide an image of Sabayon docker-capable builder. +It is just a [Sabayon base](https://github.com/mudler/docker-sabayon-base) with upgrades and compilation tools. + +Images are also on Docker Hub [sabayon/builder-amd64](https://registry.hub.docker.com/u/sabayon/builder-amd64/) [sabayon/builder-amd64-squashed](https://registry.hub.docker.com/u/sabayon/builder-amd64-squashed/). + +## What is + +The docker container serves as a out-of-the-box builder for Sabayon. + +The image will run a script that will check that all the deps of your specified atom are available on entropy, and installs them before compiling the actual package; then, it will emerge and build the packages and it's dependency that are not already available on the official sabayon repository + +## How to use + +### 1) start docker + +Ensure to have the daemon started and running: + + sudo systemctl start docker + +### 2) build your packages + +The container expect as arguments the commands to be executed to emerge, it acts like a wrapper with few enhancements. + +For example, if you want to build app-text/tree + + docker run -ti --rm sabayon/builder-amd64 app-text/tree + +Or a package available in an overlay + + docker run -ti --rm sabayon/builder-amd64 plasma-meta --layman kde + +## Check the volumes for your output + +you can inspect the volumes mounted by docker, or mounting externally the output directories (in such case /usr/portage/distfiles) + + docker run -ti --rm -v "$PWD"/artifacts:/usr/portage/packages sabayon/builder-amd64 app-text/tree + +e.g. now you can find your tbz2 in your current directory, inside the "artifacts" folder + +## Example + +The -v flag can furthermore exploited and chained to obtain more fine-grained tweaks + +You can of course customize it further, and replace all the configuration that's already been setup on the Docker Image. + +- custom.unmask: will contain your unmasks +- custom.mask: will contain your masks +- custom.use: will contain your use flags +- custom.env: will contain your env specifications +- custom.keywords: will contain your keywords + +Exporting those files to your container is a matter of adding an argument to your docker run command. + +**Example. Exporting your custom.unmask:** + + -v /my/path/custom.unmask:/opt/sabayon-build/conf/intel/portage/package.unmask/custom.unmask + + +**Example. Exporting your custom.mask:** + + -v /my/path/custom.mask:/opt/sabayon-build/conf/intel/portage/package.mask/custom.mask + + +**Example. Exporting your custom.use:** + + + -v /my/path/custom.use:/opt/sabayon-build/conf/intel/portage/package.use/custom.use + + +**Example. Exporting your custom.env:** + + + -v /my/path/custom.env:/opt/sabayon-build/conf/intel/portage/package.env/custom.env + + +**Example. Exporting your custom.keywords:** + + + -v /my/path/custom.keywords:/opt/sabayon-build/conf/intel/portage/package.keywords/custom.keywords + + +In this way you tell to docker to mount your custom.* file inside /opt/sabayon-build/conf/intel/portage/package.*/custom.* inside the container. + +Keep in mind that the container have the portage directory located at /opt/sabayon-build/conf/intel/portage/ ; the /etc/portage folder is then symlinked to it. + +**Attention!** Remember also to use absolute paths or docker will fail to mount your files in the container. + + +## ENVIRONMENT VARIABLES + +You can tweak the default behavior of the script setting those env variables with docker. + +- **BUILDER_PROFILE**: Sets the profile for compilation, you can select it using the number or the name +- **BUILDER_JOBS**: How much jobs emerge will have assigned (-j option) +- **PRESERVED_REBUILD**: 1/0 to Enable/Disable preserved rebuild compilation +- **EMERGE_DEFAULTS_ARGS**: a list of commands that you might want to specify +- **FEATURES**: you can override default FEATURES (like in Portage's make.conf) +- **ARTIFACTS_DIR**: Copy emerge output files in this directory inside the container after all went as expected + +Sabayon related: +- **USE_EQUO: 1/0** Enable/Disable equo for installing the package dependencies (if you plan to use a pure gentoo repository, set it to 0, but the compilation process would be much longer) +- **EQUO_INSTALL_ATOMS**: Install the latest version of the dependency packages +- **EQUO_INSTALL_VERSION**: Install the specific version of the dependency packages +- **EQUO_SPLIT_INSTALL**: Install all the packages separately one by one + +You can pass the ENV options to docker with the **-e** flag + + + docker run -e "EQUO_INSTALL_VERSION=1" -e "EQUO_INSTALL_ATOMS=0" -ti --rm -v "$PWD"/artifacts:/usr/portage/packages sabayon/builder-amd64 app-text/tree + +**Note**: If you want to keep your container, remove the **--rm** option. diff --git a/builder/script/build.sh b/builder/script/build.sh new file mode 100755 index 0000000..227b89e --- /dev/null +++ b/builder/script/build.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -o nounset +set -o errexit + + +docker build -t sabayon/builder-amd64 . +docker run sabayon/builder-amd64 true || true +docker export $( docker ps -aq | xargs echo | cut -d ' ' -f 1) | docker import - sabayon/builder-amd64-tmp + + +mkdir -p ~/image +mkdir -p ~/imagesquashed + +cat <<- 'EOF' > ~/image/Dockerfile +FROM sabayon/builder-amd64-tmp +MAINTAINER mudler +# Define standard volumes +VOLUME ["/usr/portage", "/usr/portage/distfiles", "/usr/portage/packages", "/var/lib/entropy/client/packages"] + +# Define default command. +ENTRYPOINT ["/builder"] +EOF + +cp -rfv ~/image/Dockerfile ~/imagesquashed + +docker build -t sabayon/builder-amd64 ~/image +docker build -t sabayon/builder-amd64-squashed ~/imagesquashed diff --git a/builder/script/builder b/builder/script/builder new file mode 100755 index 0000000..76b0435 --- /dev/null +++ b/builder/script/builder @@ -0,0 +1,191 @@ +#!/usr/bin/env perl + +use Getopt::Long; + +my $profile = $ENV{BUILDER_PROFILE} // 3; +my $jobs = $ENV{BUILDER_JOBS} // 1; +my $use_equo = $ENV{USE_EQUO} // 1; +my $preserved_rebuild = $ENV{PRESERVED_REBUILD} // 0; +my $emerge_defaults_args = $ENV{EMERGE_DEFAULTS_ARGS} + // "--accept-properties=-interactive --verbose --oneshot --nospinner --quiet-build=y --complete-graph --buildpkg"; +$ENV{FEATURES} = $ENV{FEATURES} + // "parallel-fetch protect-owned compressdebug splitdebug -userpriv"; + +my $equo_install_atoms = $ENV{EQUO_INSTALL_ATOMS} // 1; +my $equo_install_version = $ENV{EQUO_INSTALL_VERSION} // 0; +my $equo_split_install = $ENV{EQUO_SPLIT_INSTALL} // 0; +my $artifacts_folder = $ENV{ARTIFACTS_DIR}; + +my @overlays; + +GetOptions( 'layman|overlay:s{,}' => \@overlays, 'equo|install:s{,}' => \@equo_install ); + +if ( @ARGV == 0 ) { + help(); + die(); +} + +$ENV{LC_ALL} = "en_US.UTF-8"; #here be dragons + +# Input: package, depth, and atom. Package: sys-fs/foobarfs, Depth: 1 (depth of the package tree) , Atom: 1/0 (enable disable atom output) +sub package_deps { + my $package = shift; + my $depth = shift // 1; + my $atom = shift // 0; + return + map { $_ =~ s/\[.*\]|\s//g; &atom($_) if $atom; $_ } + qx/equery -C -q g --depth=$depth $package/; #depth=0 it's all +} + +#Input: nothing +#Output: returns all available packages across all the repository installed in the machine +sub available_packages { + my @packages; + my @repos = qx|equo repo list -q|; + chomp(@repos); + push( @packages, qx|equo q list available -q $_| ) for @repos; + chomp(@packages); + return @packages; +} + +# Input: package (sys-fs/foobarfs) +# Output: Array of packages to be installed, that aren't installed in a Sabayon machine +sub calculate_missing { + my $package = shift; + + # Getting the package dependencies and the installed packages + my @Packages = package_deps( $package, 1, 1 ); + my @Installed_Packages = qx/equo q --quiet list installed/; + chomp(@Installed_Packages); + + #taking only the 4th column of output as key of the hashmap + my %installed_packs = + map { ( split( /\s/, $_ ) )[3] => 1 } @Installed_Packages; + my %available_packs = map { $_ => 1 } available_packages(); + +# removing from packages the one that are already installed and keeping only the available in the entropy repositories + my @to_install = grep( defined $available_packs{$_}, + uniq( grep( !defined $installed_packs{$_}, @Packages ) ) ); + + return grep { length } @to_install; +} + +# Input : complete gentoo package (sys-fs/foobarfs-1.9.2) +# Output: atom form (sys-fs/foobarfs) +sub atom { s/-[0-9]{1,}.*$//; } + +# Input: Array +# Output: array with unique elements +sub uniq { + keys %{ { map { $_ => 1 } @_ } }; +} + +# A barely print replacement +sub say { print join( "\n", @_ ) . "\n"; } + +sub help { + say "-> You should feed me with something", "", "Examples:", "", + "\t$0 app-text/tree", "\t$0 plasma-meta --layman kde", "", + "\t$0 app-foo/foobar --equo foo-misc/foobar --equo net-foo/foobar --layman foo --layman bar foo", + "**************************", "", +"You can supply multiple overlays as well: $0 plasma-meta --layman kde plab", + ""; +} + +say +"************* IF YOU WANT TO SUPPLY ADDITIONAL ARGS TO EMERGE, pass to docker EMERGE_DEFAULT_OPTS env with your options *************"; + +if ( @overlays > 0 ) { + say "Overlay(s) to add"; + foreach my $overlay (@overlays) { + say "\t- $overlay"; + } +} + +say "Installing:"; + +say "\t* " . $_ for @ARGV; + +say "* Syncing stuff for you, if it's the first time, can take a while"; + +# Syncronizing portage configuration and adding overlays +system("echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen"); #be sure about that. +system("cd /etc/portage/;git checkout master; git pull"); +system("echo 'y' | layman -f -a $_") for @overlays; + +my $reponame = "LocalOverlay"; + +# Setting up a local overlay if doesn't exists +if ( !-f "/usr/local/portage/profiles/repo_name" ) { + system("mkdir -p /usr/local/portage/{metadata,profiles}"); + system("echo 'LocalOverlay' > /usr/local/portage/profiles/repo_name"); + system("echo 'masters = gentoo' > /usr/local/portage/metadata/layout.conf"); + system("chown -R portage:portage /usr/local/portage"); +} +else { + open FILE, "; + close FILE; + chomp(@FILE); + $reponame = $FILE[0]; +} + +qx{ +echo '[$reponame] +location = /usr/local/portage +masters = gentoo +priority=9999 +auto-sync = no' > /etc/portage/repos.conf/local.conf +}; # Declaring the repo and giving priority + +system("mkdir -p /usr/portage/distfiles/git3-src"); + +# sync portage and overlays +system("layman -S;emerge --sync"); + +# preparing for MOAR automation +qx|eselect profile set $profile|; +qx{ls /usr/portage/licenses -1 | xargs -0 > /etc/entropy/packages/license.accept} + ; #HAHA +system("equo repo mirrorsort sabayonlinux.org;equo up && equo u") + if $use_equo; # Better don't be behind +qx|echo 'ACCEPT_LICENSE="*"' >> /etc/portage/make.conf|; #just plain evil + +my @packages = @ARGV; + +if ($use_equo) { + my @packages_deps; + foreach my $p (@packages) { + push( @packages_deps, calculate_missing( $p, 1 ) ) + if $equo_install_atoms; + push( @packages_deps, package_deps( $p, 1, 0 ) ) + if $equo_install_version; + } + @packages_deps = grep { defined() and length() } @packages_deps; #cleaning + say "", "Installing missing deps with equo", @packages_deps, ""; + if ($equo_split_install) { + system("equo i $_") for (@packages_deps,@equo_install); + } + else { + system("equo i @packages_deps @equo_install"); + } +} + +say "* Ready to compile, finger crossed"; + +my $rt = system("emerge $emerge_defaults_args -j $jobs @packages"); + +my $return = $rt >> 8; + +if ($preserved_rebuild) { + + system("emerge -j $jobs --buildpkg \@preserved-rebuild"); + +} + +# Copy files to artifacts folder +system( + "mkdir -p $artifacts_folder;cp -rfv /usr/portage/packages $artifacts_folder" +) if ( $artifacts_folder and !$return ); + +exit($return); diff --git a/builder/script/depcheck b/builder/script/depcheck new file mode 100755 index 0000000..ffcfcd6 --- /dev/null +++ b/builder/script/depcheck @@ -0,0 +1,303 @@ +#!/bin/bash +# PODNAME: depcheck +# +# Copyright (c) 2014 Michael Palimaka +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# A tool to report both undeclared and potentially-unused runtime dependencies. +# +# Depends on app-misc/pax-utils, app-portage/portage-utils and +# sys-apps/gentoo-functions. + +DEBUG=FALSE +IGNORE_DEPS=( "sys-libs/glibc" "sys-devel/gcc" ) +IGNORE_LINKS=( "/lib64/libgcc_s.so.1" ) +PKG_DIR="/var/db/pkg/" + +. /lib/gentoo/functions.sh + +bold() { + echo $@ + return + local bold=$(tput bold) + local normal=$(tput sgr0) + echo "${bold}${@}${normal}" +} + +debug() { + if [ $DEBUG = TRUE ]; then + # write to stderr so as not to interfere with function returns + echo "$@" 1>&2 + fi +} + +# app-foo/bar-1.2.3-r1 -> app-foo/bar +remove_atom_version() { + local atom=`qatom "${1}" | cut -d " " -f 1-2 | tr " " /` + echo $atom +} + +virtualcheck() { + debug Checking if ${libowner_pn} is provided by a virtual + for virtual in $(qdepends --nocolor --name-only --${1} --query ${libowner_pn} | grep ^virtual/) + do + debug Checking if ${virtual} is in dependencies + local isvirtualdep=$(qdepends --${1} ${atom} | grep ${virtual}) + + if [ $? -eq 0 ]; then + used_virtuals+=( ${virtual} ) + continue 2 + fi + done + + if [ "${1}" = "depend" ]; then + eerror "${obj} links to ${link}" + fi + eindent + eerror Missing ${1^^} on $(bold ${libowner_pn}) + eoutdent + errors=1 +} + +check_atom() { + + local errors=0 + local atom=$1 + local checked=() + local rdepends=() + local used_virtuals=() + + local objects=`qlist -qo ${atom}` + + if [ ! "${objects}" ]; then + einfo ${atom} does not have any objects installed, skipping... + echo + return + fi + + if [ -z "${INSIDE_PORTAGE}" ]; then + einfo Checking ${atom} for undeclared dependencies + eindent + fi + + local obj + for obj in $objects + do + debug "Checking ${obj}" + + readelf -h ${obj} > /dev/null 2>&1 + + # can it have stuff linked to it? + if [ $? -ne 0 ]; then + debug "It can't have links, skipping" + continue + fi + + local elf=`scanelf --format "#f%n" --nobanner --use-ldpath ${obj} 2>&1` + local links=`echo ${elf} | tr "," " "` + + # get a list of everything that it's linked to + local link + for link in $links + do + local ignore + for ignore in "${IGNORE_LINKS[@]}"; do + if [ "${ignore}" = "${link}" ]; then + debug "Ignoring ${link} due to blacklist" + continue 2 + fi + done + + # only check a library once per atom for performance reasons + local check + for check in "${checked[@]}"; do + if [ "${check}" = "${link}" ]; then + debug "Already checked ${link} for this atom, skipping" + continue 2 + fi + done + + checked=( "${checked[@]}" "${link}" ) + + debug "Found ${link}" + + local libowner=`qfile -vqC ${link} | uniq` + + if [ ! "${libowner}" ]; then + ewarn "Warning: installed file ${obj} is linked to ${link} which is not owned by any installed atom." + continue + fi + + debug "Owning package for ${link} is ${libowner}" + + local libowner_pn=$(remove_atom_version ${libowner}) + local my_pn=$(remove_atom_version ${atom}) + + rdepends+=( "${libowner_pn}" ) + + if [ "${libowner_pn}" = "${my_pn}" ]; then + debug "Owning package is self, ignoring" + continue + fi + + local ignorelib + for ignorelib in "${IGNORE_DEPS[@]}" + do + if [ "${libowner_pn}" = "${ignorelib}" ]; then + debug "Ignoring objects belonging to ${ignorelib}" + continue 2 + fi + done + + debug "Checking if ${libowner_pn} is in the [R]DEPEND list of ${atom}" + + local isdep + isdep=`qdepends -d ${atom} | grep ${libowner_pn}` + if [ $? -ne 0 ]; then + virtualcheck depend + fi + + local isrdep + isrdep=`qdepends -r ${atom} | grep ${libowner_pn}` + if [ $? -ne 0 ]; then + virtualcheck rdepend + fi + + + done + + done + + local ebuild_rdepends=() + for rdepend in $(qdepends --nocolor --quiet --rdepend ${atom} | sed -e "s/\[[^]]*\]//g" | cut -d : -f 2-) + do + if [[ ${rdepend} = !* ]] ; then + debug Skipping blocker: ${rdepend} + continue + elif [[ ${rdepend} = virtual/* ]] ; then + for virtual in "${used_virtuals[@]}" + do + if [[ ${virtual} == $(remove_atom_version ${rdepend}) ]]; then + debug Skipping virtual: ${rdepend} + continue 2 + fi + done + fi + ebuild_rdepends+=( $(remove_atom_version $rdepend) ) + done + + debug "Ebuild RDEPENDS: ${ebuild_rdepends[@]}" + debug "Linked RDEPENDS: ${rdepends[@]}" + + local suspect_rdepends=$(comm -13 <(echo ${rdepends[@]} | sed 's/ /\n/g' | sort -u) <(echo ${ebuild_rdepends[@]} | sed 's/ /\n/g' | sort -u)) + if [ "${suspect_rdepends}" ]; then + ewarn "Suspect RDEPEND: $(bold ${suspect_rdepends})" + fi + + if [ -z "${INSIDE_PORTAGE}" ]; then + eoutdent + if [ -n "${CAT}" ]; then + echo + fi + fi + + return $errors + +} + +check_package() { + + local package=$1 + local atoms=`qlist -IcCS ${package} | tr ' ' '-' | cut -d : -f1` + + debug Package ${package} own atoms: ${atoms} + + if [ ! "${atoms}" ]; then + eerror ERROR: ${package} is not a valid atom + exit 1 + fi + + for atom in ${atoms}; do + check_atom ${atom} + done + +} + +check_category() { + + local errors=0 + + for package in `ls "${PKG_DIR}/${1}"`; do + + check_package "${1}/${package}" + + if [ $? -ne 0 ]; then + errors=1 + fi + + done; + + return $errors + +} + +BINNAME=`basename ${0}` +if [ -z $1 ]; then + echo "Checks emerged package(s) for undeclared depedencies" + echo + echo "Usage: ${BINNAME} [ atom | -c category | -a ]" + echo + echo "Examples:" + echo "Check a single package: ${BINNAME} app-foo/bar-1.2.3" + echo "Check a category: ${BINNAME} -c app-foo" + echo "Check everything: ${BINNAME} -a" + exit 1 +fi + +# check a particular category +if [ "$1" = "-c" ]; then + + CAT=$2 + + if [ ! -d "${PKG_DIR}/${CAT}" ]; then + eerror ERROR: No packages from the category ${CAT} have been emerged yet + exit 1 + fi + + check_category $CAT + +# check everything +elif [ "$1" = "-a" ]; then + + for category in `ls ${PKG_DIR}`; do + check_category $category + done; + +else + check_package $1 +fi + +if [ $DEBUG = TRUE ]; then + if [ $? -eq 0 ]; then + einfo Checking complete, no errors found + else + eerror Checking complete, errors found + fi +fi \ No newline at end of file diff --git a/builder/script/post-upgrade.sh b/builder/script/post-upgrade.sh new file mode 100644 index 0000000..00318a4 --- /dev/null +++ b/builder/script/post-upgrade.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +PACKAGES_TO_REMOVE=( + "app-admin/sudo" + "x11-libs/gtk+:3" + "x11-libs/gtk+:2" + "dev-db/mariadb" + "sys-fs/ntfs3g" + "app-accessibility/at-spi2-core" + "app-accessibility/at-spi2-atk" + "sys-devel/base-gcc:4.7" + "sys-devel/gcc:4.7" + "net-print/cups" + "dev-util/gtk-update-icon-cache" + "dev-qt/qtscript" + "dev-qt/qtchooser" + "dev-qt/qtcore" + "app-shells/zsh" + "app-shells/zsh-pol-config" + "dev-db/mysql-init-scripts" + "dev-lang/ruby" + "app-editors/vim" + "dev-util/gtk-doc-am" + "media-gfx/graphite2" + "x11-apps/xset" + "x11-themes/hicolor-icon-theme" + "media-libs/tiff" + "app-eselect/eselect-lcdfilter" + "app-eselect/eselect-mesa" + "app-eselect/eselect-opengl" + "app-eselect/eselect-qtgraphicssystem" + "x11-libs/pixman" + "x11-libs/libvdpau" + "x11-libs/libxshmfence" + "x11-libs/libXxf86vm" + "x11-libs/libXinerama" + "x11-libs/libXdamage" + "x11-libs/libXcursor" + "x11-libs/libXfixes" + "x11-libs/libXv" + "x11-libs/libXcomposite" + "x11-libs/libXrandr" + "media-libs/jbig2dec" + "dev-libs/libcroco" + "app-text/qpdf" + "media-fonts/urw-fonts" + "app-text/libpaper" + "dev-python/snakeoil" + "dev-libs/atk" + "dev-perl/DBI" + "app-text/sgml-common" + "sys-power/upower" +) + +FILES_TO_REMOVE=( + "/.viminfo" + "/.history" + "/.zcompdump" + "/var/log/emerge.log" + "/var/log/emerge-fetch.log" +) + +PACKAGES_TO_ADD=( + "app-eselect/eselect-bzimage" + "app-text/pastebunz" + "app-admin/perl-cleaner" + "sys-apps/grep" + "sys-kernel/sabayon-sources" + "app-misc/sabayon-version" + "app-portage/layman" + "app-portage/eix" + "net-misc/rsync" + "app-crypt/gnupg" + "sys-devel/gcc" + "sys-devel/base-gcc" + "dev-vcs/git" + "app-portage/gentoolkit" + "net-misc/openssh" + "sys-devel/automake" +) + +rsync -av -H -A -X --delete-during "rsync://rsync.at.gentoo.org/gentoo-portage/licenses/" "/usr/portage/licenses/" +ls /usr/portage/licenses -1 | xargs -0 > /etc/entropy/packages/license.accept + +# upgrading machine +equo up && equo u + +# Handling install/removal of packages specified in env +equo rm --deep --configfiles --force-system "${PACKAGES_TO_REMOVE[@]}" +equo i "${PACKAGES_TO_ADD[@]}" + +# Configuring layman +mkdir /etc/portage/repos.conf/ +mkdir /var/lib/layman/ +layman-updater -R + +# Configuring repoman +mkdir -p /usr/portage/distfiles/ && wget http://www.gentoo.org/dtd/metadata.dtd -O /usr/portage/distfiles/metadata.dtd + +# Merging defaults configurations +echo -5 | equo conf update + +pushd /opt/sabayon-build/ + +git pull + +popd + +# Writing package list file +equo q list installed -qv > /etc/sabayon-pkglist + +# Cleaning equo package cache +equo cleanup + +# Cleanup Perl cruft +perl-cleaner --ph-clean + +# remove SSH keys +rm -rf /etc/ssh/*_key* + +# Configuring for build +echo "*" > /etc/eix-sync.conf +emerge-webrsync +eix-sync +echo "y" | layman -f -a sabayon +echo "y" | layman -f -a sabayon-distro + +# remove LDAP keys +rm -f /etc/openldap/ssl/ldap.pem /etc/openldap/ssl/ldap.key \ +/etc/openldap/ssl/ldap.csr /etc/openldap/ssl/ldap.crt + +# Remove scripts +rm -rf /post-upgrade.sh + +# Cleanup +rm -rf "${FILES_TO_REMOVE[@]}" diff --git a/distccd/Dockerfile b/distccd/Dockerfile new file mode 100644 index 0000000..b551f5b --- /dev/null +++ b/distccd/Dockerfile @@ -0,0 +1,34 @@ +FROM sabayon/armhfp + +MAINTAINER mudler + +# Set locales to en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 + +ADD ./ext/qemu-arm-static /usr/bin/qemu-arm-binfmt + +RUN rsync -av "rsync://rsync.at.gentoo.org/gentoo-portage/licenses/" "/usr/portage/licenses/" && \ + ls /usr/portage/licenses -1 | xargs -0 > /etc/entropy/packages/license.accept + +RUN equo up && equo u && equo i distcc gcc base-gcc + +# Cleaning accepted license2s +RUN rm -rf /etc/entropy/packages/license.accept + +RUN echo -5 | equo conf update + +# Perform post-upgrade tasks (mirror sorting, updating repository db) +ADD ./scripts/setup.sh /setup.sh +RUN /bin/bash /setup.sh && rm -rf /setup.sh + +# Set environment variables. +ENV HOME /root + +# Define working directory. +WORKDIR / + +CMD ["/usr/bin/distccd", "--allow", "0.0.0.0/0", "--user", "distcc", "--log-level", "notice", "--log-stderr", "--no-detach"] + +EXPOSE 3632 + + diff --git a/distccd/ext/qemu-arm-static b/distccd/ext/qemu-arm-static new file mode 100755 index 0000000..ecace8b Binary files /dev/null and b/distccd/ext/qemu-arm-static differ diff --git a/distccd/scripts/setup.sh b/distccd/scripts/setup.sh new file mode 100755 index 0000000..ac751f3 --- /dev/null +++ b/distccd/scripts/setup.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +/usr/sbin/env-update +. /etc/profile + +pushd /etc/portage +git stash +git pull +popd + +equo i base-gcc +equo cleanup + +exit 0