[27961] trunk/base/portmgr

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 16 09:34:43 PDT 2007


Revision: 27961
          http://trac.macosforge.org/projects/macports/changeset/27961
Author:   jmpp at macports.org
Date:     2007-08-16 09:34:43 -0700 (Thu, 16 Aug 2007)

Log Message:
-----------
Reorder the portmgr directory a bit. I want to revive our olds page so I want
to give the PortIndex2MySQL.tcl script a front seat status again, therefore
pull it out of the packaging dir unfortunate coffin. While at it, rename the
IndexRegen.sh script to match its PortIndex regen nature (consistency++, as
always!)

Added Paths:
-----------
    trunk/base/portmgr/Makefile
    trunk/base/portmgr/PortIndex2MySQL.tcl
    trunk/base/portmgr/PortIndexRegen.sh

Removed Paths:
-------------
    trunk/base/portmgr/IndexRegen.sh
    trunk/base/portmgr/packaging/Makefile
    trunk/base/portmgr/packaging/PortIndex2MySQL.tcl

Property Changed:
----------------
    trunk/base/portmgr/GuideRegen.sh


Property changes on: trunk/base/portmgr/GuideRegen.sh
___________________________________________________________________
Name: svn:mime-type
   + text/x-sh

Deleted: trunk/base/portmgr/IndexRegen.sh
===================================================================
--- trunk/base/portmgr/IndexRegen.sh	2007-08-16 15:05:19 UTC (rev 27960)
+++ trunk/base/portmgr/IndexRegen.sh	2007-08-16 16:34:43 UTC (rev 27961)
@@ -1,135 +0,0 @@
-#!/bin/bash
-
-####
-# PortIndex regen automation script.
-# Created by Juan Manuel Palacios,
-# e-mail: jmpp at macports.org
-# Updated by Paul Guyot, <pguyot at kallisys.net>
-# Updated for svn by Daniel J. Luke <dluke at geeklair.net>
-# $Id$
-####
-
-# Configuration
-LOCKFILE=/tmp/.mp_svn_index_regen.lock
-# ROOT directory, where everything is. This needs to exist!
-ROOT=/Users/mp-user/mp_svn_index_regen
-# MP user.
-MP_USER=mp-user
-# MP group.
-MP_GROUP=mp-user
-# e-mail address to spam in case of failure.
-SPAM_LOVERS=macports-dev at lists.macosforge.org,dluke at geeklair.net
-
-# Other settings (probably don't need to be changed).
-SVN_CONFIG_DIR=${ROOT}/svnconfig
-REPO_BASE=http://svn.macports.org/repository/macports
-RELEASE_URL_FILE="config/RELEASE_URL"
-SVN="/opt/local/bin/svn -q --non-interactive --config-dir $SVN_CONFIG_DIR"
-# Where to checkout the source code. This needs to exist!
-SRCTREE=${ROOT}/source
-# Where MP will install its world. This gets created.
-PREFIX=${ROOT}/opt/local
-# Where MP installs macports1.0. This gets created.
-TCLPKG=${PREFIX}/lib/tcl
-# Path.
-PATH=${PREFIX}/bin:/bin:/usr/bin:/usr/sbin:/opt/local/bin
-# Log for the e-mail in case of failure.
-FAILURE_LOG=${ROOT}/failure.log
-# Commit message.
-COMMIT_MSG=${ROOT}/commit.msg
-# The date.
-DATE=$(date +'%A %Y-%m-%d at %H:%M:%S')
-
-
-# Function to spam people in charge if something goes wrong during indexing.
-bail () {
-    mail -s "AutoIndex Failure on ${DATE}" $SPAM_LOVERS < $FAILURE_LOG
-    cleanup; exit 1
-}
-
-# Cleanup fuction for runtime files.
-cleanup () {
-    rm -f $COMMIT_MSG $FAILURE_LOG
-    rm -f $LOCKFILE
-}
-
-
-if [ ! -e $LOCKFILE ]; then
-    touch $LOCKFILE
-else
-    echo "Index Regen lockfile found, is another index regen running?"
-    exit 1
-fi
-
-# Checkout/update the ports tree
-if [ -d ${SRCTREE}/dports ]; then
-    $SVN update ${SRCTREE}/dports > $FAILURE_LOG 2>&1 \
-	|| { echo "Updating the ports tree from $REPO_BASE/trunk/dports failed." >> $FAILURE_LOG; bail ; }
-else
-    $SVN checkout ${REPO_BASE}/trunk/dports ${SRCTREE}/dports > $FAILURE_LOG 2>&1 \
-	|| { echo "Checking out the ports tree from $REPO_BASE/trunk/dports failed." >> $FAILURE_LOG ; bail ; }
-fi
-echo `date -u +%s` > ${ROOT}/PORTS-TIMESTAMP
-
-# Checkout/update HEAD
-TMPDIR=mp_trunk/base
-if [ -d ${ROOT}/${TMPDIR} ]; then
-    $SVN update ${ROOT}/${TMPDIR} > $FAILURE_LOG 2>&1 \
-	|| { echo "Updating the trunk from $REPO_BASE/trunk/base failed." >> $FAILURE_LOG; bail ; }
-else
-    $SVN checkout ${REPO_BASE}/trunk/base ${ROOT}/${TMPDIR} > $FAILURE_LOG 2>&1 \
-       || { echo "Checking out the trunk from $REPO_BASE/trunk/base failed." >> $FAILURE_LOG ; bail ; }
-fi
-
-# Extract the release URL from HEAD
-read RELEASE_URL < ${ROOT}/${TMPDIR}/${RELEASE_URL_FILE}
-[ -n ${RELEASE_URL} ] || { echo "no RELEASE_URL specified in svn HEAD." >> $FAILURE_LOG; bail ; }
-
-# Checkout/update the release base
-if [ -d ${SRCTREE}/base ]; then
-    $SVN switch ${RELEASE_URL} ${SRCTREE}/base > $FAILURE_LOG 2>&1 \
-	|| { echo "Updating base from ${RELEASE_URL} failed." >> $FAILURE_LOG; bail ; }
-else
-    $SVN checkout ${RELEASE_URL} ${SRCTREE}/base > $FAILURE_LOG 2>&1 \
-	|| { echo "Checking out base from ${RELEASE_URL} failed." >> $FAILURE_LOG ; bail ; }
-fi
-echo `date -u +%s` > ${ROOT}/BASE-TIMESTAMP
-
-# (re)configure.
-cd ${SRCTREE}/base/ && \
-    mkdir -p ${TCLPKG} && \
-    ./configure \
-    --prefix=${PREFIX} \
-    --with-tclpackage=${TCLPKG} \
-    --with-install-user=${MP_USER} \
-    --with-install-group=${MP_GROUP} > $FAILURE_LOG 2>&1 \
-    || { echo "./configure script failed." >> $FAILURE_LOG ; bail ; }
-
-# clean
-# (cleaning is useful because we don't want the indexing to fail because dependencies aren't properly computed).
-{ cd ${SRCTREE}/base/ && make clean > $FAILURE_LOG 2>&1 ; } \
-    || { echo "make clean failed." >> $FAILURE_LOG ; bail ; }
-
-# (re)build
-{ cd ${SRCTREE}/base/ && make > $FAILURE_LOG 2>&1 ; } \
-    || { echo "make failed." >> $FAILURE_LOG ; bail ; }
-
-# (re)install
-{ cd ${SRCTREE}/base/ && make install > $FAILURE_LOG 2>&1 ; } \
-    || { echo "make install failed." >> $FAILURE_LOG ; bail ; }
-
-# (re)index
-{ cd ${SRCTREE}/dports/ && ${PREFIX}/bin/portindex > $FAILURE_LOG 2>&1 ; } \
-    || { echo "portindex failed." >> $FAILURE_LOG ; bail ; }
-
-# Commit the new index using the last 5 lines of the log for the commit message,
-tail -n 5 $FAILURE_LOG > $COMMIT_MSG
-# plus parsing failures, if any.
-echo "" >> $COMMIT_MSG
-grep Failed $FAILURE_LOG >> $COMMIT_MSG
-{ cd ${SRCTREE}/dports/ && \
-    svn --config-dir $SVN_CONFIG_DIR commit -F $COMMIT_MSG PortIndex > $FAILURE_LOG 2>&1 ; } \
-    || { echo "SVN commit failed." >> $FAILURE_LOG ; bail ; }
-
-# At this point the index was committed successfuly, so we cleanup before we exit.
-cleanup && exit 0

