Merge "Update Gentoo element for element changes"

This commit is contained in:
Jenkins 2017-10-08 23:58:20 +00:00 committed by Gerrit Code Review
commit fd8f92e542
9 changed files with 204 additions and 53 deletions

View File

@ -34,3 +34,13 @@ Notes:
* You can set the GENTOO_PORTAGE_CLEANUP environment variable to true (or
anything other than False) to clean up portage from the system and get the
image size smaller.
* Gentoo supports many diferent versions of python, in order to select one
you may use the `GENTOO_PYTHON_TARGETS` environment variable to select
the versions of python you want on your image. The format of this variable
is a string as follows `"python2_7 python3_5"`.
* In addition you can select the primary python version you wish to use (that
which will be called by running the `python` command. The
`GENTOO_PYTHON_ACTIVE_VERSION` is used to set that mapping. The variable
contents can be something like `python3.5`.

View File

@ -0,0 +1,45 @@
#!/bin/bash
# Copyright 2017 Matthew Thode
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
if [[ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]]; then
set -x
fi
set -eu
set -o pipefail
# make /dev/shm dir if it doesn't exist
# mount tmpfs and chown it
# existing programs could be using /dev/shm
# This means it cannot be moved or backed
# up as a copy easily. The only remaining
# option is to move the link if it exists
# as a link. Existing programs will still
# hold the file handle of the original
# location open and new programs can use
# the fixed /dev/shm.
[[ -e /run/lock/shm_fixed ]] && exit 0 # shm has already been fixed
if [[ ! -d /dev/shm ]]; then
if [[ ! -e /dev/shm ]]; then
if [[ -L /dev/shm ]]; then
mv /dev/shm /dev/shm.orig
fi
mkdir /dev/shm
fi
fi
mount -t tmpfs none /dev/shm
chmod 1777 /dev/shm
mkdir -p /run/lock
touch /run/lock/shm_fixed

View File

@ -32,49 +32,9 @@ function show_options {
exit 0
}
function fix_shm {
# make /dev/shm dir if it doesn't exist
# mount tmpfs and chown it
# existing programs could be using /dev/shm
# This means it cannot be moved or backed
# up as a copy easily. The only remaining
# option is to move the link if it exists
# as a link. Existing programs will still
# hold the file handle of the original
# location open and new programs can use
# the fixed /dev/shm.
if [[ "${RUN_ONCE_SHM}" == '1' ]]; then
if [[ ! -d /dev/shm ]]; then
if [[ ! -e /dev/shm ]]; then
if [[ -L /dev/shm ]]; then
mv /dev/shm /dev/shm.orig
fi
mkdir /dev/shm
fi
fi
mount -t tmpfs none /dev/shm
chmod 1777 /dev/shm
RUN_ONCE_SHM='0'
fi
}
function unfix_shm {
# unmount tmpfs
# care about anything still using it
if [[ "${RUN_ONCE_SHM}" == '0' ]]; then
umount /dev/shm
if fuser /dev/shm; then
rmdir /dev/shm
fi
if [[ -e /dev/shm.orig ]]; then
mv /dev/shm.orig /dev/shm
fi
fi
}
function install_gentoo_packages {
RUN_ONCE_SHM='1'
if grep -q /dev/shm /proc/mounts; then
if mountpoint -q /dev/shm; then
emerge $@
elif [[ -k /dev/shm ]]; then
emerge $@
@ -98,7 +58,7 @@ while true; do
if [[ ! -f /usr/portage/profiles ]]; then
emerge-webrsync -q
fi
install_gentoo_packages -uDNv --with-bdeps=y --backtrack=99 --jobs=2 @world
install_gentoo_packages -uDNv --with-bdeps=y --complete-graph=y --jobs=2 @world
install_gentoo_packages --verbose=n --depclean
install_gentoo_packages -v --usepkg=n @preserved-rebuild
etc-update --automode -5

View File

@ -0,0 +1,34 @@
#!/bin/bash
# Copyright 2017 Matthew Thode
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
if [[ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]]; then
set -x
fi
set -eu
set -o pipefail
# unmount tmpfs
# care about anything still using it
[[ ! -e /run/lock/shm_fixed ]] && exit 0 # shm hasn't been modified
umount /dev/shm
if fuser /dev/shm; then
rmdir /dev/shm
fi
if [[ -e /dev/shm.orig ]]; then
mv /dev/shm.orig /dev/shm
fi
rm /run/lock/shm_fixed

View File

@ -1,3 +1,6 @@
export DIB_RELEASE=gentoo
export DISTRO_NAME=gentoo
export GENTOO_PROFILE=${GENTOO_PROFILE:-'default/linux/amd64/13.0'}
export GENTOO_PORTAGE_CLEANUP=${GENTOO_PORTAGE_CLEANUP:-'False'}
export GENTOO_PYTHON_TARGETS=${GENTOO_PYTHON_TARGETS:-'python2_7 python3_4'}
export GENTOO_PYTHON_ACTIVE_VERSION=${GENTOO_PYTHON_ACTIVE_VERSION:-'python3.4'}

View File

@ -6,15 +6,16 @@ fi
set -eu
set -o pipefail
# make sure system is in a consistent state
echo 'PYTHON_TARGETS="python3_4"' >> /etc/portage/make.conf
eselect python set python3.4
# allow these uninstalls to fail as they may not be installed
set +e
emerge -C -q dev-lang/python:2.7
emerge -C -q dev-vcs/git
set -e
USE="-build" emerge -q --backtrack=99 --jobs=2 --update --newuse --deep --with-bdeps=y @world
if mountpoint -q /dev/shm; then
echo "/dev/shm found in /proc/self/mountinfo"
elif [[ -k /dev/shm ]]; then
echo "/dev/shm exists and is stickied"
else
fix_shm
fi
# make world consistant
USE="-build" emerge -q --complete-graph=y --jobs=2 --update --newuse --deep --with-bdeps=y @world
# rebuild packages that might need it
USE="-build" emerge -q --jobs=2 --usepkg=n @preserved-rebuild
# remove unneeded packages
@ -45,3 +46,5 @@ if [[ -a /usr/sbin/grub2-install ]]; then
mkdir -p /tmp/grub
touch /tmp/grub/install
fi
unfix_shm

View File

@ -0,0 +1,19 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
mkdir -p /etc/portage/package.use
mkdir -p /etc/portage/package.keywords
# needed in order to install pip packages as root
echo 'dev-python/pip vanilla' >> /etc/portage/package.use/pip
# needed to create disk images
echo 'sys-fs/lvm2 -thin' >> /etc/portage/package.use/grub
echo 'sys-boot/grub device-mapper' >> /etc/portage/package.use/grub
# needed in order to install pip packages as root
echo '=dev-python/pip-9.0.1-r2 ~amd64' >> /etc/portage/package.keywords/pip

View File

@ -0,0 +1,78 @@
#!/bin/bash
if [[ ${DIB_DEBUG_TRACE:-0} -gt 0 ]]; then
set -x
fi
set -eu
set -o pipefail
if mountpoint -q /dev/shm; then
echo "/dev/shm found in /proc/self/mountinfo"
elif [[ -k /dev/shm ]]; then
echo "/dev/shm exists and is stickied"
else
fix_shm
fi
if [[ ! -f /usr/portage/profiles ]]; then
emerge-webrsync -q
fi
# get the directories in order
mkdir -p /etc/portage/profile
mkdir -p /etc/portage/package.keywords
mkdir -p /etc/portage/package.use
# python-3.6 and python-3.5 are masked and considered unstable for some reason
echo "PYTHON_TARGETS=\"${GENTOO_PYTHON_TARGETS}\"" >> /etc/portage/make.conf
if [[ "${GENTOO_PYTHON_TARGETS}" == *"python3_6"* ]]; then
echo -e "-python_targets_python3_6\n-python_single_target_python3_6" >> /etc/portage/profile/use.stable.mask
echo 'dev-lang/python:3.6 ~amd64' >> /etc/portage/package.keywords/python
echo '~dev-python/setuptools-36.0.1 ~amd64' >> /etc/portage/package.keywords/python
echo '~dev-python/pyxattr-0.6.0 ~amd64' >> /etc/portage/package.keywords/python
echo '~sys-apps/kmod-24 ~amd64' >> /etc/portage/package.keywords/python
[[ ! -e /usr/lib64/libpython3.6m.so ]] && USE="-build" emerge -1q --jobs=2 dev-lang/python:3.6
fi
if [[ "${GENTOO_PYTHON_TARGETS}" == *"python3_5"* ]]; then
echo -e "-python_targets_python3_5\n-python_single_target_python3_5" >> /etc/portage/profile/use.stable.mask
echo 'dev-lang/python:3.5 ~amd64' >> /etc/portage/package.keywords/python
echo '~dev-python/setuptools-36.0.1 ~amd64' >> /etc/portage/package.keywords/python
[[ ! -e /usr/lib64/libpython3.5m.so ]] && USE="-build" emerge -1q --jobs=2 dev-lang/python:3.5
fi
[[ "${GENTOO_PYTHON_TARGETS}" == *"python3_4"* ]] && [[ ! -e /usr/lib64/libpython3.4m.so ]] && USE="-build" emerge -1q --jobs=2 dev-lang/python:3.4
[[ "${GENTOO_PYTHON_TARGETS}" == *"python2_7"* ]] && [[ ! -e /usr/lib64/libpython2.7.so ]] && USE="-build" emerge -1q --jobs=2 dev-lang/python:2.7
# disable python in git if we have to, it only supports python-2.7
if [[ "${GENTOO_PYTHON_TARGETS}" != *"python2_7"* ]]; then
echo 'dev-vcs/git -python' >> /etc/portage/package.use/git
fi
# make sure we have the new python for portage bevore we possibly remove python 2.7
USE="-build" emerge -q --oneshot --jobs=2 --with-bdeps=y --update --newuse --deep sys-apps/portage dev-python/pyxattr
# set the active python version
eselect python set ${GENTOO_PYTHON_ACTIVE_VERSION}
# allow these uninstalls to fail as they may not be installed to begin with
set +e
if [[ "${GENTOO_PYTHON_TARGETS}" != *"python2_7"* ]]; then
emerge -C -q dev-lang/python:2.7
fi
if [[ "${GENTOO_PYTHON_TARGETS}" != *"python3_4"* ]]; then
emerge -C -q dev-lang/python:3.4
fi
if [[ "${GENTOO_PYTHON_TARGETS}" != *"python3_5"* ]]; then
emerge -C -q dev-lang/python:3.5
fi
if [[ "${GENTOO_PYTHON_TARGETS}" != *"python3_6"* ]]; then
emerge -C -q dev-lang/python:3.6
fi
set -e
# make world consistant
USE="-build" emerge -q --complete-graph=y --jobs=2 --update --newuse --deep --with-bdeps=y @world
# rebuild packages that might need it
USE="-build" emerge -q --jobs=2 --usepkg=n @preserved-rebuild
# remove unneeded packages
USE="-build" emerge --verbose=n --depclean
# rebuild packages that might have somehow depended on the unneeded packages
USE="-build" emerge -q --jobs=2 --usepkg=n @preserved-rebuild
unfix_shm

View File

@ -19,8 +19,7 @@ case "$DIB_INIT_SYSTEM" in
fi
;;
openrc)
# let dib-init-system's postinstall handle enabling init scripts
exit 0
rc-update add sshd default
;;
sysv)
# ssh is enabled by default, nothing to do