# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
-# $Id: build.functions,v 1.10.2.1 2007/08/30 16:39:07 mef Exp $
+# $Id$
#
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# Be verbose
set -x
-# Make a basic chroot at the specified location given the specified
-# configuration.
-make_chroot() {
- root=$1
- config=$2
-
- # Get group list
- groups=
- while read group ; do
- groups="$groups -g \"$group\""
- done < <(./plc-config --groups $config)
-
- # Get package list
- packages=
- while read package ; do
- packages="$packages -p \"$package\""
- done < <(./plc-config --packages $config)
-
- pl_setup_chroot $root $packages $groups
+# this is fragile, as the actual layout may vary from one mirror to the other
+# however this should be in line with the layouts obtained
+# when running build/vbuild-fedora-mirror.sh
+
+function yum_conf_fedora_core () {
+ BUILD_HOST=$1; shift
+ cat <<EOF
+[base]
+name=${pl_DISTRO_NAME} - base
+baseurl=http://${BUILD_HOST}/fedora/linux/core/${pl_DISTRO_RELEASE}/${pl_DISTRO_ARCH}/os/
+
+
+[updates]
+name=${pl_DISTRO_NAME} - updates
+baseurl=http://${BUILD_HOST}/fedora/linux/core/updates/${pl_DISTRO_RELEASE}/${pl_DISTRO_ARCH}/
+
+
+[extras]
+name=${pl_DISTRO_NAME} - extras
+baseurl=http://${BUILD_HOST}/fedora/linux/extras/${pl_DISTRO_RELEASE}/${pl_DISTRO_ARCH}/
+EXTRAS
+EOF
}
-# Move specified directories out of the chroot and into a "data"
-# directory that will be bind mounted on /data inside the chroot.
-move_datadirs() {
- root=$1
- data=$2
- shift 2
- pl_move_dirs $root $data /data "$@"
+function yum_conf_fedora () {
+ BUILD_HOST=$1; shift
+ cat <<EOF
+[base]
+name=${pl_DISTRO_NAME} - base
+baseurl=http://${BUILD_HOST}/fedora/linux/releases/${pl_DISTRO_RELEASE}/Everything/${pl_DISTRO_ARCH}/os/
+
+[updates]
+name=${pl_DISTRO_NAME} - base
+baseurl=http://${BUILD_HOST}/fedora/linux/updates/${pl_DISTRO_RELEASE}/${pl_DISTRO_ARCH}/
+EOF
}
-# Make loopback filesystem from specified location
-make_image() {
- root=$1
- image=$2
- pl_make_image $root $image 100000000
+function yum_conf_to_build_host () {
+ BUILD_HOST=$(hostname)
+
+ cat <<EOF
+[main]
+cachedir=/var/cache/yum
+debuglevel=2
+logfile=/var/log/yum.log
+pkgpolicy=newest
+distroverpkg=redhat-release
+tolerant=1
+exactarch=1
+retries=10
+obsoletes=1
+gpgcheck=0
+# Prevent yum-2.4 from loading additional repository definitions
+# (e.g., from /etc/yum.repos.d/)
+reposdir=/dev/null
+
+EOF
+
+ case "$pl_DISTRO" in
+ Fedora)
+ if [ "${pl_DISTRO_RELEASE}" -le 6 ] ; then
+ yum_conf_fedora_core $BUILD_HOST
+ else
+ yum_conf_fedora $BUILD_HOST
+ fi
+ ;;
+ *)
+ echo "$0: no support for tuning yum.conf on this distribution $pl_DISTRO"
+ exit 1
+ ;;
+ esac
}
+
+# quick and dirty - might break anytime if docbook html output changes
+function docbook_html_to_drupal () {
+ title=$1; shift
+ html=$1; shift
+ php=$1; shift
+
+ mkdir -p $(dirname $php)
+ if [ ! -f $html ] ; then
+ cat << __header_no_doc__ > $php
+<?php
+require_once 'plc_drupal.php';
+drupal_set_title("$title - unavailable");
+?>
+<p class='plc-warning'> Build-time error - could not locate documentation $html</p>
+__header_no_doc__
+ else
+ # insert header, makes sure we have a trailing eol
+ (cat << __header_doc__ ; cat $html ) > $php
+<?php
+require_once 'plc_drupal.php';
+drupal_set_title("$title");
+?>
+__header_doc__
+ # ignore ed return status
+ set +e
+ # cuts off around the <body> </body>
+ # preserves the 4 first lines that we just added as a header
+ ed -s $php << __ed_script__
+/BODY/
+/>/
+s,><,<,
+5,-d
+$
+?/BODY?
+s,><.*,>,
++
+;d
+w
+q
+__ed_script__
+ set -e
+ fi
+}