Copied: trunk/base/portmgr/Makefile (from rev 27921, trunk/base/portmgr/packaging/Makefile)
===================================================================
--- trunk/base/portmgr/Makefile	                        (rev 0)
+++ trunk/base/portmgr/Makefile	2007-08-16 16:34:43 UTC (rev 27961)
@@ -0,0 +1,20 @@
+# $Id$
+
+SCRIPTS=	PortIndex2MySQL
+
+edit = sed \
+	-e 's, at TCL_PACKAGE_DIR@,$(TCL_PACKAGE_DIR),g'
+
+
+include ../../Mk/macports.autoconf.mk
+
+
+all: ${SCRIPTS}
+
+PortIndex2MySQL: PortIndex2MySQL.tcl
+	${edit} $< > $@
+
+clean:
+	rm -f ${SCRIPTS}
+
+distclean: clean

Copied: trunk/base/portmgr/PortIndex2MySQL.tcl (from rev 27921, trunk/base/portmgr/packaging/PortIndex2MySQL.tcl)
===================================================================
--- trunk/base/portmgr/PortIndex2MySQL.tcl	                        (rev 0)
+++ trunk/base/portmgr/PortIndex2MySQL.tcl	2007-08-16 16:34:43 UTC (rev 27961)
@@ -0,0 +1,250 @@
+#!/usr/bin/env tclsh
+#
+# PortIndex2MySQL.tcl
+# Kevin Van Vechten | kevin at opendarwin.org
+# 3-Oct-2002
+# Juan Manuel Palacios | jmpp at macports.org
+# 30-Jul-2007
+# $Id$
+#
+# Copyright (c) 2007 Juan Manuel Palacios, MacPorts Team.
+# Copyright (c) 2003 Apple Computer, Inc.
+# Copyright (c) 2002 Kevin Van Vechten. 
+# 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.
+# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+
+
+# Error messages reciepient.
+set SPAM_LOVERS macports-dev at lists.macosforge.org
+
+# Place holder proc for error catching and processing.
+proc bail_on_error {error_log} {
+    
+}
+
+
+# Load macports1.0 so that we can use some of its procs and the portinfo array.
+catch {source \
+	   [file join "@TCL_PACKAGE_DIR@" macports1.0 macports_fastload.tcl]}
+package require macports
+
+# Initialize MacPorts to find the sources.conf file, wherefrom we'll
+# get the PortIndex that'll feed the database.
+#more work needs to be done than just initializing and passing the
+#ui_options array to get mportinit to output verbose/debugging info;
+#I'm currently looking into this.
+array set ui_options {ports_verbose yes}
+mportinit
+
+# Call the selfupdate procedure to make sure the MacPorts installation
+# is up-to-date and with a fresh ports tree.
+macports::selfupdate
+
+
+# Procedure to catch the database password from a protected file.
+proc getpasswd {passwdfile} {
+    if {[catch {open $passwdfile r} passwdfile_fd]} {
+        ui_error "${::errorCode}: $passwdfile_fd"
+        exit 1
+    }
+    if {[gets $passwdfile_fd passwd] <= 0} {
+        ui_error "No password found in $passwdfile!"
+        exit 1
+    }
+    close $passwdfile_fd
+    return $passwd
+}
+
+# Database abstraction variables:
+set sqlfile [file join /tmp ports.sql]
+set dbcmd [macports::findBinary mysql5]
+set dbhost 127.0.0.1
+set dbname macports
+set dbuser macports
+set passwdfile [file join . password_file]
+set dbpasswd [getpasswd $passwdfile]
+set dbcmdargs "-h $dbhost -u $dbuser -p$dbpasswd $dbname"
+
+# Flat text file to which sql statements are written.
+if {[catch {open $sqlfile w+} sqlfile_fd]} {
+    ui_error "${::errorCode}: $sqlfile_fd"
+    exit 1
+}
+
+
+# SQL string escaping.
+proc sql_escape {str} {
+        regsub -all -- {'} $str {\\'} str
+        regsub -all -- {"} $str {\\"} str
+        regsub -all -- {\n} $str {\\n} str
+        return $str
+}
+
+# Initial creation of database tables: log, portfiles, categories, maintainers, dependencies, variants and platforms.
+# Do we need any other?
+puts $sqlfile_fd "DROP TABLE log"
+puts $sqlfile_fd "CREATE TABLE IF NOT EXISTS log (activity VARCHAR(255), activity_time TIMESTAMP(14))"
+puts $sqlfile_fd "INSERT INTO log VALUES ('update', NOW())"
+
+puts $sqlfile_fd "DROP TABLE portfiles"
+puts $sqlfile_fd "CREATE TABLE portfiles (name VARCHAR(255) PRIMARY KEY NOT NULL, path VARCHAR(255), version VARCHAR(255),  description TEXT)"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS categories"
+puts $sqlfile_fd "CREATE TABLE categories (portfile VARCHAR(255), category VARCHAR(255), is_primary INTEGER)"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS maintainers"
+puts $sqlfile_fd "CREATE TABLE maintainers (portfile VARCHAR(255), maintainer VARCHAR(255), is_primary INTEGER)"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS dependencies"
+puts $sqlfile_fd "CREATE TABLE dependencies (portfile VARCHAR(255), library VARCHAR(255))"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS variants"
+puts $sqlfile_fd "CREATE TABLE variants (portfile VARCHAR(255), variant VARCHAR(255))"
+
+puts $sqlfile_fd "DROP TABLE IF EXISTS platforms"
+puts $sqlfile_fd "CREATE TABLE platforms (portfile VARCHAR(255), platform VARCHAR(255))"
+
+
+# Load every port in the index through a search matching everything.
+if {[catch {set ports [mportsearch ".+"]} errstr]} {
+	ui_error "port search failed: $errstr"
+	exit 1
+}
+
+# Iterate over each matching port, extracting its information from the
+# portinfo array.
+foreach {name array} $ports {
+
+	array unset portinfo
+	array set portinfo $array
+
+	set portname [sql_escape $portinfo(name)]
+	if {[info exists portinfo(version)]} {
+		set portversion [sql_escape $portinfo(version)]
+	} else {
+		set portversion ""
+	}
+	set portdir [sql_escape $portinfo(portdir)]
+	if {[info exists portinfo(description)]} {
+		set description [sql_escape $portinfo(description)]
+	} else {
+		set description ""
+	}
+	if {[info exists portinfo(categories)]} {
+		set categories $portinfo(categories)
+	} else {
+		set categories ""
+	}
+	if {[info exists portinfo(maintainers)]} {
+		set maintainers $portinfo(maintainers)
+	} else {
+		set maintainers ""
+	}
+	if {[info exists portinfo(variants)]} {
+		set variants $portinfo(variants)
+	} else {
+		set variants ""
+	}
+        if {[info exists portinfo(depends_build)]} {
+                set depends_build $portinfo(depends_build)
+        } else {
+                set depends_build ""
+        }
+	if {[info exists portinfo(depends_lib)]} {
+		set depends_lib $portinfo(depends_lib)
+	} else {
+		set depends_lib ""
+	}
+        if {[info exists portinfo(depends_run)]} {
+                set depends_run $portinfo(depends_run)
+        } else {
+                set depends_run ""
+        }
+	if {[info exists portinfo(platforms)]} {
+		set platforms $portinfo(platforms)
+	} else {
+		set platforms ""
+	}
+
+	puts $sqlfile_fd "INSERT INTO portfiles VALUES ('$portname', '$portdir', '$portversion', '$description')"
+
+	set primary 1
+	foreach category $categories {
+		set category [sql_escape $category]
+		puts $sqlfile_fd "INSERT INTO categories VALUES ('$portname', '$category', $primary)"
+		incr primary
+	}
+	
+	set primary 1
+	foreach maintainer $maintainers {
+		set maintainer [sql_escape $maintainer]
+		puts $sqlfile_fd "INSERT INTO maintainers VALUES ('$portname', '$maintainer', $primary)"
+		incr primary
+	}
+
+        foreach build_dep $depends_build {
+            set build_dep [sql_escape $build_dep]
+            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$build_dep')"
+        }
+
+	foreach lib $depends_lib {
+		set lib [sql_escape $lib]
+		puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$lib')"
+	}
+
+        foreach run_dep $depends_run {
+            set run_dep [sql_escape $run_dep]
+            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$run_dep')"
+        }
+
+	foreach variant $variants {
+		set variant [sql_escape $variant]
+		puts $sqlfile_fd "INSERT INTO variants VALUES ('$portname', '$variant')"
+	}
+
+	foreach platform $platforms {
+		set platform [sql_escape $platform]
+		puts $sqlfile_fd "INSERT INTO platforms VALUES ('$portname', '$platform')"
+	}
+
+}
+
+
+# Pipe the contents of the generated sql file to the database command,
+# reading from the file descriptor for the raw sql file to assure completeness.
+if {[catch {seek $sqlfile_fd 0 start} errstr]} {
+    ui_error "${::errorCode}: $errstr"
+    exit 1
+}
+if {[catch {exec $dbcmd $dbcmdargs <@ $sqlfile_fd} errstr]} {
+    ui_error "${::errorCode}: $errstr"
+    exit 1
+}
+
+
+# And we're done regen'ing the MacPorts dabase! (cleanup)
+close $sqlfile_fd
+file delete -force $sqlfile

