#!/bin/bash # Copyright (c) 2012, Richard Yao ryao@cs.stonybrook.edu # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # prefix-install.sh # A script for bootstrapping Gentoo Prefix on Linux and Solaris systems # Based on Gentoo Prefix Bootstrap Process for Solaris # See the actual guide before using this script: # http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-solaris.xml # Settings a user should configure include: # CHOST The system CHOST # EPREFIX Where the installation goes # MAKEOPTS Make options # UMASK The umask value to use for the installation # Settings available to advanced users include: # FEATURES Portage FEATURES options # ESYS_OPTS Emerge options for compiling @system # CFLAGS C Compiler Flags for compiling @system # CXXFLAGS C++ Compiler Flags for compiling @system # LDFLAGS Linker Flags for building @system # USE USE flags for @system cbuild # Additional packages can be included in the initial install by providing their # atoms as commandline arguments # e.g. ./prefix-install app-portage/genlop app-misc/screen # A reasonable way to invoke this script when installing Gentoo Prefix for all # users on a amd64 quadcore system is to do the following: # env CHOST=x86_64-pc-linux-gnu EPREFIX=/usr/local/gentoo MAKEOPTS=-j5 UMASK=022 ./prefix-install.sh # Known Requirements # bash # wget # Basic UNIX utilities (i.e. chmod, rm, cat, env) set -e umask ${UMASK:-"077"} CHOST=${CHOST:-"x86_64-pc-linux-gnu"} MAKEOPTS=${MAKEOPTS:-"-j5"} FEATURES=${FEATURES:-"parallel-fetch parallel-install"} # Workaround broken --jobs #ESYS_OPTS=${ESYS_OPTS:-"--jobs"} SAVED_CFLAGS=${CFLAGS:-'-O2 -pipe'} SAVED_CXXFLAGS=${CXXFLAGS:-'${CFLAGS}'} SAVED_LDFLAGS=${LDFLAGS:-'${LDFLAGS}'} SAVED_USE=${USE='unicode nls'} unset CFLAGS CXXFLAGS LDFLAGS USE # Code Listing 1.1: Export EPREFIX variable EPREFIX=${EPREFIX:-"$HOME/gentoo"} EPREFIX_TMP=${EPREFIX_TMP:-"${EPREFIX}/tmp"} # Code Listing 1.2: Add Prefix and utility paths to your PATH on Solaris 10/x86 PATH="${EPREFIX}/usr/bin:${EPREFIX}/bin:${EPREFIX_TMP}/usr/bin:${EPREFIX_TMP}/bin:/usr/sfw/bin:/usr/sfw/i386-sun-solaris2.10/bin:/usr/sfw/sparc-sun-solaris2.10/bin:/usr/bin:/bin" # Setup ./bootstrap-prefix if [ ! -f ./bootstrap-prefix.sh ] then rm -f ./bootstrap-prefix.sh wget -O ./bootstrap-prefix.sh "http://overlays.gentoo.org/proj/alt/browser/trunk/prefix-overlay/scripts/bootstrap-prefix.sh?format=txt" chmod u+x ./bootstrap-prefix.sh fi # Code Listing 1.3: Use the bootstrap script ./bootstrap-prefix.sh "${EPREFIX}" tree ./bootstrap-prefix.sh "${EPREFIX_TMP}" make ./bootstrap-prefix.sh "${EPREFIX_TMP}" wget ./bootstrap-prefix.sh "${EPREFIX_TMP}" sed ./bootstrap-prefix.sh "${EPREFIX_TMP}" coreutils8 # Workaround Linux failure without breaking Solaris Compatibility ./bootstrap-prefix.sh "${EPREFIX_TMP}" findutils5 ./bootstrap-prefix.sh "${EPREFIX_TMP}" tar22 ./bootstrap-prefix.sh "${EPREFIX_TMP}" patch9 #Workaround for Mac OS X ./bootstrap-prefix.sh "${EPREFIX_TMP}" grep ./bootstrap-prefix.sh "${EPREFIX_TMP}" gawk ./bootstrap-prefix.sh "${EPREFIX_TMP}" bash ./bootstrap-prefix.sh "${EPREFIX_TMP}" zlib ./bootstrap-prefix.sh "${EPREFIX_TMP}" python ./bootstrap-prefix.sh "${EPREFIX}" portage # Code Listing 1.4: rehash in bash hash -r # Code Listing 1.5: emerge sed emerge --oneshot sed # Code Listing 1.6: emerge bash env MAKEOPTS=-j1 emerge --oneshot --nodeps bash # Workaround for bash race condition when MAKEOPTS=-j65 # Code Listing 1.7: emerge linker and compiler emerge --oneshot --nodeps sys-apps/baselayout-prefix emerge --oneshot --nodeps app-arch/xz-utils emerge --oneshot --nodeps sys-devel/m4 emerge --oneshot --nodeps sys-devel/flex emerge --oneshot --nodeps sys-devel/bison emerge --oneshot --nodeps sys-devel/binutils-config if [ "`uname -s`" = "Darwin" ] then emerge --oneshot --nodeps sys-devel/binutils-apple emerge --oneshot --nodeps sys-devel/gcc-config emerge --oneshot --nodeps sys-devel/gcc-apple else # Workaround for broken =sys-devel/binutils-2.22 emerge --oneshot --nodeps " "${EPREFIX}/etc/make.conf" CHOST="${CHOST}" USE="${SAVED_USE}" FEATURES="${FEATURES}" CFLAGS="${SAVED_CXXFLAGS}" CXXFLAGS="${SAVED_CXXFLAGS}" LDFLAGS="${SAVED_LDFLAGS}" MAKEOPTS="${MAKEOPTS}" END # Code Listing 1.15: activating the most recent compiler gcc-config 2 # Code Listing 1.16: doing the final system installation emerge $ESYS_OPTS -e @system $@ # Code Listing 1.17: Creating a start-script cd ${EPREFIX}/usr/portage/scripts ./bootstrap-prefix.sh ${EPREFIX} startscript