Various improvements and fixes to Gentoo build script
This commit is contained in:
parent
d419b7c832
commit
ffdf5b80a1
@ -28,7 +28,7 @@ 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}\s*${FILE_NAME}$" | awk '{print $1}')
|
MD5=$(curl -s -S ${DIGEST} | grep -o -E -e "^[0-9a-f]{32} *${FILE_NAME}$" | awk '{print $1}')
|
||||||
|
|
||||||
if [ -z ${MD5} ]; then
|
if [ -z ${MD5} ]; then
|
||||||
die "Unable to get checksum for ${FILE_NAME}, abort"
|
die "Unable to get checksum for ${FILE_NAME}, abort"
|
||||||
@ -102,13 +102,12 @@ bootstrap() {
|
|||||||
cd ${ROOT_FS}
|
cd ${ROOT_FS}
|
||||||
if [ -d "usr" ] ; then
|
if [ -d "usr" ] ; then
|
||||||
echo "There seems to be already files in ${ROOT_FS} !"
|
echo "There seems to be already files in ${ROOT_FS} !"
|
||||||
echo "Press Ctrl+c to abort..."
|
echo "Press <Ctrl+c> to abort, or <Return> to proceed with extracting stage3 ..."
|
||||||
read
|
read
|
||||||
fi
|
fi
|
||||||
fetch_file "${STAGE_TARBALL}" "${STAGE_TARBALL}.DIGESTS"
|
fetch_file "${STAGE_TARBALL}" "${STAGE_TARBALL}.DIGESTS"
|
||||||
tar jxpf $(basename ${STAGE_TARBALL}) || die "Extracting stage file failed"
|
tar jxpf $(basename ${STAGE_TARBALL}) || die "Extracting stage file failed"
|
||||||
rm -f $(basename ${STAGE_TARBALL})
|
rm -f $(basename ${STAGE_TARBALL})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,12 +118,12 @@ 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
|
mkdir -p usr/portage
|
||||||
mount --bind ${PORTDIR} ${ROOT_FS}/usr/portage || die "Error mounting ${PORTDIR}"
|
mount --bind ${PORTDIR} ${ROOT_FS}/usr/portage || die "Error mounting ${PORTDIR}"
|
||||||
else
|
else
|
||||||
# install latest portage snapshot
|
# install latest portage snapshot
|
||||||
if [ ! -d "usr/portage" ] ; then
|
if [ ! -d "usr/portage" ] ; then
|
||||||
fetch_file "${PORTAGE_SNAPSHOT}" "${PORTAGE_SNAPSHOT}.md5sum"
|
fetch_file "${PORTAGE_SNAPSHOT}" "${PORTAGE_SNAPSHOT}.md5sum"
|
||||||
tar jxf portage-latest.tar.bz2 -C "${ROOT_FS}/usr" || die "Extracting portage snapshot failed"
|
tar jxf $(basename ${PORTAGE_SNAPSHOT}) -C "${ROOT_FS}/usr" || die "Extracting portage snapshot failed"
|
||||||
rm -f portage-latest.tar.bz2
|
rm -f portage-latest.tar.bz2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -143,8 +142,14 @@ setup_chroot() {
|
|||||||
# make.conf
|
# make.conf
|
||||||
# etc/portage/*
|
# etc/portage/*
|
||||||
|
|
||||||
echo "Done :D ... take a look around, any key to end"
|
if [ ${INTERACTIVE} = 1 ]; then
|
||||||
read
|
echo "Done. Entering chroot environment..."
|
||||||
|
chroot ${ROOT_FS} /bin/bash
|
||||||
|
else
|
||||||
|
echo "Done !"
|
||||||
|
echo "Press <Return> to tear down the chroot environment once you are done."
|
||||||
|
read
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,6 +179,7 @@ OPTIONS:
|
|||||||
-r chroot location, default /mnt/gentoo
|
-r chroot location, default /mnt/gentoo
|
||||||
-c local cache, default /var/tmp
|
-c local cache, default /var/tmp
|
||||||
-b bind mount host portage tree instead of installing portage inside chroot
|
-b bind mount host portage tree instead of installing portage inside chroot
|
||||||
|
-i interactive, setting up chroot and enter it, skip extracting stage3, portage, etc.
|
||||||
-v Verbose
|
-v Verbose
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -186,7 +192,8 @@ fi
|
|||||||
|
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
BIND_PORTAGE=0
|
BIND_PORTAGE=0
|
||||||
while getopts ":a:p:t:r:c:bvh" OPTIONS; do
|
INTERACTIVE=0
|
||||||
|
while getopts ":a:p:t:r:c:bvhi" OPTIONS; do
|
||||||
case $OPTIONS in
|
case $OPTIONS in
|
||||||
a ) ARCH=$OPTARG;;
|
a ) ARCH=$OPTARG;;
|
||||||
p ) PROFILE=$OPTARG;;
|
p ) PROFILE=$OPTARG;;
|
||||||
@ -195,6 +202,7 @@ while getopts ":a:p:t:r:c:bvh" OPTIONS; do
|
|||||||
b ) BIND_PORTAGE=1;;
|
b ) BIND_PORTAGE=1;;
|
||||||
r ) IMAGE_ROOT=$OPTARG;;
|
r ) IMAGE_ROOT=$OPTARG;;
|
||||||
c ) LOCAL_CACHE=$OPTARG;;
|
c ) LOCAL_CACHE=$OPTARG;;
|
||||||
|
i ) INTERACTIVE=1;;
|
||||||
? )
|
? )
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
@ -210,7 +218,9 @@ if [ ${VERBOSE} = 1 ]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bootstrap ${IMAGE_ROOT} ${PROFILE} ${ARCH}
|
if [ ${INTERACTIVE} = 0 ]; then
|
||||||
|
bootstrap ${IMAGE_ROOT} ${PROFILE} ${ARCH}
|
||||||
|
fi
|
||||||
|
|
||||||
# From here make sure we don't leave stuff around
|
# From here make sure we don't leave stuff around
|
||||||
trap "cleanup ${IMAGE_ROOT}" INT TERM EXIT
|
trap "cleanup ${IMAGE_ROOT}" INT TERM EXIT
|
||||||
|
Loading…
Reference in New Issue
Block a user