summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-x[-rw-r--r--]scripts/mkstages/create_forcestage3.sh56
1 files changed, 43 insertions, 13 deletions
diff --git a/scripts/mkstages/create_forcestage3.sh b/scripts/mkstages/create_forcestage3.sh
index 516f95b..c34631e 100644..100755
--- a/scripts/mkstages/create_forcestage3.sh
+++ b/scripts/mkstages/create_forcestage3.sh
@@ -1,22 +1,34 @@
#!/bin/bash
set -eu
-TARGETVER="${TARGETVER:-10.1}"
+TARGETVER="${TARGETVER:-11.1}"
TARGETARCH="${TARGETARCH:-amd64}"
OLDSTAGE3="${OLDSTAGE3:-http://distfiles.gentoo.org/experimental/bsd/freebsd/stages/amd64-fbsd-9.1/stage3-amd64-freebsd-9.1.tar.bz2}"
WORKDIR="/${TARGETVER}-forcestage3/${TARGETARCH}"
PORTDIR="${PORTDIR:-/usr/portage}"
TMPFS=${TMPFS:-0}
CLANG=${CLANG:-0}
+SET_MAKEOPTS=${SET_MAKEOPTS:-1}
+# DISTDIR will be set automatically if your environment have the emerge command.
+# This setting exists for vanilla FreeBSD.
+DISTDIR="${DISTDIR:-/usr/portage/distfiles}"
+
[[ ${CLANG} -ne 0 ]] && WORKDIR="${WORKDIR}_clang"
prepare(){
- local distdir="$(emerge --info | grep DISTDIR | sed s:DISTDIR=::g | sed 's:"::g')"
+ local distdir
+
+ if type -P emerge &> /dev/null ; then
+ distdir="$(emerge --info | grep DISTDIR | sed s:DISTDIR=::g | sed 's:"::g')"
+ else
+ distdir="${DISTDIR}"
+ fi
+
if [[ ! -d "${WORKDIR}" ]]; then
mkdir -p "${WORKDIR}"
else
- echo "${WORKDIR} exists."
- echo "Please remove the following steps."
+ echo "Error: ${WORKDIR} exists."
+ echo "Please remove the following steps:"
echo ""
echo "kill -9 $(ps auxw | grep ebuild-helpers/ecompressdir | grep -v grep | awk '{ print $2 }' | xargs)"
echo "umount $(mount | grep ${WORKDIR} | awk '{print $3}' | xargs)"
@@ -27,10 +39,11 @@ prepare(){
if [[ "${OLDSTAGE3}" =~ ^http ]]; then
if [[ ! -e /tmp/$(basename ${OLDSTAGE3}) ]]; then
- wget -P /tmp "${OLDSTAGE3}"
+ cd /tmp
+ fetch "${OLDSTAGE3}"
fi
else
- cp "${OLDSTAGE3}" /tmp
+ cp -a "${OLDSTAGE3}" /tmp
fi
tar xjpf /tmp/$(basename ${OLDSTAGE3}) -C "${WORKDIR}"
@@ -40,6 +53,7 @@ prepare(){
mount -t devfs devfs "${WORKDIR}"/dev
mount -t nullfs "${PORTDIR}" "${WORKDIR}"/usr/portage
+
if [[ ! "${distdir}" =~ ${PORTDIR}.* ]]; then
echo "mount DISTDIR"
if [[ ! -e "${WORKDIR}"/usr/portage/distfiles ]]; then
@@ -51,8 +65,10 @@ prepare(){
echo "mount TMPFS"
mount -t tmpfs tmpfs "${WORKDIR}"/var/tmp/portage
fi
- wget -P "${WORKDIR}" https://gitweb.gentoo.org/proj/gentoo-bsd.git/plain/scripts/automatic_updater.sh
- cp /etc/resolv.conf "${WORKDIR}"/etc
+
+ cd "${WORKDIR}"
+ fetch https://gitweb.gentoo.org/proj/gentoo-bsd.git/plain/scripts/automatic_updater.sh
+ cp -a /etc/resolv.conf "${WORKDIR}"/etc
}
chroot_update(){
@@ -62,15 +78,24 @@ chroot_update(){
local makeconf="${WORKDIR}"/etc/portage/make.conf
fi
- echo "MAKEOPTS=\"-j$(sysctl hw.ncpu | awk '{ print $2 + 1 }')"\" >> "${makeconf}"
+ case ${SET_MAKEOPTS} in
+ [1-9]|[1-9][0-9])
+ echo "MAKEOPTS=\"-j${SET_MAKEOPTS}\"" >> "${makeconf}"
+ ;;
+ *) exit 1 ;;
+ esac
+
echo 'USE="${USE} -fortran -build-kernel"' >> "${makeconf}"
export EMERGE_DEFAULT_OPTS="-q"
+ mkdir -p "${WORKDIR}"/etc/portage/patches/sys-apps
+ cp -a /etc/portage/patches/sys-apps/portage "${WORKDIR}"/etc/portage/patches/sys-apps
chroot "${WORKDIR}" bash /automatic_updater.sh ${TARGETVER} kernel
chroot "${WORKDIR}" bash /automatic_updater.sh ${TARGETVER} freebsd_userland
if [[ -e "${WORKDIR}"/usr/bin/git ]]; then
chroot "${WORKDIR}" emerge -C dev-vcs/git
fi
+
REMOVEPERL=1 chroot "${WORKDIR}" bash /automatic_updater.sh ${TARGETVER} world
unset EMERGE_DEFAULT_OPTS
}
@@ -89,7 +114,13 @@ check_ecompressdir() {
}
cleanup(){
- local distdir="$(emerge --info | grep DISTDIR | sed s:DISTDIR=::g | sed 's:"::g')"
+ local distdir
+
+ if type -P emerge &> /dev/null ; then
+ distdir="$(emerge --info | grep DISTDIR | sed s:DISTDIR=::g | sed 's:"::g')"
+ else
+ distdir="${DISTDIR}"
+ fi
check_ecompressdir
if [[ ! "${distdir}" =~ ${PORTDIR}.* ]]; then
@@ -116,10 +147,10 @@ create_stage3(){
tarfile="stage3-${TARGETARCH}-fbsd-${TARGETVER}-forcestage3"
fi
- echo "Compress with tar."
+ echo "Compressing with tar."
LANG="en_US.UTF-8" tar cjpf /var/tmp/catalyst/builds/default/"${tarfile}".tar.bz2 .
- echo "Complete !"
+ echo "Complete!"
echo "Set FORCESTAGE3=${tarfile}"
}
@@ -127,4 +158,3 @@ prepare
chroot_update
cleanup
create_stage3
-