Various build.sh fixes
This commit is contained in:
parent
5eb28bfcaa
commit
19078eaede
@ -27,31 +27,46 @@ fetch_file() {
|
|||||||
FILE_NAME=$(basename ${URL})
|
FILE_NAME=$(basename ${URL})
|
||||||
SHA512=$(curl -s -S ${DIGEST} | grep -A1 -e "^# SHA512 HASH" | grep -o -E -e "^[0-9a-f]{128} *${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 ${SHA512} ]; then
|
# Check if local cache is usable
|
||||||
die "Unable to get checksum for ${FILE_NAME}, abort"
|
if [ ! -d ${LOCAL_CACHE} ] || [ ! -w ${LOCAL_CACHE} ]; then
|
||||||
|
die "Local cache ${LOCAL_CACHE} unusable!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Do we have local copy
|
if [ -z ${SHA512} ]; then
|
||||||
if [ -f ${LOCAL_CACHE}/${FILE_NAME} ]; then
|
# Let's try md5sum before giving up
|
||||||
# if we have local, correct copy use it
|
MD5=$(curl -s -S ${DIGEST} | grep -o -E -e "^[0-9a-f]{32} *${FILE_NAME}$" | awk '{print $1}')
|
||||||
|
if [ -z ${MD5} ]; then
|
||||||
|
die "Unable to get checksum for ${FILE_NAME}, abort"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Do we have local copy, if not download
|
||||||
|
if [ ! -f ${LOCAL_CACHE}/${FILE_NAME} ]; then
|
||||||
|
wget -O ${LOCAL_CACHE}/${FILE_NAME} ${URL} || die "Cannot download ${URL}!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z ${SHA512} ]; then
|
||||||
if [ $(sha512sum ${LOCAL_CACHE}/${FILE_NAME} | awk '{print $1}') = ${SHA512} ]; 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
|
||||||
echo "Invalid checksum for ${LOCAL_CACHE}/${FILE_NAME}, downloading new copy..."
|
rm -f ${LOCAL_CACHE}/${FILE_NAME}
|
||||||
|
die "Invalid checksum for ${LOCAL_CACHE}/${FILE_NAME}, removing cached copy."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wget -nc ${URL} || die "Cannot download ${URL}!"
|
if [ ! -z ${MD5} ]; then
|
||||||
if [ $(sha512sum ${FILE_NAME} | awk '{print $1}') != ${SHA512} ]; then
|
if [ $(md5sum ${LOCAL_CACHE}/${FILE_NAME} | awk '{print $1}') = ${MD5} ]; then
|
||||||
die "Invalid checksum for ${FILE_NAME}!"
|
cp ${LOCAL_CACHE}/${FILE_NAME} .
|
||||||
|
return
|
||||||
|
else
|
||||||
|
rm -f ${LOCAL_CACHE}/${FILE_NAME}
|
||||||
|
die "Invalid checksum for ${LOCAL_CACHE}/${FILE_NAME}, removing cached copy."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if local cache is usable
|
die "No checksum available for ${FILE_NAME}!"
|
||||||
if [ -d ${LOCAL_CACHE} ] && [ -w ${LOCAL_CACHE} ]; then
|
|
||||||
cp ${FILE_NAME} ${LOCAL_CACHE}
|
|
||||||
echo "Stored ${FILE_NAME} in local cache."
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -113,17 +128,17 @@ setup_chroot() {
|
|||||||
local ROOT_FS=$1
|
local ROOT_FS=$1
|
||||||
|
|
||||||
# Import certain values from host config
|
# Import certain values from host config
|
||||||
_PORTDIR=$(. /etc/portage/make.conf && echo $PORTDIR)
|
_PORTDIR=$(. ${MAKE_CONF} && echo $PORTDIR)
|
||||||
_DISTDIR=$(. /etc/portage/make.conf && echo $DISTDIR)
|
_DISTDIR=$(. ${MAKE_CONF} && echo $DISTDIR)
|
||||||
_PKGDIR=$(. /etc/portage/make.conf && echo $PKGDIR)
|
_PKGDIR=$(. ${MAKE_CONF} && echo $PKGDIR)
|
||||||
HOST_PORTDIR=${_PORTDIR:-/usr/portage}
|
HOST_PORTDIR=${_PORTDIR:-/usr/portage}
|
||||||
HOST_DISTDIR=${_DISTDIR:-/usr/portage/distfiles}
|
HOST_DISTDIR=${_DISTDIR:-/usr/portage/distfiles}
|
||||||
HOST_PKGDIR=${_PKGDIR:-/usr/portage/packages}
|
HOST_PKGDIR=${_PKGDIR:-/usr/portage/packages}
|
||||||
|
|
||||||
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
|
||||||
if [ -d ${ROOT_FS}/${PORTDIR} ] ; then
|
if [ -d ${ROOT_FS}/${HOST_PORTDIR} ] ; then
|
||||||
mount --bind ${HOST_PORTDIR} ${ROOT_FS}/${PORTDIR} || die "Error mounting ${PORTDIR}"
|
mount --bind ${HOST_PORTDIR} ${ROOT_FS}/${HOST_PORTDIR} || die "Error mounting ${HOST_PORTDIR}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# install latest portage snapshot
|
# install latest portage snapshot
|
||||||
@ -164,7 +179,7 @@ cleanup() {
|
|||||||
umount ${ROOT_FS}/dev ${ROOT_FS}/sys ${ROOT_FS}/proc
|
umount ${ROOT_FS}/dev ${ROOT_FS}/sys ${ROOT_FS}/proc
|
||||||
|
|
||||||
if [ ${BIND_PORTAGE} != 0 ]; then
|
if [ ${BIND_PORTAGE} != 0 ]; then
|
||||||
umount ${ROOT_FS}/${HOST_PORTAGE}
|
umount ${ROOT_FS}/${HOST_PORTDIR}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +200,7 @@ OPTIONS:
|
|||||||
-c local cache (default $LOCAL_CACHE)
|
-c local cache (default $LOCAL_CACHE)
|
||||||
-b bind mount host portage tree
|
-b bind mount host portage tree
|
||||||
-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.
|
||||||
|
-m make.conf to source portage location,etc. defaults to /etc/portage/make.conf
|
||||||
-v Verbose
|
-v Verbose
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -198,6 +214,7 @@ fi
|
|||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
BIND_PORTAGE=0
|
BIND_PORTAGE=0
|
||||||
INTERACTIVE=0
|
INTERACTIVE=0
|
||||||
|
MAKE_CONF="/etc/portage/make.conf"
|
||||||
while getopts ":a:p:t:r:c:m: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;;
|
||||||
|
Loading…
Reference in New Issue
Block a user