#!/bin/sh #- # Copyright (c) 2002-2004 FreeBSD GNOME Team # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $Id: marcusmerge.sh.in,v 1.39 2004/04/03 18:11:03 marcus Exp $ # # These variables are overrideable in /usr/local/etc/${SCRIPTNAME}.cfg. SRCDIR="" # The path to the MarcusCom ports without the trailing # module name (i.e. without the trailing /ports). DESTDIR="/usr/ports" # The path to the official ports collection. VERBOSE="no" # If you want verbose output. SUPFILE="" # The path your ports-supfile (default: auto). TARBALL="no" # Set to yes to download a tarball instead of using # CVS. MODULE="ports" # CVS module to checkout. # You do not have to change anything beyond this line. PKGVERSION_CMD="/usr/sbin/pkg_version" PKGVERSION_ARGS="-l \<" CVSUP_CMD="/usr/local/bin/cvsup -g" FETCH_CMD="/usr/bin/fetch" FETCH_ARGS="-4 -q" update_main="no" pkgversion="no" updating="no" # End list of overrideable variables SCRIPTNAME=`basename $0` if [ -f /usr/local/etc/${SCRIPTNAME}.cfg ]; then . /usr/local/etc/${SCRIPTNAME}.cfg fi SCRIPTNAME=`basename $0` CVSROOT=":pserver:anonymous@creme-brulee.marcuscom.com:/space/cvs/marcuscom-cvs" TARBALL_URL="http://www.marcuscom.com:8080/downloads/" RMPORTS="RMPORTS" MCVER_FILE="MCVER" MCVER="2004031401" get_tmpfile() { template=$1 tmpfile="" if [ -n "${MC_TMPDIR}" -a -d "${MC_TMPDIR}" ]; then tmpfile="${MC_TMPDIR}/${template}.XXXXXX" elif [ -n "${TMPDIR}" -a -d "${TMPDIR}" ]; then tmpfile="${TMPDIR}/${template}.XXXXXX" elif [ -d "/var/tmp" ]; then tmpfile="/var/tmp/${template}.XXXXXX" elif [ -d "/tmp" ]; then tmpfile="/tmp/${template}.XXXXXX" elif [ -d "/usr/tmp" ]; then tmpfile="/usr/tmp/${template}.XXXXXX" else return 1 fi tmpfile=`mktemp -q ${tmpfile}` echo ${tmpfile} return 0 } download_tarball() { tmpfile=`get_tmpfile mctmp` if [ $? != 0 ]; then printf "Unable to create a temporary file for the downloaded tarball.\nPlease set your MC_TMPDIR environment variable to a suitable tmporary directory,\nand run this script again.\n" exit 1 fi echo "===> Downloading the tarball for the ${MODULE} module." ${FETCH_CMD} ${FETCH_ARGS} -o ${tmpfile} "${TARBALL_URL}/mc_${MODULE}.tar.bz2" if [ $? != 0 ]; then printf "Failed to download mc_${MODULE}.tar.bz2 from ${TARBALL_URL}.\n\n" exit 1 fi echo "===> Download done." echo "===> Extracting ${tmpfile} to ${SRCDIR}." mkdir -p ${SRCDIR} tar -C ${SRCDIR} -xvjf ${tmpfile} echo "===> Extraction done." rm -f ${tmpfile} } args=`getopt apltuvs:d:c:m: $*` if [ $? != 0 ]; then echo "usage: ${SCRIPTNAME} [-s ] [-d ] [-c ] [-m ] [-t] [-u] [-v] [-l] [-p] [-a]" exit 1 fi set -- $args for i; do case "$i" in -s) SRCDIR="$2"; shift; shift;; -d) DESTDIR="$2"; shift; shift;; -c) CVSROOT="$2"; shift; shift;; -m) MODULE="$2"; shift; shift;; -v) VERBOSE="yes"; shift;; -t) TARBALL="yes"; shift;; -u) updating="yes"; shift;; -l) pkgversion="yes"; shift;; -p) update_main="yes"; shift;; -a) updating="yes"; pkgversion="yes"; update_main="yes"; shift;; --) shift; break;; esac done if [ -z "${SRCDIR}" ]; then echo "You did not specify a SRCDIR; aborting..." exit 1 fi if [ -z "${MODULE}" ]; then echo "You did not specify a MODULE; aborting..." exit 1 fi if [ ${SRCDIR} = ${DESTDIR} -o "${SRCDIR}/${MODULE}" = ${DESTDIR} ]; then printf "Your SRCDIR is set to the same path as your DESTDIR.\nPlease set it to a path where we can store the MarcusCom ports.\n\n" exit 1 fi # Try to get our cvsup supfile if we will be updating the main ports tree. if [ ${update_main} = "yes" ]; then if [ -z "${SUPFILE}" ]; then SUPFILE=`cd ${DESTDIR} && make -V PORTSSUPFILE` fi if [ -z "${SUPFILE}" ]; then printf "Update of main ports tree requested but you forgot\nto set SUPFILE in this script; aborting...\n\n" exit 1 fi if [ ! -f ${SUPFILE} ]; then printf "Update of main ports tree requestet but I could not\nfind SUPFILE: ${SUPFILE}; aborting...\n\n" exit 1 fi fi first_time=0 # If the SRCDIR doesn't exist, we need to download the repo. Currently, we # can do this via CVS or from a tarball generated periodically. if [ ! -d ${SRCDIR} -o ! -d ${SRCDIR}/${MODULE} ]; then first_time=1 if [ "${TARBALL}" = "yes" ]; then download_tarball else printf "First we have to checkout the ${MODULE} module from\nhttp://www.marcuscom.com:8080/cgi-bin/cvsweb.cgi\nPlease type 'anoncvs' as your password.\n\n" cvs -d${CVSROOT} login echo "===> Checking out the ${MODULE} module." mkdir -p ${SRCDIR} cd ${SRCDIR} cvs -z3 -d${CVSROOT} checkout ${MODULE} if [ $? != 0 ]; then printf "Failed to checkout the MarcusCom ports tree.\n\n" exit 1 fi echo "===> Checkout done." fi fi # Update the MarcusCom repo if so requested. Don't update if we just checked # out (or downloaded) the repo for this first time. if [ ${updating} = "yes" -a ${first_time} = 0 ]; then echo "===> Updating the marcus ports tree" if [ "${TARBALL}" = "yes" ]; then rm -rf "${SRCDIR}/${MODULE}" download_tarball else cd "${SRCDIR}/${MODULE}" cvs -z3 update -Pd -A if [ $? != 0 ]; then printf "Failed to update the MarcusCom ports tree.\n\n" exit 1 fi fi echo "===> Updating done." fi # Determine if this repo needs a newer marcusmerge. mcver="0" if [ -f "${SRCDIR}/${MODULE}/${MCVER_FILE}" ]; then mcver=`cat "${SRCDIR}/${MODULE}/${MCVER_FILE}"` fi if [ "${mcver}" != "${MCVER}" ]; then printf "This repository requires a newer version of marcusmerge. Please go\nto http://www.marcuscom.com:8080/cgi-bin/cvsweb.cgi to download the latest version.\n\n" exit 1 fi # Update the main ports tree if so requested. if [ ${update_main} = "yes" ]; then echo "===> Updating the main ports tree" if [ ${VERBOSE} = "yes" ]; then ${CVSUP_CMD} ${SUPFILE} else ${CVSUP_CMD} ${SUPFILE} -L0 fi if [ $? != 0 ]; then printf "Failed to cvsup the ports tree.\n\n" exit 1 fi echo "===> Updating done." fi # Handle ports that may have been moved or deleted in the MarcusCom repo. if [ -f "${SRCDIR}/${MODULE}/${RMPORTS}" ]; then echo "===> Removing obsolete ports from main tree" for i in `cat ${SRCDIR}/${MODULE}/${RMPORTS} | cut -d '|' -f1`; do if [ "${VERBOSE}" = "yes" ]; then echo " Removing obsolete port ${i}" fi rm -rf ${DESTDIR}/${i} done if [ "${VERBOSE}" = "yes" ]; then echo "Adding removed ports to MOVED" fi date=`date "+%Y-%m-%d"` cat ${SRCDIR}/${MODULE}/${RMPORTS} | sed -e "s|%%DATE%%|${date}|g" \ >> ${DESTDIR}/MOVED echo "===> done." fi echo "===> Merging files to the ports directory" echo "${SRCDIR}/${MODULE} --> ${DESTDIR}" if [ -d ${SRCDIR}/${MODULE}/Mk ]; then if [ "${VERBOSE}" = "yes" ]; then echo "Merging Mk files" fi if [ ! -d ${DESTDIR}/Mk ]; then if [ "${VERBOSE}" = "yes" ]; then echo "Creating nonexistent destination category directory: Mk" fi mkdir -p ${DESTDIR}/Mk fi for mk in `ls -1 ${SRCDIR}/${MODULE}/Mk/*.mk`; do cp ${mk} ${DESTDIR}/Mk done fi for category in `ls -1 ${SRCDIR}/${MODULE}`; do if [ ${category} = "CVS" ]; then continue fi for port in `ls -1 ${SRCDIR}/${MODULE}/${category}`; do if [ ${port} = "CVS" ]; then continue fi if [ ! -f ${SRCDIR}/${MODULE}/${category}/${port}/Makefile ]; then continue fi if [ ! -d ${DESTDIR}/${category} ]; then if [ "${VERBOSE}" = "yes" ]; then echo "Creating nonexistent destination category directory: ${category}" fi mkdir -p ${DESTDIR}/${category} fi if [ -d ${DESTDIR}/${category}/${port} ]; then if [ "${VERBOSE}" = "yes" ]; then echo "Removing old directory for: ${category}/${port}" fi rm -rf ${DESTDIR}/${category}/${port} fi cd ${SRCDIR}/${MODULE}/${category} tar --exclude *CVS* -cf - ${port} | \ tar -xf - -C ${DESTDIR}/${category} done done echo "===> Merging done." echo "" if [ "${pkgversion}" = "yes" ]; then echo "===> Listing outdated ports..." ${PKGVERSION_CMD} ${PKGVERSION_ARGS} echo "===> Listing done." fi echo "" echo "If you are upgrading from the stable version of GNOME to the development version, you should now run \"gnome_upgrade.sh\" available from http://www.marcuscom.com/downloads/gnome_upgrade.sh. If this is simply an update of the currently installed development version of GNOME, then run \"portupgrade -r pkgconfig\"." | /usr/bin/fmt 75 79