Copied: trunk/base/portmgr/PortIndexRegen.sh (from rev 27921, trunk/base/portmgr/IndexRegen.sh)
===================================================================
--- trunk/base/portmgr/PortIndexRegen.sh	                        (rev 0)
+++ trunk/base/portmgr/PortIndexRegen.sh	2007-08-16 16:34:43 UTC (rev 27961)
@@ -0,0 +1,135 @@
+#!/bin/bash
+
+####
+# PortIndex regen automation script.
+# Created by Juan Manuel Palacios,
+# e-mail: jmpp at macports.org
+# Updated by Paul Guyot, <pguyot at kallisys.net>
+# Updated for svn by Daniel J. Luke <dluke at geeklair.net>
+# $Id$
+####
+
+# Configuration
+LOCKFILE=/tmp/.mp_svn_index_regen.lock
+# ROOT directory, where everything is. This needs to exist!
+ROOT=/Users/mp-user/mp_svn_index_regen
+# MP user.
+MP_USER=mp-user
+# MP group.
+MP_GROUP=mp-user
+# e-mail address to spam in case of failure.
+SPAM_LOVERS=macports-dev at lists.macosforge.org,dluke at geeklair.net
+
+# Other settings (probably don't need to be changed).
+SVN_CONFIG_DIR=${ROOT}/svnconfig
+REPO_BASE=http://svn.macports.org/repository/macports
+RELEASE_URL_FILE="config/RELEASE_URL"
+SVN="/opt/local/bin/svn -q --non-interactive --config-dir $SVN_CONFIG_DIR"
+# Where to checkout the source code. This needs to exist!
+SRCTREE=${ROOT}/source
+# Where MP will install its world. This gets created.
+PREFIX=${ROOT}/opt/local
+# Where MP installs macports1.0. This gets created.
+TCLPKG=${PREFIX}/lib/tcl
+# Path.
+PATH=${PREFIX}/bin:/bin:/usr/bin:/usr/sbin:/opt/local/bin
+# Log for the e-mail in case of failure.
+FAILURE_LOG=${ROOT}/failure.log
+# Commit message.
+COMMIT_MSG=${ROOT}/commit.msg
+# The date.
+DATE=$(date +'%A %Y-%m-%d at %H:%M:%S')
+
+
+# Function to spam people in charge if something goes wrong during indexing.
+bail () {
+    mail -s "AutoIndex Failure on ${DATE}" $SPAM_LOVERS < $FAILURE_LOG
+    cleanup; exit 1
+}
+
+# Cleanup fuction for runtime files.
+cleanup () {
+    rm -f $COMMIT_MSG $FAILURE_LOG
+    rm -f $LOCKFILE
+}
+
+
+if [ ! -e $LOCKFILE ]; then
+    touch $LOCKFILE
+else
+    echo "Index Regen lockfile found, is another index regen running?"
+    exit 1
+fi
+
+# Checkout/update the ports tree
+if [ -d ${SRCTREE}/dports ]; then
+    $SVN update ${SRCTREE}/dports > $FAILURE_LOG 2>&1 \
+	|| { echo "Updating the ports tree from $REPO_BASE/trunk/dports failed." >> $FAILURE_LOG; bail ; }
+else
+    $SVN checkout ${REPO_BASE}/trunk/dports ${SRCTREE}/dports > $FAILURE_LOG 2>&1 \
+	|| { echo "Checking out the ports tree from $REPO_BASE/trunk/dports failed." >> $FAILURE_LOG ; bail ; }
+fi
+echo `date -u +%s` > ${ROOT}/PORTS-TIMESTAMP
+
+# Checkout/update HEAD
+TMPDIR=mp_trunk/base
+if [ -d ${ROOT}/${TMPDIR} ]; then
+    $SVN update ${ROOT}/${TMPDIR} > $FAILURE_LOG 2>&1 \
+	|| { echo "Updating the trunk from $REPO_BASE/trunk/base failed." >> $FAILURE_LOG; bail ; }
+else
+    $SVN checkout ${REPO_BASE}/trunk/base ${ROOT}/${TMPDIR} > $FAILURE_LOG 2>&1 \
+       || { echo "Checking out the trunk from $REPO_BASE/trunk/base failed." >> $FAILURE_LOG ; bail ; }
+fi
+
+# Extract the release URL from HEAD
+read RELEASE_URL < ${ROOT}/${TMPDIR}/${RELEASE_URL_FILE}
+[ -n ${RELEASE_URL} ] || { echo "no RELEASE_URL specified in svn HEAD." >> $FAILURE_LOG; bail ; }
+
+# Checkout/update the release base
+if [ -d ${SRCTREE}/base ]; then
+    $SVN switch ${RELEASE_URL} ${SRCTREE}/base > $FAILURE_LOG 2>&1 \
+	|| { echo "Updating base from ${RELEASE_URL} failed." >> $FAILURE_LOG; bail ; }
+else
+    $SVN checkout ${RELEASE_URL} ${SRCTREE}/base > $FAILURE_LOG 2>&1 \
+	|| { echo "Checking out base from ${RELEASE_URL} failed." >> $FAILURE_LOG ; bail ; }
+fi
+echo `date -u +%s` > ${ROOT}/BASE-TIMESTAMP
+
+# (re)configure.
+cd ${SRCTREE}/base/ && \
+    mkdir -p ${TCLPKG} && \
+    ./configure \
+    --prefix=${PREFIX} \
+    --with-tclpackage=${TCLPKG} \
+    --with-install-user=${MP_USER} \
+    --with-install-group=${MP_GROUP} > $FAILURE_LOG 2>&1 \
+    || { echo "./configure script failed." >> $FAILURE_LOG ; bail ; }
+
+# clean
+# (cleaning is useful because we don't want the indexing to fail because dependencies aren't properly computed).
+{ cd ${SRCTREE}/base/ && make clean > $FAILURE_LOG 2>&1 ; } \
+    || { echo "make clean failed." >> $FAILURE_LOG ; bail ; }
+
+# (re)build
+{ cd ${SRCTREE}/base/ && make > $FAILURE_LOG 2>&1 ; } \
+    || { echo "make failed." >> $FAILURE_LOG ; bail ; }
+
+# (re)install
+{ cd ${SRCTREE}/base/ && make install > $FAILURE_LOG 2>&1 ; } \
+    || { echo "make install failed." >> $FAILURE_LOG ; bail ; }
+
+# (re)index
+{ cd ${SRCTREE}/dports/ && ${PREFIX}/bin/portindex > $FAILURE_LOG 2>&1 ; } \
+    || { echo "portindex failed." >> $FAILURE_LOG ; bail ; }
+
+# Commit the new index using the last 5 lines of the log for the commit message,
+tail -n 5 $FAILURE_LOG > $COMMIT_MSG
+# plus parsing failures, if any.
+echo "" >> $COMMIT_MSG
+grep Failed $FAILURE_LOG >> $COMMIT_MSG
+{ cd ${SRCTREE}/dports/ && \
+    svn --config-dir $SVN_CONFIG_DIR commit -F $COMMIT_MSG PortIndex > $FAILURE_LOG 2>&1 ; } \
+    || { echo "SVN commit failed." >> $FAILURE_LOG ; bail ; }
+
+# At this point the index was committed successfuly, so we cleanup before we exit.
+cleanup && exit 0


