[24869] branches/dp2mp-move/base/portmgr
source_changes at macosforge.org
source_changes at macosforge.org
Sun May 6 20:01:43 PDT 2007
Revision: 24869
http://trac.macosforge.org/projects/macports/changeset/24869
Author: jmpp at macports.org
Date: 2007-05-06 20:01:42 -0700 (Sun, 06 May 2007)
Log Message:
-----------
Move packaging scripts into an appropriate directory.
Added Paths:
-----------
branches/dp2mp-move/base/portmgr/packaging/
branches/dp2mp-move/base/portmgr/packaging/dpkgall.tcl
branches/dp2mp-move/base/portmgr/packaging/mpkgall.tcl
branches/dp2mp-move/base/portmgr/packaging/packageall.tcl
branches/dp2mp-move/base/portmgr/packaging/rpmall.tcl
Removed Paths:
-------------
branches/dp2mp-move/base/portmgr/dpkgall.tcl
branches/dp2mp-move/base/portmgr/mpkgall.tcl
branches/dp2mp-move/base/portmgr/packageall.tcl
branches/dp2mp-move/base/portmgr/rpmall.tcl
Deleted: branches/dp2mp-move/base/portmgr/dpkgall.tcl
===================================================================
--- branches/dp2mp-move/base/portmgr/dpkgall.tcl 2007-05-07 02:56:13 UTC (rev 24868)
+++ branches/dp2mp-move/base/portmgr/dpkgall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -1,932 +0,0 @@
-#!/usr/bin/env tclsh8.4
-# dpkgbuild.tcl
-# $Id$
-#
-# Copyright (c) 2004 Landon Fuller <landonf at macports.org>
-# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
-# 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.
-
-#######################################
-#
-# Must be installed outside of dports tree:
-# tcl 8.4
-# curl
-# tar
-# gzip
-# unzip
-# dports tree
-#
-# A tar file containing full /${portprefix} directory tree, stored in:
-# $pkgrepo/$architecture/root.tar.gz
-# The /${portprefix} directory tree must contain:
-# DarwinPorts installation
-# dpkg
-#
-# Configuration:
-# /etc/ports/dpkg.conf
-# /etc/ports/dpkg
-#
-#######################################
-
-package require darwinports
-
-# Configuration Namespace
-namespace eval dpkg {
- variable configopts "pkgrepo architecture portlistfile portprefix dportsrc silentmode initialports"
-
- # Preferences
- variable silentmode false
- variable configfile "/etc/ports/dpkg.conf"
- variable portlist ""
- variable portprefix "/usr/dports"
- variable dportsrc "/usr/darwinports"
- variable pkgrepo "/export/dpkg/"
- # architecture is set in main
- variable architecture
- variable initialports "dpkg apt"
- variable aptpackagedir
- variable packagedir
- # portlistfile defaults to ${pkgrepo}/${architecture}/etc/buildlist.txt (set in main)
- variable portlistfile
- # baselistfile defaults to ${pkgrepo}/${architecture}/etc/baselist.txt (set in main)
- variable baselistfile
-
- # Non-user modifiable.
- # Ports required for building. Format:
- # <binary> <portname> <binary> <portname> ...
- variable requiredports "dpkg dpkg apt-get apt"
-
- # Current log file descriptor
- variable logfd
-}
-
-# DarwinPorts UI Event Callbacks
-proc ui_prefix {priority} {
- switch $priority {
- debug {
- return "Debug: "
- }
- error {
- return "Error: "
- }
- warn {
- return "Warning: "
- }
- default {
- return ""
- }
- }
-}
-
-proc ui_channels {priority} {
- global dpkg::logfd
- if {[info exists logfd] && [string length $logfd] > 0 } {
- return {$logfd}
- } elseif {$message(priority) != "debug"} {
- # If there's no log file, echo to stdout
- return {stdout}
- }
-}
-
-proc ui_silent {message} {
- global dpkg::silentmode
- if {"${silentmode}" != true} {
- puts $message
- ui_msg $message
- } else {
- ui_msg $message
- }
-}
-
-# Outputs message to console and to log
-# Should only be used with errors
-proc ui_noisy_error {message} {
- puts $message
- ui_error $message
-}
-
-proc log_message {channel message} {
- seek $channel 0 end
- puts $channel $message
- flush $channel
-}
-
-# Read in configuration file
-proc readConfig {file} {
- global dpkg::configopts
-
- set fd [open $file r]
- while {[gets $fd line] >= 0} {
- foreach option $configopts {
- if {[regexp "^$option\[ \t\]+(\[A-Za-z0-9_:,\./-\]+$)" $line match val] == 1} {
- set dpkg::$option $val
- }
- }
- }
-}
-
-# Read a list of newline seperated port names from $file
-proc readPortList {file} {
- set fd [open $file r]
- set portlist ""
-
- while {[gets $fd line] >= 0} {
- lappend portlist $line
- }
-
- return $portlist
-}
-
-# Escape all regex characters in a portname
-proc regex_escape_portname {portname} {
- regsub -all "(\\(){1}|(\\)){1}|(\\{1}){1}|(\\+){1}|(\\{1}){1}|(\\{){1}|(\\}){1}|(\\^){1}|(\\$){1}|(\\.){1}|(\\\\){1}" $portname "\\\\&" escaped_string
- return $escaped_string
-}
-
-# Print usage string
-proc print_usage {args} {
- global argv0
- puts "Usage: [file tail $argv0] \[-qa\] \[-f configfile\] \[-p portlist\]"
- puts " -q Quiet mode (only errors reported)"
- puts " -w No warnings (progress still reported)"
- puts " -a Build all ports"
- puts " -b Re-generate base install archive"
- puts " -p Attempt to build ports that do not advertise support for the build platform"
- puts " -i Initialize Build System (Should only be run on a new build system)"
-}
-
-# Delete and restore the build system
-proc reset_tree {args} {
- global dpkg::portprefix dpkg::pkgrepo dpkg::architecture
-
- ui_silent "Restoring pristine ${portprefix} from ${pkgrepo}/${architecture}/root.tar.gz"
- if {[catch {system "rm -Rf ${portprefix}"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-
- if {[catch {system "rm -Rf /usr/X11R6"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-
- if {[catch {system "rm -Rf /etc/X11"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-
- if {[catch {system "cd / && tar xvf ${pkgrepo}/${architecture}/root.tar.gz"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-
- ui_silent "Linking static distfiles directory to ${portprefix}/var/db/dports/distfiles."
- if {[file isdirectory ${portprefix}/var/db/dports/distfiles"]} {
- if {[catch {system "rm -rf ${portprefix}/var/db/dports/distfiles"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-
- if {[catch {system "ln -s ${pkgrepo}/distfiles ${portprefix}/var/db/dports/distfiles"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
- }
-}
-
-proc main {argc argv} {
- global dpkg::configfile dpkg::pkgrepo dpkg::architecture dpkg::portlistfile
- global dpkg::portsArray dpkg::portprefix dpkg::silentmode dpkg::logfd dpkg::packagedir dpkg::aptpackagedir
- global dpkg::requiredports dpkg::baselistfile tcl_platform
-
- # First time through, we reset the tree
- set firstrun_flag true
-
- # Read command line options
- set buildall_flag false
- set anyplatform_flag false
- set nowarn_flag false
- set basegen_flag false
- set initialize_flag false
-
- for {set i 0} {$i < $argc} {incr i} {
- set arg [lindex $argv $i]
- switch -- $arg {
- -a {
- set buildall_flag true
- }
- -b {
- set basegen_flag true
- }
- -f {
- incr i
- set configfile [lindex $argv $i]
-
- if {![file readable $configfile]} {
- return -code error "Configuration file \"$configfile\" is unreadable."
- }
- }
- -i {
- set initialize_flag true
- }
- -p {
- incr i
- set portlistfile [lindex $argv $i]
- if {![file readable $portlistfile]} {
- return -code error "Port list file \"$portlistfile\" is unreadable."
- }
- }
- -q {
- set silentmode true
- }
- -w {
- set nowarn_flag true
- }
- -p {
- set anyplatform_flag true
- }
- default {
- print_usage
- exit 1
- }
- }
- }
-
- # Initialize System
- array set ui_options {}
- array set options {}
- array set variations {}
- dportinit ui_options options variations
-
- # If -i was specified, install base system and exit
- if {$initialize_flag == "true"} {
- initialize_system
- exit 0
- }
-
- # We must have dpkg by now
- if {[catch {set_architecture} result]} {
- puts "$result."
- puts "Have you initialized the build system? Use the -i flag:"
- print_usage
- exit 1
- }
-
- # Set the platform
- set platformString [string tolower $tcl_platform(os)]
-
- set packagedir ${pkgrepo}/${architecture}/packages/
- set aptpackagedir ${pkgrepo}/apt/dists/stable/main/binary-${architecture}/
-
- # Read configuration files
- if {[file readable $configfile]} {
- readConfig $configfile
- }
-
- # If portlistfile has not been set, supply a reasonable default
- if {![info exists portlistfile]} {
- # The default portlist file
- set portlistfile [file join $pkgrepo $architecture etc buildlist.txt]
- }
-
- # If baselistfile has not been set, supply a reasonable default
- if {![info exists baselistfile]} {
- # The default baselist file
- set baselistfile [file join $pkgrepo $architecture etc baselist.txt]
- }
-
- # Read the port list
- if {[file readable $portlistfile]} {
- set portlist [readPortList $portlistfile]
- } else {
- set portlist ""
- }
-
- if {[file readable $baselistfile]} {
- set baselist [readPortList $baselistfile]
- } else {
- set baselist ""
- }
-
- # If no portlist file was specified, create a portlist that includes all ports
- if {[llength $portlist] == 0 || "$buildall_flag" == "true"} {
- set res [dportsearch {.*}]
- foreach {name array} $res {
- lappend portlist $name
- }
- } else {
- # Port list was specified. Ensure that all the specified ports are available.
- # Add ${baselist} and get_required_ports to the list
- set portlist [lsort -unique [concat $portlist $baselist [get_required_ports]]]
- foreach port $portlist {
- set fail false
-
- if {[catch {set res [get_portinfo $port]} result]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Error: $result"
- set fail true
- }
-
- # Add all of the specified ports' dependencies to the portlist
- set dependencies [get_dependencies $port false]
- foreach dep $dependencies {
- lappend portlist [lindex $dep 0]
- }
- }
- if {"$fail" == "true"} {
- exit 1
- }
- }
-
- # Clean out duplicates
- set portlist [lsort -unique $portlist]
-
- # Ensure that the log directory exists, and open up
- # the default debug log
- open_default_log w
-
- # Set the dport options
- # Package build path
- set options(package.destpath) ${packagedir}
-
- # Ensure that it exists
- file mkdir $options(package.destpath)
-
- # Force mode
- set options(ports_force) yes
-
- # Set variations (empty)
- set variations [list]
-
-
- if {"$silentmode" != "true" && "$nowarn_flag" != "true"} {
- puts "WARNING: The full contents of ${portprefix}, /usr/X11R6, and /etc/X11 will be deleted by this script. If you do not want this, control-C NOW."
- exec sleep 10
- }
-
- # Destroy the existing apt repository
- if {[catch {system "rm -Rf ${aptpackagedir}"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-
- # Recreate
- file mkdir ${aptpackagedir}
-
- close_default_log
-
- foreach port $portlist {
- # Open the default debug log write/append
- open_default_log
-
- if {[catch {set res [get_portinfo $port]} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: port search failed: $error"
- exit 1
- }
-
- # Reset array from previous runs
- unset -nocomplain portinfo
- array set portinfo [lindex $res 1]
-
- if {![info exists portinfo(name)] ||
- ![info exists portinfo(version)] ||
- ![info exists portinfo(revision)] ||
- ![info exists portinfo(categories)]} {
- ui_noisy_error "Internal error: $name missing some portinfo keys"
- close $logfd
- continue
- }
-
- # Skip un-supported ports
- if {[info exists portinfo(platforms)] && ${anyplatform_flag} != "true"} {
- if {[lsearch $portinfo(platforms) $platformString] == -1} {
- ui_silent "Skipping unsupported port $portinfo(name) (platform: $platformString supported: $portinfo(platforms))"
- continue
- }
- }
-
-
- # Add apt override line. dpkg is special cased and marked 'required'
- # TODO: add the ability to specify the "required" priority for specific
- # ports in a config file.
- if {"$portinfo(name)" == "dpkg"} {
- set pkg_priority required
- } else {
- set pkg_priority optional
- }
- add_override $portinfo(name) $pkg_priority [lindex $portinfo(categories) 0]
-
- # Skip up-to-date software
- set pkgfile [get_pkgpath $portinfo(name) $portinfo(version) $portinfo(revision)]
- if {[file exists ${pkgfile}]} {
- if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
- if {[file readable $pkgfile] && ([file mtime ${pkgfile}] > [file mtime ${portpath}/Portfile])} {
- ui_silent "Skipping ${portinfo(name)}-${portinfo(version)}-${portinfo(revision)}; package is up to date."
- # Shove the package into the apt repository
- copy_pkg_to_apt $portinfo(name) $portinfo(version) $portinfo(revision) [lindex $portinfo(categories) 0]
- continue
- }
- }
- }
-
- # We're going to actually build the package, reset the tree
- # if this is our first time through. The tree is always reset
- # at the end of a packaging run, too.
- if {$firstrun_flag == true} {
- reset_tree
- set firstrun_flag false
- }
-
- ui_silent "Building $portinfo(name) ..."
-
- # Close the main debug log
- close_default_log
-
- # Create log directory and open the build log
- file mkdir [file join ${pkgrepo} ${architecture} log build ${port}]
- set logfd [open ${pkgrepo}/${architecture}/log/build/${port}/build.log w 0644]
-
- # Install binary dependencies if possible
- set dependencies [get_dependencies $portinfo(name)]
- foreach dep $dependencies {
- install_binary_if_available $dep
- }
-
- if {[catch {set workername [dportopen $portinfo(porturl) [array get options] [array get variations] yes]} result] || $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: unable to open port: $result"
- exit 1
- }
-
- if {[catch {set result [dportexec $workername clean]} result] || $result == 1} {
- ui_noisy_error "Cleaning $portinfo(name) failed, consult build log"
-
- # Close the log
- close $logfd
-
- # Copy the log to the failure directory
- copy_failure_log $portinfo(name)
-
- # Close the port
- dportclose $workername
-
- continue
- }
-
- # Re-open the port. DarwinPorts doesn't play well with multiple targets, apparently
- dportclose $workername
- if {[catch {set workername [dportopen $portinfo(porturl) [array get options] [array get variations] yes]} result] || $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: unable to open port: $result"
- exit 1
- }
-
- if {[catch {set result [dportexec $workername dpkg]} result] || $result == 1} {
- ui_noisy_error "Packaging $portinfo(name) failed, consult build log"
-
- # Copy the log to the failure directory
- copy_failure_log $portinfo(name)
-
- # Close the port
- dportclose $workername
-
- # Close the log
- close $logfd
-
- # Open default log
- open_default_log
-
- ui_silent "Resetting /usr/dports ..."
- reset_tree
- ui_silent "Done."
-
- # Close the log
- close $logfd
-
- continue
- }
-
- ui_silent "Package build for $portinfo(name) succeeded"
-
- # Into the apt repository you go!
- copy_pkg_to_apt $portinfo(name) $portinfo(version) $portinfo(revision) [lindex $portinfo(categories) 0]
-
- ui_silent "Resetting /usr/dports ..."
- reset_tree
- ui_silent "Done."
-
- # Close the log
- close $logfd
-
- # Delete any previous failure logs
- delete_failure_log $portinfo(name)
-
- # Close the port
- dportclose $workername
- }
-
- open_default_log
-
- # If required, rebuild the clientinstall.tgz
- if {$basegen_flag == true} {
- # dpkg is always required
- set pkglist [lsort -unique [concat dpkg $baselist [get_required_ports]]]
- set workdir [file join ${pkgrepo} ${architecture}]
- set rootdir [file join $workdir clientroot]
- set rootfile [file join $workdir client-root.tar.gz]
- file mkdir ${rootdir}
-
- # dpkg is required
- array set portinfo [lindex [get_portinfo dpkg] 1]
- set pkgfile [get_pkgpath $portinfo(name) $portinfo(version) $portinfo(revision)]
- system "cd \"${rootdir}\" && ar x \"${pkgfile}\" data.tar.gz"
- system "cd \"${rootdir}\" && tar xvf data.tar.gz; rm data.tar.gz"
-
- foreach port $pkglist {
- set dependencies [get_dependencies $port false]
- foreach dep $dependencies {
- lappend newpkglist [lindex $dep 0]
- }
- }
-
- if {[info exists newpkglist]} {
- set pkglist [lsort -unique [concat $newpkglist $pkglist]]
- }
-
- foreach port $pkglist {
- array set portinfo [lindex [get_portinfo $port] 1]
- system "dpkg --root \"${rootdir}\" --force-depends -i \"[get_pkgpath $portinfo(name) $portinfo(version) $portinfo(revision)]\""
- }
-
- system "cd \"${rootdir}\" && tar cf \"[file join ${workdir} clientinstall.tar.gz]\" ."
- file delete -force ${rootdir}
- }
-
- ui_silent "Building apt-get index ..."
- if {[catch {system "cd ${pkgrepo}/apt && dpkg-scanpackages dists override >${aptpackagedir}/Packages"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-
- if {[catch {system "cd ${aptpackagedir} && gzip Packages"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
- remove_override_file
- ui_silent "Done."
-
- ui_silent "Package run finished."
- close_default_log
-
- exit 0
-}
-
-# Return ports listed in $dpkg::requiredports that are not
-# installed
-proc get_required_ports {args} {
- global dpkg::requiredports
- set reqlist ""
-
- foreach {binary port} $requiredports {
- if {[find_binary $binary] == ""} {
- lappend reqlist $port
- }
- }
- return $reqlist
-}
-
-# Given a binary name, searches PATH
-proc find_binary {binary} {
- global env
- set path [split $env(PATH) :]
- foreach dir $path {
- set file [file join $dir $binary]
- if {[file exists $file]} {
- return $file
- }
- }
- return ""
-}
-
-# Set the architecture global
-proc set_architecture {args} {
- set dpkg::architecture "[exec dpkg --print-installation-architecture]"
-}
-
-# Initialize a new build system
-proc initialize_system {args} {
- global dpkg::initialports dpkg::pkgrepo
- global dpkg::architecture dpkg::portprefix
-
- # Create standard directories
- ui_msg "Creating ${pkgrepo} directory"
- file mkdir ${pkgrepo}
-
- set builddeps ""
- set rundeps ""
-
- foreach port [get_required_ports] {
- set builddeps [concat $builddeps [get_dependencies $port true]]
- set rundeps [concat $rundeps [get_dependencies $port false]]
- }
-
- set buildlist [lsort -unique $builddeps]
-
- foreach port $builddeps {
- if {[lsearch -exact $port $rundeps] >= 0 } {
- lappend removelist $port
- }
- }
-
- set options ""
- set variations ""
-
- foreach port [get_required_ports] {
- if {[catch {do_portexec $port [array get options] [array get variants] install} result]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Fatal error: $result"
- exit 1
- }
- }
-
- if {[info exists removelist]} {
- ui_msg "Removing build dependencies ..."
- foreach portlist $removelist {
- set port [lindex $portlist 0]
-
- ui_msg "Uninstalling $port."
- if { [catch {portuninstall::uninstall $portname $portversion} result] } {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_errorr "Fatal error: Uninstalling $port failed: $result"
- exit 1
- }
- }
- ui_msg "Done."
- }
-
-
- if {[catch {set_architecture} result]} {
- puts "Fatal error: $result."
- exit 1
- }
-
- ui_msg "Creating [file join ${pkgrepo} ${architecture}] directory"
- file mkdir [file join ${pkgrepo} ${architecture}]
- file mkdir [file join ${pkgrepo} ${architecture} etc]
-
- ui_msg "Generating pristine archive: [file join ${pkgrepo} ${architecture} root.tar.gz]"
- if {[catch {system "tar -zcf \"[file join ${pkgrepo} ${architecture} root.tar.gz]\" \"${portprefix}\""} result]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Fatal error: Archive creation failed: $result"
- exit 1
- }
-
- ui_msg "Build system successfully initialized!"
-}
-
-# Execute a target on a port (by port name)
-proc do_portexec {port options variants target} {
-
- array set portinfo [lindex [get_portinfo $port] 1]
-
- if {[catch {set workername [dportopen $portinfo(porturl) $options $variants yes]} result] || $result == 1} {
- return -code error "Internal error: unable to open port: $result"
- exit 1
- }
-
- if {[catch {set result [dportexec $workername install]} result] || $result == 1} {
-
- # Close the port
- dportclose $workername
-
- # Return error
- return -code error "Executing target $target on $portinfo(name) failed."
- }
-}
-
-proc get_portinfo {port} {
- set searchstring [regex_escape_portname $port]
- set res [dportsearch "^${searchstring}\$"]
-
- if {[llength $res] < 2} {
- return -code error "Port \"$port\" not found in index."
- }
-
- return $res
-}
-
-# Given name, version, and revision, returns the path to a package file
-proc get_pkgpath {name version revision} {
- global dpkg::pkgrepo dpkg::architecture
- global dpkg::packagedir
- if {${revision} == 0} {
- set revision ""
- } else {
- set revision "-${revision}"
- }
-
- return [string tolower ${packagedir}/${name}_${version}${revision}_${architecture}.deb]
-}
-
-# Opens the default log file and sets dpkg::logfd
-proc open_default_log {{mode a}} {
- global dpkg::pkgrepo dpkg::architecture dpkg::logfd
- # Ensure that the log directory exists, and open up
- # the default debug log
- file mkdir ${pkgrepo}/${architecture}/log/
- set logfd [open ${pkgrepo}/${architecture}/log/debug.log ${mode} 0644]
-}
-
-# Closes the current logfile
-proc close_default_log {args} {
- global dpkg::logfd
- close $logfd
-}
-
-# Copies a port log file to the failure directory
-proc copy_failure_log {name} {
- global dpkg::pkgrepo dpkg::architecture
- # Copy the log to the failure log directory
- file mkdir ${pkgrepo}/${architecture}/log/failure/${name}
- file copy -force ${pkgrepo}/${architecture}/log/build/${name}/build.log ${pkgrepo}/${architecture}/log/failure/${name}/
-}
-
-# Deletes a port's failure log
-proc delete_failure_log {name} {
- global dpkg::pkgrepo dpkg::architecture
- if {[catch {system "rm -Rf ${pkgrepo}/${architecture}/log/failure/${name}"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-}
-
-# Add an override entry to the apt override file
-proc add_override {name priority section {maintainer ""}} {
- global dpkg::aptpackagedir dpkg::pkgrepo
- set output "${name} ${priority} ${section}"
- if {${maintainer} != ""} {
- append output " ${maintainer}"
- }
- set fd [open "${pkgrepo}/apt/override" a 0644]
- puts $fd $output
- close $fd
-}
-
-# Deletes the apt override file
-proc remove_override_file {args} {
- global dpkg::aptpackagedir dpkg::pkgrepo
- if {[catch {file delete -force ${pkgrepo}/apt/override} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
-}
-
-# Copies a given package to the apt repository
-proc copy_pkg_to_apt {name version revision category} {
- global dpkg::aptpackagedir
-
- set pkgfile [get_pkgpath $name $version $revision]
- file mkdir $aptpackagedir/main/$category
- file link -hard $aptpackagedir/main/$category/[file tail $pkgfile] $pkgfile
-}
-
-# Recursive bottom-up approach of building a list of dependencies.
-proc get_dependencies {portname {includeBuildDeps "true"}} {
- set result [get_dependencies_recurse $portname $includeBuildDeps]
- return [lsort -unique $result]
-}
-
-proc get_dependencies_recurse {portname includeBuildDeps} {
- set result {}
-
- set res [get_portinfo $portname]
-
- foreach {name array} $res {
- array set portinfo $array
- if {![info exists portinfo(name)] ||
- ![info exists portinfo(version)] ||
- ![info exists portinfo(revision)] ||
- ![info exists portinfo(categories)]} {
- ui_error "Internal error: $name missing some portinfo keys"
- continue
- }
-
- lappend result [list $portinfo(name) $portinfo(version) $portinfo(revision) [lindex $portinfo(categories) 0]]
-
- # Append the package's dependents to the result list
- set depends {}
- if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
- if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
- if {$includeBuildDeps == "true" && [info exists portinfo(depends_build)]} {
- eval "lappend depends $portinfo(depends_build)"
- }
- foreach depspec $depends {
- set dep [lindex [split $depspec :] end]
- set x [get_dependencies_recurse $dep $includeBuildDeps]
- eval "lappend result $x"
- set result [lsort -unique $result]
- }
- }
- return $result
-}
-
-# Install binary packages if they've already been built. This will
-# speed up the testing, since we won't have to recompile dependencies
-# which have already been compiled.
-
-proc install_binary_if_available {dep} {
- global dpkg::architecture dpkg::pkgrepo dpkg::portprefix
-
- set portname [lindex $dep 0]
- set portversion [lindex $dep 1]
- set portrevision [lindex $dep 2]
- set category [lindex $dep 3]
-
- if {${portrevision} != ""} {
- set verstring ${portversion}_${portrevision}
- } else {
- set verstring ${portversion}
- }
-
- set receiptdir [file join $portprefix var db receipts ${portname} ${verstring}]
- set pkgpath [get_pkgpath ${portname} ${portversion} ${portrevision}]
-
- # Check if the package is available, and ensure that it has not already been
- # installed through darwinports (bootstrap packages such as dpkg and its
- # dependencies are always installed)
- if {[file readable $pkgpath] && ![file exists $receiptdir/receipt.bz2]} {
- ui_silent "Installing binary: $pkgpath"
- if {[catch {system "dpkg --force-depends -i ${pkgpath}"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
- # Touch the receipt
- file mkdir $receiptdir
- if {[catch {system "touch [file join $receiptdir receipt.bz2]"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_noisy_error "Internal error: $error"
- exit 1
- }
- }
-}
-
-### main() entry point ####
-main $argc $argv
Deleted: branches/dp2mp-move/base/portmgr/mpkgall.tcl
===================================================================
--- branches/dp2mp-move/base/portmgr/mpkgall.tcl 2007-05-07 02:56:13 UTC (rev 24868)
+++ branches/dp2mp-move/base/portmgr/mpkgall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -1,336 +0,0 @@
-#!/usr/bin/env tclsh
-# mpkgall.tcl
-# $Id$
-#
-# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
-# 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.
-
-package require darwinports
-
-# globals
-set portdir .
-array set ui_options {}
-
-proc ui_prefix {priority} {
- return ""
-}
-
-proc ui_channels {priority} {
- return {}
-}
-
-# copy binary packages if they've already been built.
-
-proc copy_package_if_available {portname basepath destpath} {
-
- set dependencies {}
-
- # XXX: don't overwrite Apple X11
- # XXX: probably should exclude KDE here too
- if {$portname == "XFree86"} { return {} }
-
- if {[catch {set res [dportsearch "^$portname\$"]} error]} {
- puts stderr "Internal error: port search failed: $error"
- return
- }
- foreach {name array} $res {
- array set portinfo $array
- if {![info exists portinfo(name)]} { return -1 }
- if {![info exists portinfo(version)]} { return -1 }
- if {![info exists portinfo(categories)]} { return -1 }
-
- set portname $portinfo(name)
- set portversion $portinfo(version)
- set category [lindex $portinfo(categories) 0]
-
- set depends {}
- if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
- if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
- #if {[info exists portinfo(depends_build)]} { eval "lappend depends $portinfo(depends_build)" }
- foreach depspec $depends {
- set dep [lindex [split $depspec :] end]
- set result [copy_package_if_available $dep $basepath $destpath]
- if {$result == -1} {
- return -1
- } else {
- eval "lappend dependencies $result"
- }
- }
-
- set pkgname "${portname}-${portversion}.pkg"
- lappend dependencies $pkgname
- set pkgpath "${basepath}/${category}/${pkgname}"
- if {[file readable "${pkgpath}/Contents/Info.plist"]} {
- puts stderr "copying package: ${pkgpath} to ${destpath}"
- if {[catch {system "cp -R ${pkgpath} ${destpath}/"} error]} {
- puts stderr "Internal error: $error"
- }
- } else {
- puts stderr "package ${pkgname} not found"
- return -1
- }
- }
-
- return $dependencies
-}
-
-proc write_description_plist {infofile portname portversion description} {
- set infofd [open ${infofile} w+]
- puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-}
- puts $infofd "<dict>
- <key>IFPkgDescriptionDeleteWarning</key>
- <string></string>
- <key>IFPkgDescriptionDescription</key>
- <string>${description}</string>
- <key>IFPkgDescriptionTitle</key>
- <string>${portname}</string>
- <key>IFPkgDescriptionVersion</key>
- <string>${portversion}</string>
-</dict>
-</plist>"
- close $infofd
-}
-
-proc write_welcome_html {filename portname portversion long_description description homepage} {
- set fd [open ${filename} w+]
- if {$long_description == ""} {
- set long_description $description
- }
-
-puts $fd "
-<html lang=\"en\">
-<head>
- <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">
- <title>Install ${portname}</title>
-</head>
-<body>
-<font face=\"Helvetica\"><b>Welcome to the ${portname} for Mac OS X Installer</b></font>
-<p>
-<font face=\"Helvetica\">${long_description}</font>
-<p>"
-
- if {$homepage != ""} {
- puts $fd "<font face=\"Helvetica\">${homepage}</font><p>"
- }
-
- puts $fd "<font face=\"Helvetica\">This installer guides you through the steps necessary to install ${portname} ${portversion} for Mac OS X. To get started, click Continue.</font>
-</body>
-</html>"
-
- close $fd
-}
-
-proc write_PkgInfo {infofile} {
- set infofd [open ${infofile} w+]
- puts $infofd "pmkrpkg1"
- close $infofd
-}
-
-proc mpkg_write_info_plist {infofile portname portversion portrevision destination dependencies} {
- set vers [split $portversion "."]
-
- if {[string index $destination end] != "/"} {
- append destination /
- }
-
- set depxml ""
- foreach dep $dependencies {
- append depxml "<dict>
- <key>IFPkgFlagPackageLocation</key>
- <string>${dep}</string>
- <key>IFPkgFlagPackageSelection</key>
- <string>selected</string>
- </dict>
- "
- }
-
- set infofd [open ${infofile} w+]
- puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-}
- puts $infofd "<dict>
- <key>CFBundleGetInfoString</key>
- <string>${portname} ${portversion}</string>
- <key>CFBundleIdentifier</key>
- <string>org.opendarwin.darwinports.mpkg.${portname}</string>
- <key>CFBundleName</key>
- <string>${portname}</string>
- <key>CFBundleShortVersionString</key>
- <string>${portversion}</string>
- <key>IFMajorVersion</key>
- <integer>${portrevision}</integer>
- <key>IFMinorVersion</key>
- <integer>0</integer>
- <key>IFPkgFlagComponentDirectory</key>
- <string>./Contents/Resources</string>
- <key>IFPkgFlagPackageList</key>
- <array>
- ${depxml}</array>
- <key>IFPkgFormatVersion</key>
- <real>0.10000000149011612</real>
-</dict>
-</plist>"
- close $infofd
-}
-
-
-# Standard procedures
-
-proc fatal args {
- global argv0
- puts stderr "$argv0: $args"
- exit
-}
-
-# Main
-array set options [list]
-array set variations [list]
-# set ui_options(ports_verbose) yes
-
-if {[catch {dportinit ui_options options variations} result]} {
- puts "Failed to initialize ports system, $result"
- exit 1
-}
-
-package require Pextlib
-
-# If no arguments were given, default to all ports.
-if {[llength $argv] == 0} {
- lappend argv ".*"
-}
-
-foreach pname $argv {
-
-if {[catch {set res [dportsearch "^${pname}\$"]} result]} {
- puts "port search failed: $result"
- exit 1
-}
-
-foreach {name array} $res {
- global prefix
- array unset portinfo
- array set portinfo $array
-
- if {![info exists portinfo(porturl)]} {
- puts stderr "Internal error: no porturl for $name"
- continue
- }
-
- set pkgbase "/darwinports/pkgs/"
- set mpkgbase "/darwinports/mpkgs/"
- set porturl $portinfo(porturl)
- set prefix "/opt/local"
-
- # Skip up-to-date packages
- if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
- if {[info exists portinfo(name)] &&
- [info exists portinfo(version)] &&
- [info exists portinfo(categories)]} {
- set portname $portinfo(name)
- set portversion $portinfo(version)
- set category [lindex $portinfo(categories) 0]
- set mpkgfile ${mpkgbase}/${category}/${portname}-${portversion}.mpkg/Contents/Info.plist
- if {[file readable $mpkgfile] && ([file mtime ${mpkgfile}] > [file mtime ${portpath}/Portfile])} {
- puts stderr "Skipping ${portname}-${portversion}; meta-package is up to date."
- continue
- }
- }
- }
-
- # Skipt packages which previously failed
-
- # Building the mpkg:
- # - create an mpkg skeleton
- # - copy dependent pkgs into Contents/Resources directory
-
- set portname ""
- set portversion ""
- set description ""
- set long_description ""
- set homepage ""
- set category ""
-
- if {[info exists portinfo(name)]} { set portname $portinfo(name) }
- if {[info exists portinfo(version)]} { set portversion $portinfo(version) }
- if {[info exists portinfo(description)]} { set description $portinfo(description) }
- if {[info exists portinfo(long_description)]} { set long_description $portinfo(long_description) }
- if {[info exists portinfo(homepage)]} { set homepage $portinfo(homepage) }
- if {[info exists portinfo(categories)]} { set category [lindex $portinfo(categories) 0] }
- if {[info exists portinfo(maintainers)]} { set maintainers $portinfo(maintainers) }
-
- puts "meta-packaging ${category}/${portname}-${portversion}"
-
- set mpkgpath "${mpkgbase}/${category}/${portname}-${portversion}.mpkg"
-
- if {[catch {system "mkdir -p -m 0755 ${mpkgpath}/Contents/Resources"} error]} {
- puts stderr "Internal error: $error"
- }
-
- # list of .pkg names for dependencies,
- # built up by copy_package_if_available, and used in the Info.plist
- set dependencies {}
- set result [copy_package_if_available ${portname} $pkgbase "${mpkgpath}/Contents/Resources/"]
- if {$result == -1} {
- puts stderr "aborting; one or more dependencies was missing."
- if {[catch {system "rm -R ${mpkgpath}"} error]} {
- puts stderr "Internal error: $error"
- }
- continue
- } else {
- set result [lsort -uniq $result]
- eval "lappend dependencies $result"
- }
-
- #
- # Begin quote from portmpkg.tcl
- #
- write_PkgInfo ${mpkgpath}/Contents/PkgInfo
- mpkg_write_info_plist ${mpkgpath}/Contents/Info.plist $portname $portversion $prefix $dependencies
- write_description_plist ${mpkgpath}/Contents/Resources/Description.plist $portname $portversion $description
- # long_description, description, or homepage may not exist
- foreach variable {long_description description homepage} {
- if {![info exists $variable]} {
- set pkg_$variable ""
- } else {
- set pkg_$variable [set $variable]
- }
- }
- write_welcome_html ${mpkgpath}/Contents/Resources/Welcome.html $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
- file copy -force -- /opt/local/share/darwinports/resources/port1.0/package/background.tiff \
- ${mpkgpath}/Contents/Resources/background.tiff
- #
- # End quote from portmpkg.tcl
- #
-}
-
-}
-# end foreach pname
Deleted: branches/dp2mp-move/base/portmgr/packageall.tcl
===================================================================
--- branches/dp2mp-move/base/portmgr/packageall.tcl 2007-05-07 02:56:13 UTC (rev 24868)
+++ branches/dp2mp-move/base/portmgr/packageall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -1,421 +0,0 @@
-#!/usr/bin/env tclsh
-# packageall.tcl
-# $Id$
-#
-# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
-# 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.
-
-package require darwinports
-
-# globals
-set portdir .
-
-# UI Instantiations
-array set ui_options {}
-# ui_options(ports_debug) - If set, output debugging messages.
-# ui_options(ports_verbose) - If set, output info messages (ui_info)
-# ui_options(ports_quiet) - If set, don't output "standard messages"
-
-# ui_options accessor
-proc ui_isset {val} {
- global ui_options
- if {[info exists ui_options($val)]} {
- if {$ui_options($val) == "yes"} {
- return 1
- }
- }
- return 0
-}
-
-# UI Callback
-
-proc ui_prefix {priority} {
- switch $priority {
- debug {
- return "DEBUG: "
- }
- error {
- return "Error: "
- }
- warn {
- return "Warning: "
- }
- default {
- return ""
- }
- }
-}
-
-proc ui_channels {priority} {
- global logfd
- switch $priority {
- debug {
- if {[ui_isset ports_debug]} {
- return {stdout}
- } else {
- return {}
- }
- }
- info {
- # put verbose stuff only to the log file
- if {[ui_isset ports_verbose]} {
- return {$logfd}
- } else {
- return {}
- }
- }
- msg {
- if {[ui_isset ports_quiet]} {
- return {}
- } else {
- return {stdout}
- }
- }
- default {
- return {stdout}
- }
- }
-}
-
-proc pkg_ui_log {message} {
- global logfd
- if {[string length $logfd] > 0 } {
- log_message $logfd $message
- }
-}
-
-proc log_message {channel message} {
- seek $channel 0 end
- puts $channel $message
- flush $channel
-}
-
-# Recursive bottom-up approach of building a list of dependencies.
-proc get_dependencies {portname includeBuildDeps} {
- set result {}
-
- if {[catch {set res [dportsearch "^$portname\$"]} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: port search failed: $error"
- return {}
- }
- foreach {name array} $res {
- array set portinfo $array
- if {![info exists portinfo(name)] ||
- ![info exists portinfo(version)] ||
- ![info exists portinfo(categories)]} {
- ui_error "Internal error: $name missing some portinfo keys"
- continue
- }
-
- set portname $portinfo(name)
- set portversion $portinfo(version)
- set category [lindex $portinfo(categories) 0]
-
- # Append the package itself to the result list
- #set pkgpath ${category}/${portname}-${portversion}.pkg
- lappend result [list $portname $portversion $category]
-
- # Append the package's dependents to the result list
- set depends {}
- if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
- if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
- if {$includeBuildDeps != "" && [info exists portinfo(depends_build)]} {
- eval "lappend depends $portinfo(depends_build)"
- }
- foreach depspec $depends {
- set dep [lindex [split $depspec :] end]
- set x [get_dependencies $dep $includeBuildDeps]
- eval "lappend result $x"
- set result [lsort -unique $result]
- }
- }
- return $result
-}
-
-# Install binary packages if they've already been built. This will
-# speed up the testing, since we won't have to recompile dependencies
-# which have already been compiled.
-
-proc install_binary_if_available {dep basepath} {
- set portname [lindex $dep 0]
- set portversion [lindex $dep 1]
- set category [lindex $dep 2]
-
- set pkgpath ${basepath}/${category}/${portname}-${portversion}.pkg
- if {[file readable $pkgpath]} {
- ui_msg "installing binary: $pkgpath"
- if {[catch {system "cd / && gunzip -c ${pkgpath}/Contents/Archive.pax.gz | pax -r"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: $error"
- }
- # Touch the receipt
- # xxx: use some variable to describe this path
- if {[catch {system "touch /opt/local/var/db/dports/receipts/${portname}-${portversion}.bz2"} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: $error"
- }
- }
-}
-
-
-# Standard procedures
-
-proc fatal args {
- global argv0
- puts stderr "$argv0: $args"
- exit
-}
-
-# Main
-array set options [list]
-array set variations [list]
-# set ui_options(ports_verbose) yes
-
-if {[catch {dportinit ui_options options variations} result]} {
- puts "Failed to initialize ports system, $result"
- exit 1
-}
-
-package require Pextlib
-
-# If no arguments were given, default to all ports.
-if {[llength $argv] == 0} {
- lappend argv ".*"
-}
-
-foreach pname $argv {
-
-if {[catch {set res [dportsearch "^${pname}\$"]} result]} {
- puts "port search failed: $result"
- exit 1
-}
-
-set logpath "/darwinports/logs"
-set logfd ""
-
-foreach {name array} $res {
- array unset portinfo
- array set portinfo $array
-
- # Start with verbose output off;
- # this will prevent the repopulation of /opt from getting logged.
- set ui_options(ports_verbose) no
-
- if {![info exists portinfo(porturl)]} {
- puts stderr "Internal error: no porturl for $name"
- continue
- }
-
- set pkgbase /darwinports/pkgs/
- set porturl $portinfo(porturl)
-
- # Skip up-to-date packages
- if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
- if {[info exists portinfo(name)] &&
- [info exists portinfo(version)] &&
- [info exists portinfo(categories)]} {
- set portname $portinfo(name)
- set portversion $portinfo(version)
- set category [lindex $portinfo(categories) 0]
- set pkgfile ${pkgbase}/${category}/${portname}-${portversion}.pkg/Contents/Archive.pax.gz
- if {[file readable $pkgfile] && ([file mtime ${pkgfile}] > [file mtime ${portpath}/Portfile])} {
- puts stderr "Skipping ${portname}-${portversion}; package is up to date."
- continue
- }
- }
- }
-
- # Skipt packages which previously failed
-
- # Building the port:
- # - remove /opt so it won't pollute the port.
- # - re-install DarwinPorts.
- # - keep distfiles outside /opt so we don't have to keep fetching them.
- # - send out an email to the maintainer if any errors occurred.
-
- ui_msg "removing /opt"
- #unset ui_options(ports_verbose)
- if {[catch {system "rm -Rf /opt"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "rm -Rf /usr/X11R6"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "rm -Rf /etc/X11"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "rm -Rf /etc/fonts"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "cd $env(HOME)/darwinports && make && make install"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "rmdir /opt/local/var/db/dports/distfiles"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "ln -s /darwinports/distfiles /opt/local/var/db/dports/distfiles"} error]} {
- puts stderr "Internal error: $error"
- }
- #set ui_options(ports_verbose) yes
-
- # If there was a log file left over from the previous pass,
- # then the port failed with an error. Send the log in an
- # email to the maintainers.
- if {[string length $logfd] > 0} {
- close $logfd
- set logfd ""
- }
- #if {[file readable $logfilename]} {
- # if {[catch {system "cat $logfilename | /usr/sbin/sendmail -t"} error]} {
- # puts stderr "Internal error: $error"
- # }
- #}
-
- # Open the log file for writing
- set logfd [open ${logpath}/${name}.log w]
-
- set valid 1
-
- set lint_errors {}
- set portname ""
- set portversion ""
- set description ""
- set category ""
-
- if {![info exists portinfo(name)]} {
- lappend lint_errors "missing name key"
- set valid 0
- } else {
- set portname $portinfo(name)
- }
-
- if {![info exists portinfo(description)]} {
- lappend lint_errors "missing description key"
- set valid 0
- } else {
- set description $portinfo(description)
- }
-
- if {![info exists portinfo(version)]} {
- lappend lint_errors "missing version key"
- set valid 0
- } else {
- set portversion $portinfo(version)
- }
-
- if {![info exists portinfo(categories)]} {
- lappend lint_errors "missing categories key"
- set valid 0
- } else {
- set category [lindex $portinfo(categories) 0]
- }
-
- if {![info exists portinfo(maintainers)]} {
- append lint_errors "missing maintainers key"
- set valid 0
- set maintainers kevin at opendarwin.org
- } else {
- set maintainers $portinfo(maintainers)
- }
-
- pkg_ui_log "To: [join $maintainers {, }]"
- pkg_ui_log "From: donotreply at opendarwin.org"
- pkg_ui_log "Subject: DarwinPorts $portinfo(name)-$portinfo(version) build failure"
- pkg_ui_log ""
- pkg_ui_log "The following is a transcript produced by the DarwinPorts automated build "
- pkg_ui_log "system. You are receiving this email because you are listed as a maintainer "
- pkg_ui_log "of this port, which has failed the automated packaging process. Please update "
- pkg_ui_log "the port as soon as possible."
- pkg_ui_log ""
- pkg_ui_log ""
- pkg_ui_log "Thank you,"
- pkg_ui_log "The DarwinPorts Team"
- pkg_ui_log ""
- pkg_ui_log "================================================================================"
- pkg_ui_log ""
-
- if {!$valid} {
- foreach error $lint_errors {
- ui_error $error
- }
- }
-
- ui_msg "packaging ${category}/${portname}-${portversion}"
-
- # Install binary dependencies if we can, to speed things up.
- #set depends {}
- #if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
- #if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
- #if {[info exists portinfo(depends_build)]} { eval "lappend depends $portinfo(depends_build)" }
- #foreach depspec $depends {
- # set dep [lindex [split $depspec :] end]
- #install_binary_if_available $dep $pkgbase
- #}
- set dependencies [get_dependencies $portname 1]
- set dependencies [lsort -unique $dependencies]
- foreach dep $dependencies {
- install_binary_if_available $dep $pkgbase
- }
-
- set options(package.type) pkg
- set options(package.destpath) ${pkgbase}/${category}/
-
- # Turn on verbose output for the build
- set ui_options(ports_verbose) yes
- if {[catch {set workername [dportopen $porturl [array get options] [array get variations] yes]} result] ||
- $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: unable to open port: $result"
- continue
- }
- if {[catch {set result [dportexec $workername pkg]} result] ||
- $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "port package failed: $result"
- dportclose $workername
- continue
- }
- set ui_options(ports_verbose) no
- # Turn verbose output off after the build
-
- dportclose $workername
-
- # We made it to the end. We can delete the log file.
- close $logfd
- set logfd ""
- file delete ${logpath}/${name}.log
-}
-
-}
-# end foreach pname
Copied: branches/dp2mp-move/base/portmgr/packaging/dpkgall.tcl (from rev 24627, branches/dp2mp-move/base/portmgr/dpkgall.tcl)
===================================================================
--- branches/dp2mp-move/base/portmgr/packaging/dpkgall.tcl (rev 0)
+++ branches/dp2mp-move/base/portmgr/packaging/dpkgall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -0,0 +1,932 @@
+#!/usr/bin/env tclsh8.4
+# dpkgbuild.tcl
+# $Id$
+#
+# Copyright (c) 2004 Landon Fuller <landonf at macports.org>
+# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
+# Copyright (c) 2002 Apple Computer, Inc.
+# 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.
+
+#######################################
+#
+# Must be installed outside of dports tree:
+# tcl 8.4
+# curl
+# tar
+# gzip
+# unzip
+# dports tree
+#
+# A tar file containing full /${portprefix} directory tree, stored in:
+# $pkgrepo/$architecture/root.tar.gz
+# The /${portprefix} directory tree must contain:
+# DarwinPorts installation
+# dpkg
+#
+# Configuration:
+# /etc/ports/dpkg.conf
+# /etc/ports/dpkg
+#
+#######################################
+
+package require darwinports
+
+# Configuration Namespace
+namespace eval dpkg {
+ variable configopts "pkgrepo architecture portlistfile portprefix dportsrc silentmode initialports"
+
+ # Preferences
+ variable silentmode false
+ variable configfile "/etc/ports/dpkg.conf"
+ variable portlist ""
+ variable portprefix "/usr/dports"
+ variable dportsrc "/usr/darwinports"
+ variable pkgrepo "/export/dpkg/"
+ # architecture is set in main
+ variable architecture
+ variable initialports "dpkg apt"
+ variable aptpackagedir
+ variable packagedir
+ # portlistfile defaults to ${pkgrepo}/${architecture}/etc/buildlist.txt (set in main)
+ variable portlistfile
+ # baselistfile defaults to ${pkgrepo}/${architecture}/etc/baselist.txt (set in main)
+ variable baselistfile
+
+ # Non-user modifiable.
+ # Ports required for building. Format:
+ # <binary> <portname> <binary> <portname> ...
+ variable requiredports "dpkg dpkg apt-get apt"
+
+ # Current log file descriptor
+ variable logfd
+}
+
+# DarwinPorts UI Event Callbacks
+proc ui_prefix {priority} {
+ switch $priority {
+ debug {
+ return "Debug: "
+ }
+ error {
+ return "Error: "
+ }
+ warn {
+ return "Warning: "
+ }
+ default {
+ return ""
+ }
+ }
+}
+
+proc ui_channels {priority} {
+ global dpkg::logfd
+ if {[info exists logfd] && [string length $logfd] > 0 } {
+ return {$logfd}
+ } elseif {$message(priority) != "debug"} {
+ # If there's no log file, echo to stdout
+ return {stdout}
+ }
+}
+
+proc ui_silent {message} {
+ global dpkg::silentmode
+ if {"${silentmode}" != true} {
+ puts $message
+ ui_msg $message
+ } else {
+ ui_msg $message
+ }
+}
+
+# Outputs message to console and to log
+# Should only be used with errors
+proc ui_noisy_error {message} {
+ puts $message
+ ui_error $message
+}
+
+proc log_message {channel message} {
+ seek $channel 0 end
+ puts $channel $message
+ flush $channel
+}
+
+# Read in configuration file
+proc readConfig {file} {
+ global dpkg::configopts
+
+ set fd [open $file r]
+ while {[gets $fd line] >= 0} {
+ foreach option $configopts {
+ if {[regexp "^$option\[ \t\]+(\[A-Za-z0-9_:,\./-\]+$)" $line match val] == 1} {
+ set dpkg::$option $val
+ }
+ }
+ }
+}
+
+# Read a list of newline seperated port names from $file
+proc readPortList {file} {
+ set fd [open $file r]
+ set portlist ""
+
+ while {[gets $fd line] >= 0} {
+ lappend portlist $line
+ }
+
+ return $portlist
+}
+
+# Escape all regex characters in a portname
+proc regex_escape_portname {portname} {
+ regsub -all "(\\(){1}|(\\)){1}|(\\{1}){1}|(\\+){1}|(\\{1}){1}|(\\{){1}|(\\}){1}|(\\^){1}|(\\$){1}|(\\.){1}|(\\\\){1}" $portname "\\\\&" escaped_string
+ return $escaped_string
+}
+
+# Print usage string
+proc print_usage {args} {
+ global argv0
+ puts "Usage: [file tail $argv0] \[-qa\] \[-f configfile\] \[-p portlist\]"
+ puts " -q Quiet mode (only errors reported)"
+ puts " -w No warnings (progress still reported)"
+ puts " -a Build all ports"
+ puts " -b Re-generate base install archive"
+ puts " -p Attempt to build ports that do not advertise support for the build platform"
+ puts " -i Initialize Build System (Should only be run on a new build system)"
+}
+
+# Delete and restore the build system
+proc reset_tree {args} {
+ global dpkg::portprefix dpkg::pkgrepo dpkg::architecture
+
+ ui_silent "Restoring pristine ${portprefix} from ${pkgrepo}/${architecture}/root.tar.gz"
+ if {[catch {system "rm -Rf ${portprefix}"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+
+ if {[catch {system "rm -Rf /usr/X11R6"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+
+ if {[catch {system "rm -Rf /etc/X11"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+
+ if {[catch {system "cd / && tar xvf ${pkgrepo}/${architecture}/root.tar.gz"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+
+ ui_silent "Linking static distfiles directory to ${portprefix}/var/db/dports/distfiles."
+ if {[file isdirectory ${portprefix}/var/db/dports/distfiles"]} {
+ if {[catch {system "rm -rf ${portprefix}/var/db/dports/distfiles"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+
+ if {[catch {system "ln -s ${pkgrepo}/distfiles ${portprefix}/var/db/dports/distfiles"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+ }
+}
+
+proc main {argc argv} {
+ global dpkg::configfile dpkg::pkgrepo dpkg::architecture dpkg::portlistfile
+ global dpkg::portsArray dpkg::portprefix dpkg::silentmode dpkg::logfd dpkg::packagedir dpkg::aptpackagedir
+ global dpkg::requiredports dpkg::baselistfile tcl_platform
+
+ # First time through, we reset the tree
+ set firstrun_flag true
+
+ # Read command line options
+ set buildall_flag false
+ set anyplatform_flag false
+ set nowarn_flag false
+ set basegen_flag false
+ set initialize_flag false
+
+ for {set i 0} {$i < $argc} {incr i} {
+ set arg [lindex $argv $i]
+ switch -- $arg {
+ -a {
+ set buildall_flag true
+ }
+ -b {
+ set basegen_flag true
+ }
+ -f {
+ incr i
+ set configfile [lindex $argv $i]
+
+ if {![file readable $configfile]} {
+ return -code error "Configuration file \"$configfile\" is unreadable."
+ }
+ }
+ -i {
+ set initialize_flag true
+ }
+ -p {
+ incr i
+ set portlistfile [lindex $argv $i]
+ if {![file readable $portlistfile]} {
+ return -code error "Port list file \"$portlistfile\" is unreadable."
+ }
+ }
+ -q {
+ set silentmode true
+ }
+ -w {
+ set nowarn_flag true
+ }
+ -p {
+ set anyplatform_flag true
+ }
+ default {
+ print_usage
+ exit 1
+ }
+ }
+ }
+
+ # Initialize System
+ array set ui_options {}
+ array set options {}
+ array set variations {}
+ dportinit ui_options options variations
+
+ # If -i was specified, install base system and exit
+ if {$initialize_flag == "true"} {
+ initialize_system
+ exit 0
+ }
+
+ # We must have dpkg by now
+ if {[catch {set_architecture} result]} {
+ puts "$result."
+ puts "Have you initialized the build system? Use the -i flag:"
+ print_usage
+ exit 1
+ }
+
+ # Set the platform
+ set platformString [string tolower $tcl_platform(os)]
+
+ set packagedir ${pkgrepo}/${architecture}/packages/
+ set aptpackagedir ${pkgrepo}/apt/dists/stable/main/binary-${architecture}/
+
+ # Read configuration files
+ if {[file readable $configfile]} {
+ readConfig $configfile
+ }
+
+ # If portlistfile has not been set, supply a reasonable default
+ if {![info exists portlistfile]} {
+ # The default portlist file
+ set portlistfile [file join $pkgrepo $architecture etc buildlist.txt]
+ }
+
+ # If baselistfile has not been set, supply a reasonable default
+ if {![info exists baselistfile]} {
+ # The default baselist file
+ set baselistfile [file join $pkgrepo $architecture etc baselist.txt]
+ }
+
+ # Read the port list
+ if {[file readable $portlistfile]} {
+ set portlist [readPortList $portlistfile]
+ } else {
+ set portlist ""
+ }
+
+ if {[file readable $baselistfile]} {
+ set baselist [readPortList $baselistfile]
+ } else {
+ set baselist ""
+ }
+
+ # If no portlist file was specified, create a portlist that includes all ports
+ if {[llength $portlist] == 0 || "$buildall_flag" == "true"} {
+ set res [dportsearch {.*}]
+ foreach {name array} $res {
+ lappend portlist $name
+ }
+ } else {
+ # Port list was specified. Ensure that all the specified ports are available.
+ # Add ${baselist} and get_required_ports to the list
+ set portlist [lsort -unique [concat $portlist $baselist [get_required_ports]]]
+ foreach port $portlist {
+ set fail false
+
+ if {[catch {set res [get_portinfo $port]} result]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Error: $result"
+ set fail true
+ }
+
+ # Add all of the specified ports' dependencies to the portlist
+ set dependencies [get_dependencies $port false]
+ foreach dep $dependencies {
+ lappend portlist [lindex $dep 0]
+ }
+ }
+ if {"$fail" == "true"} {
+ exit 1
+ }
+ }
+
+ # Clean out duplicates
+ set portlist [lsort -unique $portlist]
+
+ # Ensure that the log directory exists, and open up
+ # the default debug log
+ open_default_log w
+
+ # Set the dport options
+ # Package build path
+ set options(package.destpath) ${packagedir}
+
+ # Ensure that it exists
+ file mkdir $options(package.destpath)
+
+ # Force mode
+ set options(ports_force) yes
+
+ # Set variations (empty)
+ set variations [list]
+
+
+ if {"$silentmode" != "true" && "$nowarn_flag" != "true"} {
+ puts "WARNING: The full contents of ${portprefix}, /usr/X11R6, and /etc/X11 will be deleted by this script. If you do not want this, control-C NOW."
+ exec sleep 10
+ }
+
+ # Destroy the existing apt repository
+ if {[catch {system "rm -Rf ${aptpackagedir}"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+
+ # Recreate
+ file mkdir ${aptpackagedir}
+
+ close_default_log
+
+ foreach port $portlist {
+ # Open the default debug log write/append
+ open_default_log
+
+ if {[catch {set res [get_portinfo $port]} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: port search failed: $error"
+ exit 1
+ }
+
+ # Reset array from previous runs
+ unset -nocomplain portinfo
+ array set portinfo [lindex $res 1]
+
+ if {![info exists portinfo(name)] ||
+ ![info exists portinfo(version)] ||
+ ![info exists portinfo(revision)] ||
+ ![info exists portinfo(categories)]} {
+ ui_noisy_error "Internal error: $name missing some portinfo keys"
+ close $logfd
+ continue
+ }
+
+ # Skip un-supported ports
+ if {[info exists portinfo(platforms)] && ${anyplatform_flag} != "true"} {
+ if {[lsearch $portinfo(platforms) $platformString] == -1} {
+ ui_silent "Skipping unsupported port $portinfo(name) (platform: $platformString supported: $portinfo(platforms))"
+ continue
+ }
+ }
+
+
+ # Add apt override line. dpkg is special cased and marked 'required'
+ # TODO: add the ability to specify the "required" priority for specific
+ # ports in a config file.
+ if {"$portinfo(name)" == "dpkg"} {
+ set pkg_priority required
+ } else {
+ set pkg_priority optional
+ }
+ add_override $portinfo(name) $pkg_priority [lindex $portinfo(categories) 0]
+
+ # Skip up-to-date software
+ set pkgfile [get_pkgpath $portinfo(name) $portinfo(version) $portinfo(revision)]
+ if {[file exists ${pkgfile}]} {
+ if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
+ if {[file readable $pkgfile] && ([file mtime ${pkgfile}] > [file mtime ${portpath}/Portfile])} {
+ ui_silent "Skipping ${portinfo(name)}-${portinfo(version)}-${portinfo(revision)}; package is up to date."
+ # Shove the package into the apt repository
+ copy_pkg_to_apt $portinfo(name) $portinfo(version) $portinfo(revision) [lindex $portinfo(categories) 0]
+ continue
+ }
+ }
+ }
+
+ # We're going to actually build the package, reset the tree
+ # if this is our first time through. The tree is always reset
+ # at the end of a packaging run, too.
+ if {$firstrun_flag == true} {
+ reset_tree
+ set firstrun_flag false
+ }
+
+ ui_silent "Building $portinfo(name) ..."
+
+ # Close the main debug log
+ close_default_log
+
+ # Create log directory and open the build log
+ file mkdir [file join ${pkgrepo} ${architecture} log build ${port}]
+ set logfd [open ${pkgrepo}/${architecture}/log/build/${port}/build.log w 0644]
+
+ # Install binary dependencies if possible
+ set dependencies [get_dependencies $portinfo(name)]
+ foreach dep $dependencies {
+ install_binary_if_available $dep
+ }
+
+ if {[catch {set workername [dportopen $portinfo(porturl) [array get options] [array get variations] yes]} result] || $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: unable to open port: $result"
+ exit 1
+ }
+
+ if {[catch {set result [dportexec $workername clean]} result] || $result == 1} {
+ ui_noisy_error "Cleaning $portinfo(name) failed, consult build log"
+
+ # Close the log
+ close $logfd
+
+ # Copy the log to the failure directory
+ copy_failure_log $portinfo(name)
+
+ # Close the port
+ dportclose $workername
+
+ continue
+ }
+
+ # Re-open the port. DarwinPorts doesn't play well with multiple targets, apparently
+ dportclose $workername
+ if {[catch {set workername [dportopen $portinfo(porturl) [array get options] [array get variations] yes]} result] || $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: unable to open port: $result"
+ exit 1
+ }
+
+ if {[catch {set result [dportexec $workername dpkg]} result] || $result == 1} {
+ ui_noisy_error "Packaging $portinfo(name) failed, consult build log"
+
+ # Copy the log to the failure directory
+ copy_failure_log $portinfo(name)
+
+ # Close the port
+ dportclose $workername
+
+ # Close the log
+ close $logfd
+
+ # Open default log
+ open_default_log
+
+ ui_silent "Resetting /usr/dports ..."
+ reset_tree
+ ui_silent "Done."
+
+ # Close the log
+ close $logfd
+
+ continue
+ }
+
+ ui_silent "Package build for $portinfo(name) succeeded"
+
+ # Into the apt repository you go!
+ copy_pkg_to_apt $portinfo(name) $portinfo(version) $portinfo(revision) [lindex $portinfo(categories) 0]
+
+ ui_silent "Resetting /usr/dports ..."
+ reset_tree
+ ui_silent "Done."
+
+ # Close the log
+ close $logfd
+
+ # Delete any previous failure logs
+ delete_failure_log $portinfo(name)
+
+ # Close the port
+ dportclose $workername
+ }
+
+ open_default_log
+
+ # If required, rebuild the clientinstall.tgz
+ if {$basegen_flag == true} {
+ # dpkg is always required
+ set pkglist [lsort -unique [concat dpkg $baselist [get_required_ports]]]
+ set workdir [file join ${pkgrepo} ${architecture}]
+ set rootdir [file join $workdir clientroot]
+ set rootfile [file join $workdir client-root.tar.gz]
+ file mkdir ${rootdir}
+
+ # dpkg is required
+ array set portinfo [lindex [get_portinfo dpkg] 1]
+ set pkgfile [get_pkgpath $portinfo(name) $portinfo(version) $portinfo(revision)]
+ system "cd \"${rootdir}\" && ar x \"${pkgfile}\" data.tar.gz"
+ system "cd \"${rootdir}\" && tar xvf data.tar.gz; rm data.tar.gz"
+
+ foreach port $pkglist {
+ set dependencies [get_dependencies $port false]
+ foreach dep $dependencies {
+ lappend newpkglist [lindex $dep 0]
+ }
+ }
+
+ if {[info exists newpkglist]} {
+ set pkglist [lsort -unique [concat $newpkglist $pkglist]]
+ }
+
+ foreach port $pkglist {
+ array set portinfo [lindex [get_portinfo $port] 1]
+ system "dpkg --root \"${rootdir}\" --force-depends -i \"[get_pkgpath $portinfo(name) $portinfo(version) $portinfo(revision)]\""
+ }
+
+ system "cd \"${rootdir}\" && tar cf \"[file join ${workdir} clientinstall.tar.gz]\" ."
+ file delete -force ${rootdir}
+ }
+
+ ui_silent "Building apt-get index ..."
+ if {[catch {system "cd ${pkgrepo}/apt && dpkg-scanpackages dists override >${aptpackagedir}/Packages"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+
+ if {[catch {system "cd ${aptpackagedir} && gzip Packages"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+ remove_override_file
+ ui_silent "Done."
+
+ ui_silent "Package run finished."
+ close_default_log
+
+ exit 0
+}
+
+# Return ports listed in $dpkg::requiredports that are not
+# installed
+proc get_required_ports {args} {
+ global dpkg::requiredports
+ set reqlist ""
+
+ foreach {binary port} $requiredports {
+ if {[find_binary $binary] == ""} {
+ lappend reqlist $port
+ }
+ }
+ return $reqlist
+}
+
+# Given a binary name, searches PATH
+proc find_binary {binary} {
+ global env
+ set path [split $env(PATH) :]
+ foreach dir $path {
+ set file [file join $dir $binary]
+ if {[file exists $file]} {
+ return $file
+ }
+ }
+ return ""
+}
+
+# Set the architecture global
+proc set_architecture {args} {
+ set dpkg::architecture "[exec dpkg --print-installation-architecture]"
+}
+
+# Initialize a new build system
+proc initialize_system {args} {
+ global dpkg::initialports dpkg::pkgrepo
+ global dpkg::architecture dpkg::portprefix
+
+ # Create standard directories
+ ui_msg "Creating ${pkgrepo} directory"
+ file mkdir ${pkgrepo}
+
+ set builddeps ""
+ set rundeps ""
+
+ foreach port [get_required_ports] {
+ set builddeps [concat $builddeps [get_dependencies $port true]]
+ set rundeps [concat $rundeps [get_dependencies $port false]]
+ }
+
+ set buildlist [lsort -unique $builddeps]
+
+ foreach port $builddeps {
+ if {[lsearch -exact $port $rundeps] >= 0 } {
+ lappend removelist $port
+ }
+ }
+
+ set options ""
+ set variations ""
+
+ foreach port [get_required_ports] {
+ if {[catch {do_portexec $port [array get options] [array get variants] install} result]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Fatal error: $result"
+ exit 1
+ }
+ }
+
+ if {[info exists removelist]} {
+ ui_msg "Removing build dependencies ..."
+ foreach portlist $removelist {
+ set port [lindex $portlist 0]
+
+ ui_msg "Uninstalling $port."
+ if { [catch {portuninstall::uninstall $portname $portversion} result] } {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_errorr "Fatal error: Uninstalling $port failed: $result"
+ exit 1
+ }
+ }
+ ui_msg "Done."
+ }
+
+
+ if {[catch {set_architecture} result]} {
+ puts "Fatal error: $result."
+ exit 1
+ }
+
+ ui_msg "Creating [file join ${pkgrepo} ${architecture}] directory"
+ file mkdir [file join ${pkgrepo} ${architecture}]
+ file mkdir [file join ${pkgrepo} ${architecture} etc]
+
+ ui_msg "Generating pristine archive: [file join ${pkgrepo} ${architecture} root.tar.gz]"
+ if {[catch {system "tar -zcf \"[file join ${pkgrepo} ${architecture} root.tar.gz]\" \"${portprefix}\""} result]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Fatal error: Archive creation failed: $result"
+ exit 1
+ }
+
+ ui_msg "Build system successfully initialized!"
+}
+
+# Execute a target on a port (by port name)
+proc do_portexec {port options variants target} {
+
+ array set portinfo [lindex [get_portinfo $port] 1]
+
+ if {[catch {set workername [dportopen $portinfo(porturl) $options $variants yes]} result] || $result == 1} {
+ return -code error "Internal error: unable to open port: $result"
+ exit 1
+ }
+
+ if {[catch {set result [dportexec $workername install]} result] || $result == 1} {
+
+ # Close the port
+ dportclose $workername
+
+ # Return error
+ return -code error "Executing target $target on $portinfo(name) failed."
+ }
+}
+
+proc get_portinfo {port} {
+ set searchstring [regex_escape_portname $port]
+ set res [dportsearch "^${searchstring}\$"]
+
+ if {[llength $res] < 2} {
+ return -code error "Port \"$port\" not found in index."
+ }
+
+ return $res
+}
+
+# Given name, version, and revision, returns the path to a package file
+proc get_pkgpath {name version revision} {
+ global dpkg::pkgrepo dpkg::architecture
+ global dpkg::packagedir
+ if {${revision} == 0} {
+ set revision ""
+ } else {
+ set revision "-${revision}"
+ }
+
+ return [string tolower ${packagedir}/${name}_${version}${revision}_${architecture}.deb]
+}
+
+# Opens the default log file and sets dpkg::logfd
+proc open_default_log {{mode a}} {
+ global dpkg::pkgrepo dpkg::architecture dpkg::logfd
+ # Ensure that the log directory exists, and open up
+ # the default debug log
+ file mkdir ${pkgrepo}/${architecture}/log/
+ set logfd [open ${pkgrepo}/${architecture}/log/debug.log ${mode} 0644]
+}
+
+# Closes the current logfile
+proc close_default_log {args} {
+ global dpkg::logfd
+ close $logfd
+}
+
+# Copies a port log file to the failure directory
+proc copy_failure_log {name} {
+ global dpkg::pkgrepo dpkg::architecture
+ # Copy the log to the failure log directory
+ file mkdir ${pkgrepo}/${architecture}/log/failure/${name}
+ file copy -force ${pkgrepo}/${architecture}/log/build/${name}/build.log ${pkgrepo}/${architecture}/log/failure/${name}/
+}
+
+# Deletes a port's failure log
+proc delete_failure_log {name} {
+ global dpkg::pkgrepo dpkg::architecture
+ if {[catch {system "rm -Rf ${pkgrepo}/${architecture}/log/failure/${name}"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+}
+
+# Add an override entry to the apt override file
+proc add_override {name priority section {maintainer ""}} {
+ global dpkg::aptpackagedir dpkg::pkgrepo
+ set output "${name} ${priority} ${section}"
+ if {${maintainer} != ""} {
+ append output " ${maintainer}"
+ }
+ set fd [open "${pkgrepo}/apt/override" a 0644]
+ puts $fd $output
+ close $fd
+}
+
+# Deletes the apt override file
+proc remove_override_file {args} {
+ global dpkg::aptpackagedir dpkg::pkgrepo
+ if {[catch {file delete -force ${pkgrepo}/apt/override} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+}
+
+# Copies a given package to the apt repository
+proc copy_pkg_to_apt {name version revision category} {
+ global dpkg::aptpackagedir
+
+ set pkgfile [get_pkgpath $name $version $revision]
+ file mkdir $aptpackagedir/main/$category
+ file link -hard $aptpackagedir/main/$category/[file tail $pkgfile] $pkgfile
+}
+
+# Recursive bottom-up approach of building a list of dependencies.
+proc get_dependencies {portname {includeBuildDeps "true"}} {
+ set result [get_dependencies_recurse $portname $includeBuildDeps]
+ return [lsort -unique $result]
+}
+
+proc get_dependencies_recurse {portname includeBuildDeps} {
+ set result {}
+
+ set res [get_portinfo $portname]
+
+ foreach {name array} $res {
+ array set portinfo $array
+ if {![info exists portinfo(name)] ||
+ ![info exists portinfo(version)] ||
+ ![info exists portinfo(revision)] ||
+ ![info exists portinfo(categories)]} {
+ ui_error "Internal error: $name missing some portinfo keys"
+ continue
+ }
+
+ lappend result [list $portinfo(name) $portinfo(version) $portinfo(revision) [lindex $portinfo(categories) 0]]
+
+ # Append the package's dependents to the result list
+ set depends {}
+ if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
+ if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
+ if {$includeBuildDeps == "true" && [info exists portinfo(depends_build)]} {
+ eval "lappend depends $portinfo(depends_build)"
+ }
+ foreach depspec $depends {
+ set dep [lindex [split $depspec :] end]
+ set x [get_dependencies_recurse $dep $includeBuildDeps]
+ eval "lappend result $x"
+ set result [lsort -unique $result]
+ }
+ }
+ return $result
+}
+
+# Install binary packages if they've already been built. This will
+# speed up the testing, since we won't have to recompile dependencies
+# which have already been compiled.
+
+proc install_binary_if_available {dep} {
+ global dpkg::architecture dpkg::pkgrepo dpkg::portprefix
+
+ set portname [lindex $dep 0]
+ set portversion [lindex $dep 1]
+ set portrevision [lindex $dep 2]
+ set category [lindex $dep 3]
+
+ if {${portrevision} != ""} {
+ set verstring ${portversion}_${portrevision}
+ } else {
+ set verstring ${portversion}
+ }
+
+ set receiptdir [file join $portprefix var db receipts ${portname} ${verstring}]
+ set pkgpath [get_pkgpath ${portname} ${portversion} ${portrevision}]
+
+ # Check if the package is available, and ensure that it has not already been
+ # installed through darwinports (bootstrap packages such as dpkg and its
+ # dependencies are always installed)
+ if {[file readable $pkgpath] && ![file exists $receiptdir/receipt.bz2]} {
+ ui_silent "Installing binary: $pkgpath"
+ if {[catch {system "dpkg --force-depends -i ${pkgpath}"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+ # Touch the receipt
+ file mkdir $receiptdir
+ if {[catch {system "touch [file join $receiptdir receipt.bz2]"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_noisy_error "Internal error: $error"
+ exit 1
+ }
+ }
+}
+
+### main() entry point ####
+main $argc $argv
Copied: branches/dp2mp-move/base/portmgr/packaging/mpkgall.tcl (from rev 24532, branches/dp2mp-move/base/portmgr/mpkgall.tcl)
===================================================================
--- branches/dp2mp-move/base/portmgr/packaging/mpkgall.tcl (rev 0)
+++ branches/dp2mp-move/base/portmgr/packaging/mpkgall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -0,0 +1,336 @@
+#!/usr/bin/env tclsh
+# mpkgall.tcl
+# $Id$
+#
+# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
+# Copyright (c) 2002 Apple Computer, Inc.
+# 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.
+
+package require darwinports
+
+# globals
+set portdir .
+array set ui_options {}
+
+proc ui_prefix {priority} {
+ return ""
+}
+
+proc ui_channels {priority} {
+ return {}
+}
+
+# copy binary packages if they've already been built.
+
+proc copy_package_if_available {portname basepath destpath} {
+
+ set dependencies {}
+
+ # XXX: don't overwrite Apple X11
+ # XXX: probably should exclude KDE here too
+ if {$portname == "XFree86"} { return {} }
+
+ if {[catch {set res [dportsearch "^$portname\$"]} error]} {
+ puts stderr "Internal error: port search failed: $error"
+ return
+ }
+ foreach {name array} $res {
+ array set portinfo $array
+ if {![info exists portinfo(name)]} { return -1 }
+ if {![info exists portinfo(version)]} { return -1 }
+ if {![info exists portinfo(categories)]} { return -1 }
+
+ set portname $portinfo(name)
+ set portversion $portinfo(version)
+ set category [lindex $portinfo(categories) 0]
+
+ set depends {}
+ if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
+ if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
+ #if {[info exists portinfo(depends_build)]} { eval "lappend depends $portinfo(depends_build)" }
+ foreach depspec $depends {
+ set dep [lindex [split $depspec :] end]
+ set result [copy_package_if_available $dep $basepath $destpath]
+ if {$result == -1} {
+ return -1
+ } else {
+ eval "lappend dependencies $result"
+ }
+ }
+
+ set pkgname "${portname}-${portversion}.pkg"
+ lappend dependencies $pkgname
+ set pkgpath "${basepath}/${category}/${pkgname}"
+ if {[file readable "${pkgpath}/Contents/Info.plist"]} {
+ puts stderr "copying package: ${pkgpath} to ${destpath}"
+ if {[catch {system "cp -R ${pkgpath} ${destpath}/"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ } else {
+ puts stderr "package ${pkgname} not found"
+ return -1
+ }
+ }
+
+ return $dependencies
+}
+
+proc write_description_plist {infofile portname portversion description} {
+ set infofd [open ${infofile} w+]
+ puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+}
+ puts $infofd "<dict>
+ <key>IFPkgDescriptionDeleteWarning</key>
+ <string></string>
+ <key>IFPkgDescriptionDescription</key>
+ <string>${description}</string>
+ <key>IFPkgDescriptionTitle</key>
+ <string>${portname}</string>
+ <key>IFPkgDescriptionVersion</key>
+ <string>${portversion}</string>
+</dict>
+</plist>"
+ close $infofd
+}
+
+proc write_welcome_html {filename portname portversion long_description description homepage} {
+ set fd [open ${filename} w+]
+ if {$long_description == ""} {
+ set long_description $description
+ }
+
+puts $fd "
+<html lang=\"en\">
+<head>
+ <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">
+ <title>Install ${portname}</title>
+</head>
+<body>
+<font face=\"Helvetica\"><b>Welcome to the ${portname} for Mac OS X Installer</b></font>
+<p>
+<font face=\"Helvetica\">${long_description}</font>
+<p>"
+
+ if {$homepage != ""} {
+ puts $fd "<font face=\"Helvetica\">${homepage}</font><p>"
+ }
+
+ puts $fd "<font face=\"Helvetica\">This installer guides you through the steps necessary to install ${portname} ${portversion} for Mac OS X. To get started, click Continue.</font>
+</body>
+</html>"
+
+ close $fd
+}
+
+proc write_PkgInfo {infofile} {
+ set infofd [open ${infofile} w+]
+ puts $infofd "pmkrpkg1"
+ close $infofd
+}
+
+proc mpkg_write_info_plist {infofile portname portversion portrevision destination dependencies} {
+ set vers [split $portversion "."]
+
+ if {[string index $destination end] != "/"} {
+ append destination /
+ }
+
+ set depxml ""
+ foreach dep $dependencies {
+ append depxml "<dict>
+ <key>IFPkgFlagPackageLocation</key>
+ <string>${dep}</string>
+ <key>IFPkgFlagPackageSelection</key>
+ <string>selected</string>
+ </dict>
+ "
+ }
+
+ set infofd [open ${infofile} w+]
+ puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+}
+ puts $infofd "<dict>
+ <key>CFBundleGetInfoString</key>
+ <string>${portname} ${portversion}</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.opendarwin.darwinports.mpkg.${portname}</string>
+ <key>CFBundleName</key>
+ <string>${portname}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${portversion}</string>
+ <key>IFMajorVersion</key>
+ <integer>${portrevision}</integer>
+ <key>IFMinorVersion</key>
+ <integer>0</integer>
+ <key>IFPkgFlagComponentDirectory</key>
+ <string>./Contents/Resources</string>
+ <key>IFPkgFlagPackageList</key>
+ <array>
+ ${depxml}</array>
+ <key>IFPkgFormatVersion</key>
+ <real>0.10000000149011612</real>
+</dict>
+</plist>"
+ close $infofd
+}
+
+
+# Standard procedures
+
+proc fatal args {
+ global argv0
+ puts stderr "$argv0: $args"
+ exit
+}
+
+# Main
+array set options [list]
+array set variations [list]
+# set ui_options(ports_verbose) yes
+
+if {[catch {dportinit ui_options options variations} result]} {
+ puts "Failed to initialize ports system, $result"
+ exit 1
+}
+
+package require Pextlib
+
+# If no arguments were given, default to all ports.
+if {[llength $argv] == 0} {
+ lappend argv ".*"
+}
+
+foreach pname $argv {
+
+if {[catch {set res [dportsearch "^${pname}\$"]} result]} {
+ puts "port search failed: $result"
+ exit 1
+}
+
+foreach {name array} $res {
+ global prefix
+ array unset portinfo
+ array set portinfo $array
+
+ if {![info exists portinfo(porturl)]} {
+ puts stderr "Internal error: no porturl for $name"
+ continue
+ }
+
+ set pkgbase "/darwinports/pkgs/"
+ set mpkgbase "/darwinports/mpkgs/"
+ set porturl $portinfo(porturl)
+ set prefix "/opt/local"
+
+ # Skip up-to-date packages
+ if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
+ if {[info exists portinfo(name)] &&
+ [info exists portinfo(version)] &&
+ [info exists portinfo(categories)]} {
+ set portname $portinfo(name)
+ set portversion $portinfo(version)
+ set category [lindex $portinfo(categories) 0]
+ set mpkgfile ${mpkgbase}/${category}/${portname}-${portversion}.mpkg/Contents/Info.plist
+ if {[file readable $mpkgfile] && ([file mtime ${mpkgfile}] > [file mtime ${portpath}/Portfile])} {
+ puts stderr "Skipping ${portname}-${portversion}; meta-package is up to date."
+ continue
+ }
+ }
+ }
+
+ # Skipt packages which previously failed
+
+ # Building the mpkg:
+ # - create an mpkg skeleton
+ # - copy dependent pkgs into Contents/Resources directory
+
+ set portname ""
+ set portversion ""
+ set description ""
+ set long_description ""
+ set homepage ""
+ set category ""
+
+ if {[info exists portinfo(name)]} { set portname $portinfo(name) }
+ if {[info exists portinfo(version)]} { set portversion $portinfo(version) }
+ if {[info exists portinfo(description)]} { set description $portinfo(description) }
+ if {[info exists portinfo(long_description)]} { set long_description $portinfo(long_description) }
+ if {[info exists portinfo(homepage)]} { set homepage $portinfo(homepage) }
+ if {[info exists portinfo(categories)]} { set category [lindex $portinfo(categories) 0] }
+ if {[info exists portinfo(maintainers)]} { set maintainers $portinfo(maintainers) }
+
+ puts "meta-packaging ${category}/${portname}-${portversion}"
+
+ set mpkgpath "${mpkgbase}/${category}/${portname}-${portversion}.mpkg"
+
+ if {[catch {system "mkdir -p -m 0755 ${mpkgpath}/Contents/Resources"} error]} {
+ puts stderr "Internal error: $error"
+ }
+
+ # list of .pkg names for dependencies,
+ # built up by copy_package_if_available, and used in the Info.plist
+ set dependencies {}
+ set result [copy_package_if_available ${portname} $pkgbase "${mpkgpath}/Contents/Resources/"]
+ if {$result == -1} {
+ puts stderr "aborting; one or more dependencies was missing."
+ if {[catch {system "rm -R ${mpkgpath}"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ continue
+ } else {
+ set result [lsort -uniq $result]
+ eval "lappend dependencies $result"
+ }
+
+ #
+ # Begin quote from portmpkg.tcl
+ #
+ write_PkgInfo ${mpkgpath}/Contents/PkgInfo
+ mpkg_write_info_plist ${mpkgpath}/Contents/Info.plist $portname $portversion $prefix $dependencies
+ write_description_plist ${mpkgpath}/Contents/Resources/Description.plist $portname $portversion $description
+ # long_description, description, or homepage may not exist
+ foreach variable {long_description description homepage} {
+ if {![info exists $variable]} {
+ set pkg_$variable ""
+ } else {
+ set pkg_$variable [set $variable]
+ }
+ }
+ write_welcome_html ${mpkgpath}/Contents/Resources/Welcome.html $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
+ file copy -force -- /opt/local/share/darwinports/resources/port1.0/package/background.tiff \
+ ${mpkgpath}/Contents/Resources/background.tiff
+ #
+ # End quote from portmpkg.tcl
+ #
+}
+
+}
+# end foreach pname
Copied: branches/dp2mp-move/base/portmgr/packaging/packageall.tcl (from rev 24532, branches/dp2mp-move/base/portmgr/packageall.tcl)
===================================================================
--- branches/dp2mp-move/base/portmgr/packaging/packageall.tcl (rev 0)
+++ branches/dp2mp-move/base/portmgr/packaging/packageall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -0,0 +1,421 @@
+#!/usr/bin/env tclsh
+# packageall.tcl
+# $Id$
+#
+# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
+# Copyright (c) 2002 Apple Computer, Inc.
+# 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.
+
+package require darwinports
+
+# globals
+set portdir .
+
+# UI Instantiations
+array set ui_options {}
+# ui_options(ports_debug) - If set, output debugging messages.
+# ui_options(ports_verbose) - If set, output info messages (ui_info)
+# ui_options(ports_quiet) - If set, don't output "standard messages"
+
+# ui_options accessor
+proc ui_isset {val} {
+ global ui_options
+ if {[info exists ui_options($val)]} {
+ if {$ui_options($val) == "yes"} {
+ return 1
+ }
+ }
+ return 0
+}
+
+# UI Callback
+
+proc ui_prefix {priority} {
+ switch $priority {
+ debug {
+ return "DEBUG: "
+ }
+ error {
+ return "Error: "
+ }
+ warn {
+ return "Warning: "
+ }
+ default {
+ return ""
+ }
+ }
+}
+
+proc ui_channels {priority} {
+ global logfd
+ switch $priority {
+ debug {
+ if {[ui_isset ports_debug]} {
+ return {stdout}
+ } else {
+ return {}
+ }
+ }
+ info {
+ # put verbose stuff only to the log file
+ if {[ui_isset ports_verbose]} {
+ return {$logfd}
+ } else {
+ return {}
+ }
+ }
+ msg {
+ if {[ui_isset ports_quiet]} {
+ return {}
+ } else {
+ return {stdout}
+ }
+ }
+ default {
+ return {stdout}
+ }
+ }
+}
+
+proc pkg_ui_log {message} {
+ global logfd
+ if {[string length $logfd] > 0 } {
+ log_message $logfd $message
+ }
+}
+
+proc log_message {channel message} {
+ seek $channel 0 end
+ puts $channel $message
+ flush $channel
+}
+
+# Recursive bottom-up approach of building a list of dependencies.
+proc get_dependencies {portname includeBuildDeps} {
+ set result {}
+
+ if {[catch {set res [dportsearch "^$portname\$"]} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: port search failed: $error"
+ return {}
+ }
+ foreach {name array} $res {
+ array set portinfo $array
+ if {![info exists portinfo(name)] ||
+ ![info exists portinfo(version)] ||
+ ![info exists portinfo(categories)]} {
+ ui_error "Internal error: $name missing some portinfo keys"
+ continue
+ }
+
+ set portname $portinfo(name)
+ set portversion $portinfo(version)
+ set category [lindex $portinfo(categories) 0]
+
+ # Append the package itself to the result list
+ #set pkgpath ${category}/${portname}-${portversion}.pkg
+ lappend result [list $portname $portversion $category]
+
+ # Append the package's dependents to the result list
+ set depends {}
+ if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
+ if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
+ if {$includeBuildDeps != "" && [info exists portinfo(depends_build)]} {
+ eval "lappend depends $portinfo(depends_build)"
+ }
+ foreach depspec $depends {
+ set dep [lindex [split $depspec :] end]
+ set x [get_dependencies $dep $includeBuildDeps]
+ eval "lappend result $x"
+ set result [lsort -unique $result]
+ }
+ }
+ return $result
+}
+
+# Install binary packages if they've already been built. This will
+# speed up the testing, since we won't have to recompile dependencies
+# which have already been compiled.
+
+proc install_binary_if_available {dep basepath} {
+ set portname [lindex $dep 0]
+ set portversion [lindex $dep 1]
+ set category [lindex $dep 2]
+
+ set pkgpath ${basepath}/${category}/${portname}-${portversion}.pkg
+ if {[file readable $pkgpath]} {
+ ui_msg "installing binary: $pkgpath"
+ if {[catch {system "cd / && gunzip -c ${pkgpath}/Contents/Archive.pax.gz | pax -r"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: $error"
+ }
+ # Touch the receipt
+ # xxx: use some variable to describe this path
+ if {[catch {system "touch /opt/local/var/db/dports/receipts/${portname}-${portversion}.bz2"} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: $error"
+ }
+ }
+}
+
+
+# Standard procedures
+
+proc fatal args {
+ global argv0
+ puts stderr "$argv0: $args"
+ exit
+}
+
+# Main
+array set options [list]
+array set variations [list]
+# set ui_options(ports_verbose) yes
+
+if {[catch {dportinit ui_options options variations} result]} {
+ puts "Failed to initialize ports system, $result"
+ exit 1
+}
+
+package require Pextlib
+
+# If no arguments were given, default to all ports.
+if {[llength $argv] == 0} {
+ lappend argv ".*"
+}
+
+foreach pname $argv {
+
+if {[catch {set res [dportsearch "^${pname}\$"]} result]} {
+ puts "port search failed: $result"
+ exit 1
+}
+
+set logpath "/darwinports/logs"
+set logfd ""
+
+foreach {name array} $res {
+ array unset portinfo
+ array set portinfo $array
+
+ # Start with verbose output off;
+ # this will prevent the repopulation of /opt from getting logged.
+ set ui_options(ports_verbose) no
+
+ if {![info exists portinfo(porturl)]} {
+ puts stderr "Internal error: no porturl for $name"
+ continue
+ }
+
+ set pkgbase /darwinports/pkgs/
+ set porturl $portinfo(porturl)
+
+ # Skip up-to-date packages
+ if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
+ if {[info exists portinfo(name)] &&
+ [info exists portinfo(version)] &&
+ [info exists portinfo(categories)]} {
+ set portname $portinfo(name)
+ set portversion $portinfo(version)
+ set category [lindex $portinfo(categories) 0]
+ set pkgfile ${pkgbase}/${category}/${portname}-${portversion}.pkg/Contents/Archive.pax.gz
+ if {[file readable $pkgfile] && ([file mtime ${pkgfile}] > [file mtime ${portpath}/Portfile])} {
+ puts stderr "Skipping ${portname}-${portversion}; package is up to date."
+ continue
+ }
+ }
+ }
+
+ # Skipt packages which previously failed
+
+ # Building the port:
+ # - remove /opt so it won't pollute the port.
+ # - re-install DarwinPorts.
+ # - keep distfiles outside /opt so we don't have to keep fetching them.
+ # - send out an email to the maintainer if any errors occurred.
+
+ ui_msg "removing /opt"
+ #unset ui_options(ports_verbose)
+ if {[catch {system "rm -Rf /opt"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "rm -Rf /usr/X11R6"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "rm -Rf /etc/X11"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "rm -Rf /etc/fonts"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "cd $env(HOME)/darwinports && make && make install"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "rmdir /opt/local/var/db/dports/distfiles"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "ln -s /darwinports/distfiles /opt/local/var/db/dports/distfiles"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ #set ui_options(ports_verbose) yes
+
+ # If there was a log file left over from the previous pass,
+ # then the port failed with an error. Send the log in an
+ # email to the maintainers.
+ if {[string length $logfd] > 0} {
+ close $logfd
+ set logfd ""
+ }
+ #if {[file readable $logfilename]} {
+ # if {[catch {system "cat $logfilename | /usr/sbin/sendmail -t"} error]} {
+ # puts stderr "Internal error: $error"
+ # }
+ #}
+
+ # Open the log file for writing
+ set logfd [open ${logpath}/${name}.log w]
+
+ set valid 1
+
+ set lint_errors {}
+ set portname ""
+ set portversion ""
+ set description ""
+ set category ""
+
+ if {![info exists portinfo(name)]} {
+ lappend lint_errors "missing name key"
+ set valid 0
+ } else {
+ set portname $portinfo(name)
+ }
+
+ if {![info exists portinfo(description)]} {
+ lappend lint_errors "missing description key"
+ set valid 0
+ } else {
+ set description $portinfo(description)
+ }
+
+ if {![info exists portinfo(version)]} {
+ lappend lint_errors "missing version key"
+ set valid 0
+ } else {
+ set portversion $portinfo(version)
+ }
+
+ if {![info exists portinfo(categories)]} {
+ lappend lint_errors "missing categories key"
+ set valid 0
+ } else {
+ set category [lindex $portinfo(categories) 0]
+ }
+
+ if {![info exists portinfo(maintainers)]} {
+ append lint_errors "missing maintainers key"
+ set valid 0
+ set maintainers kevin at opendarwin.org
+ } else {
+ set maintainers $portinfo(maintainers)
+ }
+
+ pkg_ui_log "To: [join $maintainers {, }]"
+ pkg_ui_log "From: donotreply at opendarwin.org"
+ pkg_ui_log "Subject: DarwinPorts $portinfo(name)-$portinfo(version) build failure"
+ pkg_ui_log ""
+ pkg_ui_log "The following is a transcript produced by the DarwinPorts automated build "
+ pkg_ui_log "system. You are receiving this email because you are listed as a maintainer "
+ pkg_ui_log "of this port, which has failed the automated packaging process. Please update "
+ pkg_ui_log "the port as soon as possible."
+ pkg_ui_log ""
+ pkg_ui_log ""
+ pkg_ui_log "Thank you,"
+ pkg_ui_log "The DarwinPorts Team"
+ pkg_ui_log ""
+ pkg_ui_log "================================================================================"
+ pkg_ui_log ""
+
+ if {!$valid} {
+ foreach error $lint_errors {
+ ui_error $error
+ }
+ }
+
+ ui_msg "packaging ${category}/${portname}-${portversion}"
+
+ # Install binary dependencies if we can, to speed things up.
+ #set depends {}
+ #if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
+ #if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
+ #if {[info exists portinfo(depends_build)]} { eval "lappend depends $portinfo(depends_build)" }
+ #foreach depspec $depends {
+ # set dep [lindex [split $depspec :] end]
+ #install_binary_if_available $dep $pkgbase
+ #}
+ set dependencies [get_dependencies $portname 1]
+ set dependencies [lsort -unique $dependencies]
+ foreach dep $dependencies {
+ install_binary_if_available $dep $pkgbase
+ }
+
+ set options(package.type) pkg
+ set options(package.destpath) ${pkgbase}/${category}/
+
+ # Turn on verbose output for the build
+ set ui_options(ports_verbose) yes
+ if {[catch {set workername [dportopen $porturl [array get options] [array get variations] yes]} result] ||
+ $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: unable to open port: $result"
+ continue
+ }
+ if {[catch {set result [dportexec $workername pkg]} result] ||
+ $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "port package failed: $result"
+ dportclose $workername
+ continue
+ }
+ set ui_options(ports_verbose) no
+ # Turn verbose output off after the build
+
+ dportclose $workername
+
+ # We made it to the end. We can delete the log file.
+ close $logfd
+ set logfd ""
+ file delete ${logpath}/${name}.log
+}
+
+}
+# end foreach pname
Copied: branches/dp2mp-move/base/portmgr/packaging/rpmall.tcl (from rev 24532, branches/dp2mp-move/base/portmgr/rpmall.tcl)
===================================================================
--- branches/dp2mp-move/base/portmgr/packaging/rpmall.tcl (rev 0)
+++ branches/dp2mp-move/base/portmgr/packaging/rpmall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -0,0 +1,494 @@
+#!/usr/bin/env tclsh
+# rpmall.tcl
+# $Id$
+#
+# Copyright (c) 2003 Benjamin Reed <ranger at befunk.com>
+# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
+# Copyright (c) 2002 Apple Computer, Inc.
+# 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.
+
+package require darwinports
+
+# globals
+set portdir .
+
+# UI Instantiations
+array set ui_options {}
+# ui_options(ports_debug) - If set, output debugging messages.
+# ui_options(ports_verbose) - If set, output info messages (ui_info)
+# ui_options(ports_quiet) - If set, don't output "standard messages"
+
+# ui_options accessor
+proc ui_isset {val} {
+ global ui_options
+ if {[info exists ui_options($val)]} {
+ if {$ui_options($val) == "yes"} {
+ return 1
+ }
+ }
+ return 0
+}
+
+set options(package.destpath) "/darwinports/rpms"
+
+# UI Callback
+
+proc ui_prefix {priority} {
+ switch $priority {
+ debug {
+ return "DEBUG: "
+ }
+ error {
+ return "Error: "
+ }
+ warn {
+ return "Warning: "
+ }
+ default {
+ return ""
+ }
+ }
+}
+
+proc ui_channels {priority} {
+ global logfd
+ switch $priority {
+ debug {
+ if {[ui_isset ports_debug]} {
+ return {stdout}
+ } else {
+ return {}
+ }
+ }
+ info {
+ # put verbose stuff only to the log file
+ if {[ui_isset ports_verbose]} {
+ return {$logfd}
+ } else {
+ return {}
+ }
+ }
+ msg {
+ if {[ui_isset ports_quiet]} {
+ return {}
+ } else {
+ return {stdout}
+ }
+ }
+ default {
+ return {stdout}
+ }
+ }
+}
+
+proc pkg_ui_log {message} {
+ global logfd
+ if {[string length $logfd] > 0 } {
+ log_message $logfd $message
+ }
+}
+
+proc log_message {channel message} {
+ seek $channel 0 end
+ puts $channel $message
+ flush $channel
+}
+
+# Recursive bottom-up approach of building a list of dependencies.
+proc get_dependencies {portname includeBuildDeps} {
+ set result {}
+
+ if {[catch {set search [dportsearch "^$portname\$"]} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: port search failed: $error"
+ return {}
+ }
+ foreach {name array} $search {
+ array set portinfo $array
+ if {![info exists portinfo(name)] ||
+ ![info exists portinfo(version)] ||
+ ![info exists portinfo(categories)]} {
+ ui_error "Internal error: $name missing some portinfo keys"
+ continue
+ }
+ if {![info exists portinfo(revision)]} {
+ set portinfo(revision) 0
+ }
+
+ set portname $portinfo(name)
+ set portversion $portinfo(version)
+ set revision $portinfo(revision)
+
+ # Append the package itself to the result list
+ lappend result [list $portname $portversion $revision]
+
+ # Append the package's dependents to the result list
+ set depends {}
+ if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
+ if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
+ if {$includeBuildDeps != "" && [info exists portinfo(depends_build)]} {
+ eval "lappend depends $portinfo(depends_build)"
+ }
+ foreach depspec $depends {
+ set dep [lindex [split $depspec :] end]
+ set x [get_dependencies $dep $includeBuildDeps]
+ eval "lappend result $x"
+ set result [lsort -unique $result]
+ }
+ }
+ return $result
+}
+
+# Install binary packages if they've already been built. This will
+# speed up the testing, since we won't have to recompile dependencies
+# which have already been compiled.
+
+proc install_binary_if_available {dep} {
+ set portname [lindex $dep 0]
+ set portversion [lindex $dep 1]
+ set revision [lindex $dep 2]
+
+ foreach dir {"${prefix}/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
+ foreach arch {"ppc" "i386" "fat"} {
+ set rpmpath "${dir}/${arch}/${portname}-${portversion}-${revision}.${arch}.rpm"
+ if {[file readable $rpmpath]} {
+ ui_msg "Installing binary: $rpmpath"
+ if {[catch {system "rpm -Uvh --force $rpmpath"} error ]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: $error"
+ } else {
+ return true
+ }
+ }
+ }
+ }
+ return false
+}
+
+
+# Standard procedures
+
+proc fatal args {
+ global argv0
+ puts stderr "$argv0: $args"
+ exit
+}
+
+# Main
+array set options [list]
+array set variations [list]
+
+# set ui_options(ports_verbose) yes
+if {![file exists /usr/bin/sw_vers]} {
+ set variations(puredarwin) "+"
+}
+
+if {[catch {dportinit ui_options options variations} result]} {
+ puts "Failed to initialize ports system, $result"
+ exit 1
+}
+
+package require Pextlib
+
+# If no arguments were given, default to all ports.
+if {[llength $argv] == 0} {
+ lappend argv ".*"
+}
+
+foreach pname $argv {
+
+if {[catch {set allpackages [dportsearch "^${pname}\$"]} result]} {
+ puts "port search failed: $result"
+ exit 1
+}
+
+set logpath "/darwinports/logs"
+set logfd ""
+
+foreach {name array} $allpackages {
+ array unset portinfo
+ array set portinfo $array
+
+ #ui_msg "foo $portinfo(porturl)"
+
+ # Start with verbose output off;
+ # this will prevent the repopulation of /opt from getting logged.
+ set ui_options(ports_verbose) no
+
+ if {![info exists portinfo(porturl)]} {
+ puts stderr "Internal error: no porturl for $name"
+ continue
+ }
+ if {![info exists portinfo(revision)]} {
+ set portinfo(revision) 0
+ }
+
+ set porturl $portinfo(porturl)
+
+ # this is used to short-circuit the RPM check and
+ # move on to the next package
+
+ global exit_loop
+ set exit_loop false
+
+ # Skip up-to-date packages
+ if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
+ if {[info exists portinfo(name)] &&
+ [info exists portinfo(version)] &&
+ [info exists portinfo(revision)]} {
+ set portname $portinfo(name)
+ set portversion $portinfo(version)
+ set revision $portinfo(revision)
+
+ foreach dir {"/opt/local/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
+ foreach arch {"ppc" "i386" "fat"} {
+ set rpmpath "${dir}/${arch}/${portname}-${portversion}-${revision}.${arch}.rpm"
+ #ui_msg "trying ${rpmpath}"
+ if {[file readable $rpmpath] && ([file mtime ${rpmpath}] >= [file mtime ${portpath}/Portfile])} {
+ puts stderr "-> skipping ${portname}-${portversion}; package is up to date."
+ set exit_loop true
+ break
+ }
+ }
+ if {${exit_loop}} {
+ break
+ }
+ }
+ }
+ }
+ if {${exit_loop}} {
+ continue
+ }
+
+ # Skip packages which previously failed
+ set exit_loop false
+
+ # Skip up-to-date packages
+ if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
+ if {[info exists portinfo(name)] &&
+ [info exists portinfo(version)] &&
+ [info exists portinfo(revision)]} {
+ set portname $portinfo(name)
+ set portversion $portinfo(version)
+ set revision $portinfo(revision)
+
+ set logfilepath "${logpath}/${portname}.log"
+ if {[file readable ${logfilepath}] && ([file mtime ${logfilepath}] > [file mtime ${portpath}/Portfile])} {
+ puts stderr "-> skipping ${portname}-${portversion}; package failed, but has not changed."
+ set exit_loop true
+ }
+ }
+ }
+ if {${exit_loop}} {
+ continue
+ }
+
+ # Building the port:
+ # - remove /opt so it won't pollute the port.
+ # - re-install DarwinPorts.
+ # - keep distfiles outside /opt so we don't have to keep fetching them.
+ # - send out an email to the maintainer if any errors occurred.
+
+ set remove_files ""
+ foreach dir {"/opt/local/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
+ foreach arch {"ppc" "i386" "fat"} {
+ set remove_files "${remove_files} '${dir}/${arch}/'*.rpm"
+ }
+ }
+ system "rpm -q --queryformat='%{name} ' -p ${remove_files} | xargs rpm -e || true"
+
+ ui_msg "-> Removing /opt"
+ #unset ui_options(ports_verbose)
+ if {[catch {system "rm -Rf /opt"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ # this is bad on pure darwin :)
+ #if {[catch {system "rm -Rf /usr/X11R6"} error]} {
+ # puts stderr "Internal error: $error"
+ #}
+ #if {[catch {system "rm -Rf /etc/X11"} error]} {
+ # puts stderr "Internal error: $error"
+ #}
+ #if {[catch {system "rm -Rf /etc/fonts"} error]} {
+ # puts stderr "Internal error: $error"
+ #}
+ ui_msg "-> Installing darwinports"
+ if {[catch {system "cd $env(HOME)/darwinports && make && make install"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "rmdir /opt/local/var/db/dports/distfiles"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ if {[catch {system "ln -s /darwinports/distfiles /opt/local/var/db/dports/distfiles"} error]} {
+ puts stderr "Internal error: $error"
+ }
+ #set ui_options(ports_verbose) yes
+
+ # If there was a log file left over from the previous pass,
+ # then the port failed with an error. Send the log in an
+ # email to the maintainers.
+ if {[string length $logfd] > 0} {
+ close $logfd
+ set logfd ""
+ }
+ #if {[file readable $logfilename]} {
+ # if {[catch {system "cat $logfilename | /usr/sbin/sendmail -t"} error]} {
+ # puts stderr "Internal error: $error"
+ # }
+ #}
+
+ # Open the log file for writing
+ set logfd [open ${logpath}/${name}.log w]
+
+ set valid 1
+
+ set lint_errors {}
+ set portname ""
+ set portversion ""
+ set description ""
+ set category ""
+
+ if {![info exists portinfo(name)]} {
+ lappend lint_errors "missing name key"
+ set valid 0
+ } else {
+ set portname $portinfo(name)
+ }
+
+ if {![info exists portinfo(description)]} {
+ lappend lint_errors "missing description key"
+ set valid 0
+ } else {
+ set description $portinfo(description)
+ }
+
+ if {![info exists portinfo(version)]} {
+ lappend lint_errors "missing version key"
+ set valid 0
+ } else {
+ set portversion $portinfo(version)
+ }
+
+ if {![info exists portinfo(categories)]} {
+ lappend lint_errors "missing categories key"
+ set valid 0
+ } else {
+ set category [lindex $portinfo(categories) 0]
+ }
+
+ if {![info exists portinfo(maintainers)]} {
+ append lint_errors "missing maintainers key"
+ set valid 0
+ set maintainers kevin at opendarwin.org
+ } else {
+ set maintainers $portinfo(maintainers)
+ }
+
+ pkg_ui_log "To: [join $maintainers {, }]"
+ pkg_ui_log "From: donotreply at opendarwin.org"
+ pkg_ui_log "Subject: DarwinPorts $portinfo(name)-$portinfo(version) build failure"
+ pkg_ui_log ""
+ pkg_ui_log "The following is a transcript produced by the DarwinPorts automated build "
+ pkg_ui_log "system. You are receiving this email because you are listed as a maintainer "
+ pkg_ui_log "of this port, which has failed the automated packaging process. Please update "
+ pkg_ui_log "the port as soon as possible."
+ pkg_ui_log ""
+ pkg_ui_log ""
+ pkg_ui_log "Thank you,"
+ pkg_ui_log "The DarwinPorts Team"
+ pkg_ui_log ""
+ pkg_ui_log "================================================================================"
+ pkg_ui_log ""
+
+ if {!$valid} {
+ foreach error $lint_errors {
+ ui_error $error
+ }
+ }
+
+ ui_msg "--> Packaging ${category}/${portname}-${portversion}"
+
+ foreach prebuild {"ccache" "rpm" "unzip"} {
+ if {![file exists /bin/${prebuild}] && ![file exists /usr/bin/${prebuild}]} {
+ ui_msg "---> Pre-installing ${prebuild}"
+ if {[catch {set search [dportsearch "^${prebuild}\$"]} error]} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: port search ${prebuild} failed: $error"
+ }
+ array set prebuildinfo [lindex $search 1]
+ set ui_options(ports_verbose) yes
+ if {[catch {set workername [dportopen $prebuildinfo(porturl) [array get options] [array get variations] yes]} result] ||
+ $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: unable to install ${prebuild}... exiting"
+ exit 1
+ }
+ if {[catch {set result [dportexec $workername install]} result] ||
+ $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "installation of ${prebuild} failed: $result"
+ dportclose $workername
+ exit 1
+ }
+ }
+ }
+
+ # Turn on verbose output for the build
+ set ui_options(ports_verbose) yes
+ if {[catch {set workername [dportopen $porturl [array get options] [array get variations]]} result] ||
+ $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "Internal error: unable to open port: $result"
+ continue
+ }
+ if {[catch {set result [dportexec $workername rpmpackage]} result] ||
+ $result == 1} {
+ global errorInfo
+ ui_debug "$errorInfo"
+ ui_error "port package failed: $result"
+ dportclose $workername
+ continue
+ }
+ set ui_options(ports_verbose) no
+ # Turn verbose output off after the build
+
+ dportclose $workername
+
+ # We made it to the end. We can delete the log file.
+ close $logfd
+ set logfd ""
+ file delete ${logpath}/${name}.log
+}
+
+}
+# end foreach pname
Deleted: branches/dp2mp-move/base/portmgr/rpmall.tcl
===================================================================
--- branches/dp2mp-move/base/portmgr/rpmall.tcl 2007-05-07 02:56:13 UTC (rev 24868)
+++ branches/dp2mp-move/base/portmgr/rpmall.tcl 2007-05-07 03:01:42 UTC (rev 24869)
@@ -1,494 +0,0 @@
-#!/usr/bin/env tclsh
-# rpmall.tcl
-# $Id$
-#
-# Copyright (c) 2003 Benjamin Reed <ranger at befunk.com>
-# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
-# 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.
-
-package require darwinports
-
-# globals
-set portdir .
-
-# UI Instantiations
-array set ui_options {}
-# ui_options(ports_debug) - If set, output debugging messages.
-# ui_options(ports_verbose) - If set, output info messages (ui_info)
-# ui_options(ports_quiet) - If set, don't output "standard messages"
-
-# ui_options accessor
-proc ui_isset {val} {
- global ui_options
- if {[info exists ui_options($val)]} {
- if {$ui_options($val) == "yes"} {
- return 1
- }
- }
- return 0
-}
-
-set options(package.destpath) "/darwinports/rpms"
-
-# UI Callback
-
-proc ui_prefix {priority} {
- switch $priority {
- debug {
- return "DEBUG: "
- }
- error {
- return "Error: "
- }
- warn {
- return "Warning: "
- }
- default {
- return ""
- }
- }
-}
-
-proc ui_channels {priority} {
- global logfd
- switch $priority {
- debug {
- if {[ui_isset ports_debug]} {
- return {stdout}
- } else {
- return {}
- }
- }
- info {
- # put verbose stuff only to the log file
- if {[ui_isset ports_verbose]} {
- return {$logfd}
- } else {
- return {}
- }
- }
- msg {
- if {[ui_isset ports_quiet]} {
- return {}
- } else {
- return {stdout}
- }
- }
- default {
- return {stdout}
- }
- }
-}
-
-proc pkg_ui_log {message} {
- global logfd
- if {[string length $logfd] > 0 } {
- log_message $logfd $message
- }
-}
-
-proc log_message {channel message} {
- seek $channel 0 end
- puts $channel $message
- flush $channel
-}
-
-# Recursive bottom-up approach of building a list of dependencies.
-proc get_dependencies {portname includeBuildDeps} {
- set result {}
-
- if {[catch {set search [dportsearch "^$portname\$"]} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: port search failed: $error"
- return {}
- }
- foreach {name array} $search {
- array set portinfo $array
- if {![info exists portinfo(name)] ||
- ![info exists portinfo(version)] ||
- ![info exists portinfo(categories)]} {
- ui_error "Internal error: $name missing some portinfo keys"
- continue
- }
- if {![info exists portinfo(revision)]} {
- set portinfo(revision) 0
- }
-
- set portname $portinfo(name)
- set portversion $portinfo(version)
- set revision $portinfo(revision)
-
- # Append the package itself to the result list
- lappend result [list $portname $portversion $revision]
-
- # Append the package's dependents to the result list
- set depends {}
- if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
- if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
- if {$includeBuildDeps != "" && [info exists portinfo(depends_build)]} {
- eval "lappend depends $portinfo(depends_build)"
- }
- foreach depspec $depends {
- set dep [lindex [split $depspec :] end]
- set x [get_dependencies $dep $includeBuildDeps]
- eval "lappend result $x"
- set result [lsort -unique $result]
- }
- }
- return $result
-}
-
-# Install binary packages if they've already been built. This will
-# speed up the testing, since we won't have to recompile dependencies
-# which have already been compiled.
-
-proc install_binary_if_available {dep} {
- set portname [lindex $dep 0]
- set portversion [lindex $dep 1]
- set revision [lindex $dep 2]
-
- foreach dir {"${prefix}/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
- foreach arch {"ppc" "i386" "fat"} {
- set rpmpath "${dir}/${arch}/${portname}-${portversion}-${revision}.${arch}.rpm"
- if {[file readable $rpmpath]} {
- ui_msg "Installing binary: $rpmpath"
- if {[catch {system "rpm -Uvh --force $rpmpath"} error ]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: $error"
- } else {
- return true
- }
- }
- }
- }
- return false
-}
-
-
-# Standard procedures
-
-proc fatal args {
- global argv0
- puts stderr "$argv0: $args"
- exit
-}
-
-# Main
-array set options [list]
-array set variations [list]
-
-# set ui_options(ports_verbose) yes
-if {![file exists /usr/bin/sw_vers]} {
- set variations(puredarwin) "+"
-}
-
-if {[catch {dportinit ui_options options variations} result]} {
- puts "Failed to initialize ports system, $result"
- exit 1
-}
-
-package require Pextlib
-
-# If no arguments were given, default to all ports.
-if {[llength $argv] == 0} {
- lappend argv ".*"
-}
-
-foreach pname $argv {
-
-if {[catch {set allpackages [dportsearch "^${pname}\$"]} result]} {
- puts "port search failed: $result"
- exit 1
-}
-
-set logpath "/darwinports/logs"
-set logfd ""
-
-foreach {name array} $allpackages {
- array unset portinfo
- array set portinfo $array
-
- #ui_msg "foo $portinfo(porturl)"
-
- # Start with verbose output off;
- # this will prevent the repopulation of /opt from getting logged.
- set ui_options(ports_verbose) no
-
- if {![info exists portinfo(porturl)]} {
- puts stderr "Internal error: no porturl for $name"
- continue
- }
- if {![info exists portinfo(revision)]} {
- set portinfo(revision) 0
- }
-
- set porturl $portinfo(porturl)
-
- # this is used to short-circuit the RPM check and
- # move on to the next package
-
- global exit_loop
- set exit_loop false
-
- # Skip up-to-date packages
- if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
- if {[info exists portinfo(name)] &&
- [info exists portinfo(version)] &&
- [info exists portinfo(revision)]} {
- set portname $portinfo(name)
- set portversion $portinfo(version)
- set revision $portinfo(revision)
-
- foreach dir {"/opt/local/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
- foreach arch {"ppc" "i386" "fat"} {
- set rpmpath "${dir}/${arch}/${portname}-${portversion}-${revision}.${arch}.rpm"
- #ui_msg "trying ${rpmpath}"
- if {[file readable $rpmpath] && ([file mtime ${rpmpath}] >= [file mtime ${portpath}/Portfile])} {
- puts stderr "-> skipping ${portname}-${portversion}; package is up to date."
- set exit_loop true
- break
- }
- }
- if {${exit_loop}} {
- break
- }
- }
- }
- }
- if {${exit_loop}} {
- continue
- }
-
- # Skip packages which previously failed
- set exit_loop false
-
- # Skip up-to-date packages
- if {[regsub {^file://} $portinfo(porturl) "" portpath]} {
- if {[info exists portinfo(name)] &&
- [info exists portinfo(version)] &&
- [info exists portinfo(revision)]} {
- set portname $portinfo(name)
- set portversion $portinfo(version)
- set revision $portinfo(revision)
-
- set logfilepath "${logpath}/${portname}.log"
- if {[file readable ${logfilepath}] && ([file mtime ${logfilepath}] > [file mtime ${portpath}/Portfile])} {
- puts stderr "-> skipping ${portname}-${portversion}; package failed, but has not changed."
- set exit_loop true
- }
- }
- }
- if {${exit_loop}} {
- continue
- }
-
- # Building the port:
- # - remove /opt so it won't pollute the port.
- # - re-install DarwinPorts.
- # - keep distfiles outside /opt so we don't have to keep fetching them.
- # - send out an email to the maintainer if any errors occurred.
-
- set remove_files ""
- foreach dir {"/opt/local/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
- foreach arch {"ppc" "i386" "fat"} {
- set remove_files "${remove_files} '${dir}/${arch}/'*.rpm"
- }
- }
- system "rpm -q --queryformat='%{name} ' -p ${remove_files} | xargs rpm -e || true"
-
- ui_msg "-> Removing /opt"
- #unset ui_options(ports_verbose)
- if {[catch {system "rm -Rf /opt"} error]} {
- puts stderr "Internal error: $error"
- }
- # this is bad on pure darwin :)
- #if {[catch {system "rm -Rf /usr/X11R6"} error]} {
- # puts stderr "Internal error: $error"
- #}
- #if {[catch {system "rm -Rf /etc/X11"} error]} {
- # puts stderr "Internal error: $error"
- #}
- #if {[catch {system "rm -Rf /etc/fonts"} error]} {
- # puts stderr "Internal error: $error"
- #}
- ui_msg "-> Installing darwinports"
- if {[catch {system "cd $env(HOME)/darwinports && make && make install"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "rmdir /opt/local/var/db/dports/distfiles"} error]} {
- puts stderr "Internal error: $error"
- }
- if {[catch {system "ln -s /darwinports/distfiles /opt/local/var/db/dports/distfiles"} error]} {
- puts stderr "Internal error: $error"
- }
- #set ui_options(ports_verbose) yes
-
- # If there was a log file left over from the previous pass,
- # then the port failed with an error. Send the log in an
- # email to the maintainers.
- if {[string length $logfd] > 0} {
- close $logfd
- set logfd ""
- }
- #if {[file readable $logfilename]} {
- # if {[catch {system "cat $logfilename | /usr/sbin/sendmail -t"} error]} {
- # puts stderr "Internal error: $error"
- # }
- #}
-
- # Open the log file for writing
- set logfd [open ${logpath}/${name}.log w]
-
- set valid 1
-
- set lint_errors {}
- set portname ""
- set portversion ""
- set description ""
- set category ""
-
- if {![info exists portinfo(name)]} {
- lappend lint_errors "missing name key"
- set valid 0
- } else {
- set portname $portinfo(name)
- }
-
- if {![info exists portinfo(description)]} {
- lappend lint_errors "missing description key"
- set valid 0
- } else {
- set description $portinfo(description)
- }
-
- if {![info exists portinfo(version)]} {
- lappend lint_errors "missing version key"
- set valid 0
- } else {
- set portversion $portinfo(version)
- }
-
- if {![info exists portinfo(categories)]} {
- lappend lint_errors "missing categories key"
- set valid 0
- } else {
- set category [lindex $portinfo(categories) 0]
- }
-
- if {![info exists portinfo(maintainers)]} {
- append lint_errors "missing maintainers key"
- set valid 0
- set maintainers kevin at opendarwin.org
- } else {
- set maintainers $portinfo(maintainers)
- }
-
- pkg_ui_log "To: [join $maintainers {, }]"
- pkg_ui_log "From: donotreply at opendarwin.org"
- pkg_ui_log "Subject: DarwinPorts $portinfo(name)-$portinfo(version) build failure"
- pkg_ui_log ""
- pkg_ui_log "The following is a transcript produced by the DarwinPorts automated build "
- pkg_ui_log "system. You are receiving this email because you are listed as a maintainer "
- pkg_ui_log "of this port, which has failed the automated packaging process. Please update "
- pkg_ui_log "the port as soon as possible."
- pkg_ui_log ""
- pkg_ui_log ""
- pkg_ui_log "Thank you,"
- pkg_ui_log "The DarwinPorts Team"
- pkg_ui_log ""
- pkg_ui_log "================================================================================"
- pkg_ui_log ""
-
- if {!$valid} {
- foreach error $lint_errors {
- ui_error $error
- }
- }
-
- ui_msg "--> Packaging ${category}/${portname}-${portversion}"
-
- foreach prebuild {"ccache" "rpm" "unzip"} {
- if {![file exists /bin/${prebuild}] && ![file exists /usr/bin/${prebuild}]} {
- ui_msg "---> Pre-installing ${prebuild}"
- if {[catch {set search [dportsearch "^${prebuild}\$"]} error]} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: port search ${prebuild} failed: $error"
- }
- array set prebuildinfo [lindex $search 1]
- set ui_options(ports_verbose) yes
- if {[catch {set workername [dportopen $prebuildinfo(porturl) [array get options] [array get variations] yes]} result] ||
- $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: unable to install ${prebuild}... exiting"
- exit 1
- }
- if {[catch {set result [dportexec $workername install]} result] ||
- $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "installation of ${prebuild} failed: $result"
- dportclose $workername
- exit 1
- }
- }
- }
-
- # Turn on verbose output for the build
- set ui_options(ports_verbose) yes
- if {[catch {set workername [dportopen $porturl [array get options] [array get variations]]} result] ||
- $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "Internal error: unable to open port: $result"
- continue
- }
- if {[catch {set result [dportexec $workername rpmpackage]} result] ||
- $result == 1} {
- global errorInfo
- ui_debug "$errorInfo"
- ui_error "port package failed: $result"
- dportclose $workername
- continue
- }
- set ui_options(ports_verbose) no
- # Turn verbose output off after the build
-
- dportclose $workername
-
- # We made it to the end. We can delete the log file.
- close $logfd
- set logfd ""
- file delete ${logpath}/${name}.log
-}
-
-}
-# end foreach pname
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070506/dbc12ad0/attachment.html
More information about the macports-changes
mailing list