Fix SHA512 checksum on build script, various tweaks

This commit is contained in:
Stefan Reimer 2012-10-29 22:18:15 -07:00
parent bc1a86dedc
commit dc5d0b3cd5
2 changed files with 47 additions and 16 deletions

View File

@ -11,9 +11,11 @@ GENTOO_MIRROR="http://gentoo.arcticnetwork.ca"
LOCAL_CACHE=/var/tmp LOCAL_CACHE=/var/tmp
IMAGE_ROOT=/mnt/gentoo IMAGE_ROOT=/mnt/gentoo
HOST_PORTDIR=/mnt/portage
# Import certain values from host config # Import certain values from host config
_PORTDIR=$(. /etc/make.conf && echo $PORTDIR) # _PORTDIR=$(. /etc/portage/make.conf && echo $PORTDIR)
PORTDIR=${_PORTDIR:-/usr/portage} # HOST_PORTDIR=${_PORTDIR:-/usr/portage}
set -o nounset set -o nounset
@ -28,16 +30,16 @@ fetch_file() {
local DIGEST=$2 local DIGEST=$2
FILE_NAME=$(basename ${URL}) FILE_NAME=$(basename ${URL})
MD5=$(curl -s -S ${DIGEST} | grep -o -E -e "^[0-9a-f]{32} *${FILE_NAME}$" | awk '{print $1}') SHA512=$(curl -s -S ${DIGEST} | grep -A1 -e "^# SHA512 HASH" | grep -o -E -e "^[0-9a-f]{128} *${FILE_NAME}$" | awk '{print $1}')
if [ -z ${MD5} ]; then if [ -z ${SHA512} ]; then
die "Unable to get checksum for ${FILE_NAME}, abort" die "Unable to get checksum for ${FILE_NAME}, abort"
fi fi
# Do we have local copy # Do we have local copy
if [ -f ${LOCAL_CACHE}/${FILE_NAME} ]; then if [ -f ${LOCAL_CACHE}/${FILE_NAME} ]; then
# if we have local, correct copy use it # if we have local, correct copy use it
if [ $(md5sum ${LOCAL_CACHE}/${FILE_NAME} | awk '{print $1}') = ${MD5} ]; then if [ $(sha512sum ${LOCAL_CACHE}/${FILE_NAME} | awk '{print $1}') = ${SHA512} ]; then
cp ${LOCAL_CACHE}/${FILE_NAME} . cp ${LOCAL_CACHE}/${FILE_NAME} .
return return
else else
@ -46,7 +48,7 @@ fetch_file() {
fi fi
wget -nc ${URL} || die "Cannot download ${URL}!" wget -nc ${URL} || die "Cannot download ${URL}!"
if [ $(md5sum ${FILE_NAME} | awk '{print $1}') != ${MD5} ]; then if [ $(sha512sum ${FILE_NAME} | awk '{print $1}') != ${SHA512} ]; then
die "Invalid checksum for ${FILE_NAME}!" die "Invalid checksum for ${FILE_NAME}!"
fi fi
@ -117,8 +119,9 @@ setup_chroot() {
PORTAGE_SNAPSHOT="${GENTOO_MIRROR}/snapshots/portage-latest.tar.bz2" PORTAGE_SNAPSHOT="${GENTOO_MIRROR}/snapshots/portage-latest.tar.bz2"
if [ ${BIND_PORTAGE} = 1 ] ; then if [ ${BIND_PORTAGE} = 1 ] ; then
mkdir -p usr/portage if [ -d ${ROOT_FS}/${BIND_PORTAGE} ] ; then
mount --bind ${PORTDIR} ${ROOT_FS}/usr/portage || die "Error mounting ${PORTDIR}" mount --bind ${PORTDIR} ${ROOT_FS}/${BIND_PORTAGE} || die "Error mounting ${PORTDIR}"
fi
else else
# install latest portage snapshot # install latest portage snapshot
if [ ! -d "usr/portage" ] ; then if [ ! -d "usr/portage" ] ; then
@ -139,7 +142,6 @@ setup_chroot() {
# Compile own kernel later # Compile own kernel later
# boot + kernel + lib/modules # boot + kernel + lib/modules
# make.conf
# etc/portage/* # etc/portage/*
if [ ${INTERACTIVE} = 1 ]; then if [ ${INTERACTIVE} = 1 ]; then
@ -158,8 +160,8 @@ cleanup() {
local ROOT_FS=$1 local ROOT_FS=$1
umount ${ROOT_FS}/dev ${ROOT_FS}/sys ${ROOT_FS}/proc umount ${ROOT_FS}/dev ${ROOT_FS}/sys ${ROOT_FS}/proc
if [ ${BIND_PORTAGE} = 1 ]; then if [ ${BIND_PORTAGE} != 0 ]; then
umount ${ROOT_FS}/usr/portage umount ${ROOT_FS}/${BIND_PORTAGE}
fi fi
} }
@ -176,9 +178,9 @@ OPTIONS:
-a arch, either i686 or x86_64, defaults to uname -m -a arch, either i686 or x86_64, defaults to uname -m
-p profile, either hardened or hardened-no-multilib or server(default) -p profile, either hardened or hardened-no-multilib or server(default)
-t The timezone to use, default to GMT -t The timezone to use, default to GMT
-r chroot location, default /mnt/gentoo -r chroot location (default $IMAGE_ROOT )
-c local cache, default /var/tmp -c local cache (default $LOCAL_CACHE)
-b bind mount host portage tree instead of installing portage inside chroot -b bind mount host portage tree (default $HOST_PORTDIR)
-i interactive, setting up chroot and enter it, skip extracting stage3, portage, etc. -i interactive, setting up chroot and enter it, skip extracting stage3, portage, etc.
-v Verbose -v Verbose
EOF EOF
@ -193,7 +195,7 @@ fi
VERBOSE=0 VERBOSE=0
BIND_PORTAGE=0 BIND_PORTAGE=0
INTERACTIVE=0 INTERACTIVE=0
while getopts ":a:p:t:r:c:bvhi" OPTIONS; do while getopts ":a:p:t:r:c:m:bvhi" OPTIONS; do
case $OPTIONS in case $OPTIONS in
a ) ARCH=$OPTARG;; a ) ARCH=$OPTARG;;
p ) PROFILE=$OPTARG;; p ) PROFILE=$OPTARG;;
@ -203,6 +205,7 @@ while getopts ":a:p:t:r:c:bvhi" OPTIONS; do
r ) IMAGE_ROOT=$OPTARG;; r ) IMAGE_ROOT=$OPTARG;;
c ) LOCAL_CACHE=$OPTARG;; c ) LOCAL_CACHE=$OPTARG;;
i ) INTERACTIVE=1;; i ) INTERACTIVE=1;;
m ) MAKE_CONF=$OPTARG;;
? ) ? )
usage usage
exit exit

View File

@ -0,0 +1,28 @@
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
DO_USE="mmx sse sse2"
# USE_NOT="-avahi -abiword -fortran -nfsv3 -arts -ipv6"
USE_NOT="-avahi -hal -ipv6 -X -gtk -gtk3 -qt4 -kde -webkit -alsa -opengl"
DISTDIR="/mnt/portage/distfiles"
PORTDIR="/mnt/portage/portage"
PKGDIR="/mnt/portage/packages"
PORTAGE_TMPDIR="/tmp"
PORTAGE_NICENESS=10
MAKEOPTS="-j8"
CLEAN_DELAY="3"
LINGUAS="en de"
USE="${DO_USE} ${USE_NOT}"