# ==============================================================================
# portsreinstall library script
# - Parsing of configuration files -
-# Copyright (C) 2013 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
+# Copyright (C) 2013-2014 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
# This software is distributed under the 2-Clause BSD License.
# ==============================================================================
{
PORTS_MOVED_DB=${PORTSDIR}/MOVED
PORTS_INDEX_DB=${PORTSDIR}/INDEX-`uname -r | cut -d . -f 1`
+ if [ ! -e "${PORTS_INDEX_DB}" ]
+ then
+ message_echo "INFO: The ports index for the current OS version is not found, so fetching it now."
+ if ! make -C "${PORTSDIR}" fetchindex || [ ! -e "${PORTS_INDEX_DB}" ]
+ then
+ message_echo "WARNING: Failed to fetch the ports index, so trying to build it locally." >&2
+ make -C "${PORTSDIR}" index
+ fi
+ fi
}
# ============= Set up environment variables =============
conf_setup_envs ()
{
local tmp_work
-# LOCALBASE=${LOCALBASE:-/usr/local}
-# PORT_DBDIR=${PORT_DBDIR:-/var/db/ports}
-# LINUXBASE=${LINUXBASE:-/compat/linux}
-# DISTDIR=${DISTDIR:-${PORTSDIR}/distfiles}
-# PACKAGES=${PACKAGES:-${PORTSDIR}/packages}
-# PKGREPOSITORYSUBDIR=${PKGREPOSITORYSUBDIR:-All}
-# PKGREPOSITORY=${PKG_PATH:-${PKGREPOSITORY:-${PACKAGES}/${PKGREPOSITORYSUBDIR}}}
- tmp_work=${TMPDIR}/pkgsys_def_pkgtools:work
+ tmp_work=${TMPDIR}/conf_setup_envs:work
rm -rf "$tmp_work"
mkdir "$tmp_work"
- PORTSDIR=${PORTSDIR:-`make -C "$tmp_work" -f /etc/make.conf -V PORTSDIR`}
+ PORTSDIR=${PORTSDIR:-`[ -e /etc/make.conf ] && make -C "$tmp_work" -f /etc/make.conf -V PORTSDIR 2> /dev/null`} || :
PORTSDIR=${PORTSDIR:-/usr/ports}
+ pkgsys_chk_sys
for var in LOCALBASE PORT_DBDIR LINUXBASE DISTDIR PACKAGES PKGREPOSITORYSUBDIR PKGREPOSITORY
do
- val=`make -C "$tmp_work" -f "${PORTSDIR}/Mk/bsd.port.mk" -V $var`
+ val=`pkgsys_sysvar $var`
eval $var=\$val
done
PKGREPOSITORY=${PKG_PATH:-${PKGREPOSITORY}}
[ -n "$portupgrade_pkg" ] || portupgrade_pkg=`pkg_info_qO ports-mgmt/portupgrade-devel`
[ `expr "$portupgrade_pkg" : '^portupgrade-devel-'` -eq 0 ] \
|| message_echo "WARNING: Combination with portupgrade-devel-* has not tested." >&2
-# istart=`grep -m 1 -n -e '^def init_global$' "${PORTUPGRADE}" | cut -d : -f 1` || :
-# [ -n "$istart" ] || { echo "ERROR: The current installed version of portupgrade is unsupported." >&2; }
-# sed 1,$(($istart-1))d "${PORTUPGRADE}" > $tmp_script_crop1
-# iend=`grep -m 1 -n -e '^end$' "$tmp_script_crop1" | cut -d : -f 1`
-# sed -n 1,${iend}p "$tmp_script_crop1" > $tmp_script_crop2
sed -n '/^def init_global$/,/^end$/p' "$PORTUPGRADE" > $tmp_script_crop
[ `wc -l < $tmp_script_crop` -gt 0 ] || \
{ message_echo "ERROR: The current installed version of portupgrade is unsupported." >&2; }