makedist/makedist/defs.inc.sh

201 lines
4.9 KiB
Bash
Raw Normal View History

2011-05-04 02:30:35 +02:00
#
# makedist definitions include script
#
# Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
PASSED_TARGET=$1
PASSED_PLATFORM=$2
PASSED_SUBPLATFORM=$3
PASSED_ARCH=$4
PASSED_KERNEL_EXTRAVER=$5
PASSED_DISTROMATIC=$6
PASSED_RELEASE=$7
PASSED_VARIANT=$8
#RPM=rpm
#RPM2CPIO=rpm2cpio
TOPDIR=/usr/share/makedist
CONFIGFILE=/etc/makedist/config
# NOTE: LOCALSTATEDIR is hardcoded in Makefile and global/Makefile, to change it you have to modify there files too
LOCALSTATEDIR=/var/makedist
SOURCEDIR=$LOCALSTATEDIR/repositories
TARGETSDIR=$LOCALSTATEDIR/targets
# load some target specific settings
if [ "$PASSED_TARGET" ]; then
[ -r $TARGETSDIR/$PASSED_TARGET/settings.inc ] || {
echo "Error: missing target file $TARGETSDIR/$PASSED_TARGET/settings.inc; aborting."
exit 1
}
PLATFORM=$PASSED_PLATFORM \
TARGETDIR=$TARGETSDIR/$PASSED_TARGET \
. $TARGETSDIR/$PASSED_TARGET/settings.inc
fi
[ "$PASSED_RELEASE" ] && RELEASE=$PASSED_RELEASE
[ "$PASSED_VARIANT" ] && VARIANT=$PASSED_VARIANT
if [ "$PASSED_ARCH" ]; then
ARCH=$PASSED_ARCH
fi
arch=$ARCH
[ $ARCH ] || {
arch=`uname -i`
[ "$arch" = "unknown" ] && {
echo "Error: can't determine the hardware platform; aborting."
exit 1
}
}
case $arch in
i386|i486|i686) arch=i586 ; ARCH=i586 ;;
esac
if [ "$arch" = "x86_64" ]; then
arch_fallback=i586
fi
if [ "$PASSED_KERNEL_EXTRAVER" ]; then
KERNEL_EXTRAVER=$PASSED_KERNEL_EXTRAVER
fi
if [ "$PASSED_DISTROMATIC" ]; then
PASSED_DISTROMATIC=$PASSED_DISTROMATIC
fi
. $TOPDIR/VERSION
. $CONFIGFILE
[ "$PASSED_TARGET" ] && {
[ -r $CONFIGFILE-$PASSED_TARGET ] && . $CONFIGFILE-$PASSED_TARGET
[ "$PASSED_PLATFORM" ] && {
[ -r $CONFIGFILE-$PASSED_TARGET-$PASSED_PLATFORM ] &&
. $CONFIGFILE-$PASSED_TARGET-$PASSED_PLATFORM
}
}
[ "${REPOSITORY[*]}" ] || {
echo "Error: no repositories defined in configuration file; aborting."
exit 1
}
# NOTE: repository paths must end with "/"
for c in `seq 1 ${#REPOSITORY[*]}`; do
[ ${REPOSITORY[$c-1]: -1} = "/" ] ||
REPOSITORY[$c-1]=${REPOSITORY[$c-1]}/
RPMDIR[$c-1]=${REPOSITORY[$c-1]}RPMS.
SRPMDIR[$c-1]=${REPOSITORY[$c-1]}SRPMS.base/
done
UTILSDIR=$LOCALSTATEDIR/utils
GLOBALDIR=$TOPDIR/global
MEDIA_LIST="cd1 cd2 cd3 cd4 dvd1"
DEPSFILE=$LOCALSTATEDIR/distromatic/deps
BUILDDEPSFILE=$LOCALSTATEDIR/distromatic/builddeps
SOURCESFILE=$LOCALSTATEDIR/distromatic/sources
BUILDSFILE=$LOCALSTATEDIR/distromatic/builds
if [ "$BUILD_MISSING" -a "$BUILD_MISSING" != "0" -a "$arch" != "$PORT_FROM_ARCH" ]; then
DISTROMATIC_ARCHS="$PORT_FROM_ARCH $arch"
else
DISTROMATIC_ARCHS="$arch"
fi
cat > $LOCALSTATEDIR/distromatic/distromatic.conf << _EOF
#
# distromatic.conf: distromatic configuration file for use with makedist
#
# this file was autogenerated by defs.inc.sh, please do not modify this file
# but look in defs.inc.sh.
#
[defaults]
HTML_BASEDIR = $LOCALSTATEDIR/
DISTRIBUTION_NAME = ${DISTRONAME}
ARCHS = $DISTROMATIC_ARCHS
_EOF
ALTREPNUM=`expr ${#REPOSITORY[*]} - 2`
for c in `seq 0 $ALTREPNUM`; do
echo "
[makedist${c}]
2012-05-31 11:17:03 +02:00
DESCRIPTION = makedist repository ${c}
2011-05-04 02:30:35 +02:00
REPOSITORY_DIR = ${REPOSITORY[$c]}" >> $LOCALSTATEDIR/distromatic/distromatic.conf
done
cat >> $LOCALSTATEDIR/distromatic/distromatic.conf << _EOF
[distromatic]
DESCRIPTION = makedist repository
REPOSITORY_DIR = ${REPOSITORY[${#REPOSITORY[*]}-1]}
_EOF
for c in `seq 0 $ALTREPNUM`; do
echo "PARENT = makedist${c}" >> $LOCALSTATEDIR/distromatic/distromatic.conf
done
cat > $LOCALSTATEDIR/.defs.inc << _EOF
#
# .defs.inc: include file for global Makefile
#
# this file was autogenerated by defs.inc.sh, please do not modify this file
# but look in defs.inc.sh.
#
DISTRONAME=$DISTRONAME
RELEASE=$RELEASE
VARIANT=$VARIANT
LOCALSTATEDIR=$LOCALSTATEDIR
SOURCEDIR=$SOURCEDIR
TOPDIR=$TOPDIR
TARGETSDIR=$TARGETSDIR
RPMDIR=$RPMDIR
SRPMDIR=$SRPMDIR
DISTROMATIC_URL_PREFIX="$DISTROMATIC_URL_PREFIX"
DEPSFILE=$DEPSFILE
BUILDDEPSFILE=$BUILDDEPSFILE
SOURCESFILE=$SOURCESFILE
BUILDSFILE=$BUILDSFILE
UTILSDIR=$UTILSDIR
GLOBALDIR=$GLOBALDIR
MEDIA_LIST="$MEDIA_LIST"
makedist_version=$makedist_version
MAKEDIST_TARGET=$PASSED_TARGET
arch=$arch
arch_fallback=$arch_fallback
ARCH=$arch
PORT_FROM_ARCH=$PORT_FROM_ARCH
PORT_DEST_REPOSITORY=$PORT_DEST_REPOSITORY
PORT_AUTODIST_USER=$PORT_AUTODIST_USER
KERNEL_EXTRAVER=$KERNEL_EXTRAVER
PASSED_DISTROMATIC=$PASSED_DISTROMATIC
PASSED_RELEASE=$PASSED_RELEASE
PASSED_VARIANT=$PASSED_VARIANT
RPM_GPG_KEY=$RPM_GPG_KEY
_EOF
for c in `seq 1 ${#REPOSITORY[*]}`; do
echo "\
REPOSITORY[$c-1]=${REPOSITORY[$c-1]}
RPMDIR[$c-1]=${RPMDIR[$c-1]}
SRPMDIR[$c-1]=${SRPMDIR[$c-1]}
" >> $LOCALSTATEDIR/.defs.inc
done
> $LOCALSTATEDIR/.Makefile.inc
[ -e ${ADDITIONAL_DEFS_FILE} ] && {
. ${ADDITIONAL_DEFS_FILE}
cat ${ADDITIONAL_DEFS_FILE} | \
while read line; do
if [[ "$line" =~ ([A-Z0-9_]*)= ]]; then
echo "${BASH_REMATCH[1]}: ${!BASH_REMATCH[1]}" >> $LOCALSTATEDIR/.Makefile.inc
fi
done
}