Property changes on: trunk/base/portmgr/PortIndexRegen.sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + text/x-sh
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Deleted: trunk/base/portmgr/packaging/Makefile
===================================================================
--- trunk/base/portmgr/packaging/Makefile	2007-08-16 15:05:19 UTC (rev 27960)
+++ trunk/base/portmgr/packaging/Makefile	2007-08-16 16:34:43 UTC (rev 27961)
@@ -1,20 +0,0 @@
-# $Id$
-
-SCRIPTS=	PortIndex2MySQL
-
-edit = sed \
-	-e 's, at TCL_PACKAGE_DIR@,$(TCL_PACKAGE_DIR),g'
-
-
-include ../../Mk/macports.autoconf.mk
-
-
-all: ${SCRIPTS}
-
-PortIndex2MySQL: PortIndex2MySQL.tcl
-	${edit} $< > $@
-
-clean:
-	rm -f ${SCRIPTS}
-
-distclean: clean

Deleted: trunk/base/portmgr/packaging/PortIndex2MySQL.tcl
===================================================================
--- trunk/base/portmgr/packaging/PortIndex2MySQL.tcl	2007-08-16 15:05:19 UTC (rev 27960)
+++ trunk/base/portmgr/packaging/PortIndex2MySQL.tcl	2007-08-16 16:34:43 UTC (rev 27961)
@@ -1,250 +0,0 @@
-#!/usr/bin/env tclsh
-#
-# PortIndex2MySQL.tcl
-# Kevin Van Vechten | kevin at opendarwin.org
-# 3-Oct-2002
-# Juan Manuel Palacios | jmpp at macports.org
-# 30-Jul-2007
-# $Id$
-#
-# Copyright (c) 2007 Juan Manuel Palacios, MacPorts Team.
-# Copyright (c) 2003 Apple Computer, Inc.
-# Copyright (c) 2002 Kevin Van Vechten. 
-# 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.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
-#    may be used to endorse or promote products derived from this software
-#    without specific prior written permission.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
-
-
-# Error messages reciepient.
-set SPAM_LOVERS macports-dev at lists.macosforge.org
-
-# Place holder proc for error catching and processing.
-proc bail_on_error {error_log} {
-    
-}
-
-
-# Load macports1.0 so that we can use some of its procs and the portinfo array.
-catch {source \
-	   [file join "@TCL_PACKAGE_DIR@" macports1.0 macports_fastload.tcl]}
-package require macports
-
-# Initialize MacPorts to find the sources.conf file, wherefrom we'll
-# get the PortIndex that'll feed the database.
-#more work needs to be done than just initializing and passing the
-#ui_options array to get mportinit to output verbose/debugging info;
-#I'm currently looking into this.
-array set ui_options {ports_verbose yes}
-mportinit
-
-# Call the selfupdate procedure to make sure the MacPorts installation
-# is up-to-date and with a fresh ports tree.
-macports::selfupdate
-
-
-# Procedure to catch the database password from a protected file.
-proc getpasswd {passwdfile} {
-    if {[catch {open $passwdfile r} passwdfile_fd]} {
-        ui_error "${::errorCode}: $passwdfile_fd"
-        exit 1
-    }
-    if {[gets $passwdfile_fd passwd] <= 0} {
-        ui_error "No password found in $passwdfile!"
-        exit 1
-    }
-    close $passwdfile_fd
-    return $passwd
-}
-
-# Database abstraction variables:
-set sqlfile [file join /tmp ports.sql]
-set dbcmd [macports::findBinary mysql5]
-set dbhost 127.0.0.1
-set dbname macports
-set dbuser macports
-set passwdfile [file join . password_file]
-set dbpasswd [getpasswd $passwdfile]
-set dbcmdargs "-h $dbhost -u $dbuser -p$dbpasswd $dbname"
-
-# Flat text file to which sql statements are written.
-if {[catch {open $sqlfile w+} sqlfile_fd]} {
-    ui_error "${::errorCode}: $sqlfile_fd"
-    exit 1
-}
-
-
-# SQL string escaping.
-proc sql_escape {str} {
-        regsub -all -- {'} $str {\\'} str
-        regsub -all -- {"} $str {\\"} str
-        regsub -all -- {\n} $str {\\n} str
-        return $str
-}
-
-# Initial creation of database tables: log, portfiles, categories, maintainers, dependencies, variants and platforms.
-# Do we need any other?
-puts $sqlfile_fd "DROP TABLE log"
-puts $sqlfile_fd "CREATE TABLE IF NOT EXISTS log (activity VARCHAR(255), activity_time TIMESTAMP(14))"
-puts $sqlfile_fd "INSERT INTO log VALUES ('update', NOW())"
-
-puts $sqlfile_fd "DROP TABLE portfiles"
-puts $sqlfile_fd "CREATE TABLE portfiles (name VARCHAR(255) PRIMARY KEY NOT NULL, path VARCHAR(255), version VARCHAR(255),  description TEXT)"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS categories"
-puts $sqlfile_fd "CREATE TABLE categories (portfile VARCHAR(255), category VARCHAR(255), is_primary INTEGER)"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS maintainers"
-puts $sqlfile_fd "CREATE TABLE maintainers (portfile VARCHAR(255), maintainer VARCHAR(255), is_primary INTEGER)"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS dependencies"
-puts $sqlfile_fd "CREATE TABLE dependencies (portfile VARCHAR(255), library VARCHAR(255))"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS variants"
-puts $sqlfile_fd "CREATE TABLE variants (portfile VARCHAR(255), variant VARCHAR(255))"
-
-puts $sqlfile_fd "DROP TABLE IF EXISTS platforms"
-puts $sqlfile_fd "CREATE TABLE platforms (portfile VARCHAR(255), platform VARCHAR(255))"
-
-
-# Load every port in the index through a search matching everything.
-if {[catch {set ports [mportsearch ".+"]} errstr]} {
-	ui_error "port search failed: $errstr"
-	exit 1
-}
-
-# Iterate over each matching port, extracting its information from the
-# portinfo array.
-foreach {name array} $ports {
-
-	array unset portinfo
-	array set portinfo $array
-
-	set portname [sql_escape $portinfo(name)]
-	if {[info exists portinfo(version)]} {
-		set portversion [sql_escape $portinfo(version)]
-	} else {
-		set portversion ""
-	}
-	set portdir [sql_escape $portinfo(portdir)]
-	if {[info exists portinfo(description)]} {
-		set description [sql_escape $portinfo(description)]
-	} else {
-		set description ""
-	}
-	if {[info exists portinfo(categories)]} {
-		set categories $portinfo(categories)
-	} else {
-		set categories ""
-	}
-	if {[info exists portinfo(maintainers)]} {
-		set maintainers $portinfo(maintainers)
-	} else {
-		set maintainers ""
-	}
-	if {[info exists portinfo(variants)]} {
-		set variants $portinfo(variants)
-	} else {
-		set variants ""
-	}
-        if {[info exists portinfo(depends_build)]} {
-                set depends_build $portinfo(depends_build)
-        } else {
-                set depends_build ""
-        }
-	if {[info exists portinfo(depends_lib)]} {
-		set depends_lib $portinfo(depends_lib)
-	} else {
-		set depends_lib ""
-	}
-        if {[info exists portinfo(depends_run)]} {
-                set depends_run $portinfo(depends_run)
-        } else {
-                set depends_run ""
-        }
-	if {[info exists portinfo(platforms)]} {
-		set platforms $portinfo(platforms)
-	} else {
-		set platforms ""
-	}
-
-	puts $sqlfile_fd "INSERT INTO portfiles VALUES ('$portname', '$portdir', '$portversion', '$description')"
-
-	set primary 1
-	foreach category $categories {
-		set category [sql_escape $category]
-		puts $sqlfile_fd "INSERT INTO categories VALUES ('$portname', '$category', $primary)"
-		incr primary
-	}
-	
-	set primary 1
-	foreach maintainer $maintainers {
-		set maintainer [sql_escape $maintainer]
-		puts $sqlfile_fd "INSERT INTO maintainers VALUES ('$portname', '$maintainer', $primary)"
-		incr primary
-	}
-
-        foreach build_dep $depends_build {
-            set build_dep [sql_escape $build_dep]
-            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$build_dep')"
-        }
-
-	foreach lib $depends_lib {
-		set lib [sql_escape $lib]
-		puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$lib')"
-	}
-
-        foreach run_dep $depends_run {
-            set run_dep [sql_escape $run_dep]
-            puts $sqlfile_fd "INSERT INTO dependencies VALUES ('$portname', '$run_dep')"
-        }
-
-	foreach variant $variants {
-		set variant [sql_escape $variant]
-		puts $sqlfile_fd "INSERT INTO variants VALUES ('$portname', '$variant')"
-	}
-
-	foreach platform $platforms {
-		set platform [sql_escape $platform]
-		puts $sqlfile_fd "INSERT INTO platforms VALUES ('$portname', '$platform')"
-	}
-
-}
-
-
-# Pipe the contents of the generated sql file to the database command,
-# reading from the file descriptor for the raw sql file to assure completeness.
-if {[catch {seek $sqlfile_fd 0 start} errstr]} {
-    ui_error "${::errorCode}: $errstr"
-    exit 1
-}
-if {[catch {exec $dbcmd $dbcmdargs <@ $sqlfile_fd} errstr]} {
-    ui_error "${::errorCode}: $errstr"
-    exit 1
-}
-
-
-# And we're done regen'ing the MacPorts dabase! (cleanup)
-close $sqlfile_fd
-file delete -force $sqlfile

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070816/020d5f32/attachment.html


More information about the macports-changes mailing list