[91009] trunk/base
jmr at macports.org
jmr at macports.org
Wed Mar 21 08:39:28 PDT 2012
Revision: 91009
https://trac.macports.org/changeset/91009
Author: jmr at macports.org
Date: 2012-03-21 08:39:24 -0700 (Wed, 21 Mar 2012)
Log Message:
-----------
Archive fetch improvements:
* Added a config file to allow using custom archive sites
* An archive type is associated with each group of sites; portarchivetype is now only used for locally creating archives
* A frameworks_dir and applications_dir are associated with each group of sites as well as a prefix; sites are excluded when they don't match the current values
Modified Paths:
--------------
trunk/base/doc/Makefile
trunk/base/portmgr/dmg/postflight
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/package1.0/portarchivefetch.tcl
Added Paths:
-----------
trunk/base/doc/archive_sites.conf
Modified: trunk/base/doc/Makefile
===================================================================
--- trunk/base/doc/Makefile 2012-03-21 15:08:20 UTC (rev 91008)
+++ trunk/base/doc/Makefile 2012-03-21 15:39:24 UTC (rev 91009)
@@ -1,7 +1,7 @@
MAN1= port.1
MAN5= macports.conf.5
MAN7= portfile.7 portstyle.7 porthier.7 portgroup.7
-CONF= macports.conf pubkeys.conf sources.conf variants.conf
+CONF= archive_sites.conf macports.conf pubkeys.conf sources.conf variants.conf
INSTALLDIR= ${DESTDIR}${prefix}
TOPSRCDIR= ..
Added: trunk/base/doc/archive_sites.conf
===================================================================
--- trunk/base/doc/archive_sites.conf (rev 0)
+++ trunk/base/doc/archive_sites.conf 2012-03-21 15:39:24 UTC (rev 91009)
@@ -0,0 +1,27 @@
+# Configuration for (binary) archive sources.
+# $Id$
+
+# Each entry is started by a name line. The only required values are name and
+# urls. Other fields are type, prefix, applications_dir and frameworks_dir,
+# which have the usual default values:
+# type tbz2
+# prefix /opt/local
+# applications_dir /Applications/MacPorts
+# frameworks_dir ${prefix}/Library/Frameworks
+#
+# type can be any of: tgz, tar, tbz, tbz2, tlz, txz, xar, zip, cpgz, cpio
+# Note that some types require a corresponding tool to be installed, and
+# entries with an unsupported type will not be used.
+
+# Example:
+#name mysource
+#urls http://example.com/ ftp://ftp.example.org/
+#type tbz2
+#prefix /opt/mysource
+#applications_dir /opt/mysource/Applications
+#frameworks_dir /opt/mysource/Library/Frameworks
+
+# If you want to disable use of the archive sites listed in the ports tree,
+# you could do this:
+#name macports_archives
+#urls
Property changes on: trunk/base/doc/archive_sites.conf
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/base/portmgr/dmg/postflight
===================================================================
--- trunk/base/portmgr/dmg/postflight 2012-03-21 15:08:20 UTC (rev 91008)
+++ trunk/base/portmgr/dmg/postflight 2012-03-21 15:39:24 UTC (rev 91009)
@@ -36,7 +36,7 @@
#set -x
# Script identification ('cause more often than not the svn Id is not expanded):
-VERSION=2.0.0
+VERSION=2.0.99
# Abstraction variables:
PREFIX=__PREFIX__
@@ -56,7 +56,7 @@
# Create config files from defaults if not present
function setup_configs {
- for f in macports.conf pubkeys.conf sources.conf variants.conf ; do
+ for f in archive_sites.conf macports.conf pubkeys.conf sources.conf variants.conf ; do
if [[ ! -f ${CONFIGPATH}/${f} ]]; then
echo "Copying ${f}.default to ${f}"
/bin/cp ${CONFIGPATH}/${f}.default ${CONFIGPATH}/${f}
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2012-03-21 15:08:20 UTC (rev 91008)
+++ trunk/base/src/macports1.0/macports.tcl 2012-03-21 15:39:24 UTC (rev 91009)
@@ -1294,6 +1294,9 @@
$workername alias get_pingtime macports::get_pingtime
$workername alias set_pingtime macports::set_pingtime
+ # archive_sites.conf handling
+ $workername alias get_archive_sites_conf_values macports::get_archive_sites_conf_values
+
foreach opt $portinterp_options {
if {![info exists $opt]} {
global macports::$opt
@@ -4547,3 +4550,66 @@
global macports::ping_cache
set ping_cache($host) [list $ms [clock seconds]]
}
+
+# read and cache archive_sites.conf (called from port1.0 code)
+proc macports::get_archive_sites_conf_values {} {
+ global macports::archive_sites_conf_values macports::autoconf::macports_conf_path
+ if {![info exists archive_sites_conf_values]} {
+ set archive_sites_conf_values {}
+ set all_names {}
+ array set defaults {applications_dir /Applications/MacPorts prefix /opt/local type tbz2}
+ set conf_file "${macports_conf_path}/archive_sites.conf"
+ set conf_options {applications_dir frameworks_dir name prefix type urls}
+ if {[file isfile $conf_file]} {
+ set fd [open $conf_file r]
+ while {[gets $fd line] >= 0} {
+ if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
+ if {[lsearch -exact $conf_options $option] >= 0} {
+ if {$option == "name"} {
+ set cur_name $val
+ lappend all_names $val
+ } elseif {[info exists cur_name]} {
+ set trimmedval [string trim $val]
+ if {$option == "urls"} {
+ set processed_urls {}
+ foreach url $trimmedval {
+ lappend processed_urls ${url}:nosubdir
+ }
+ lappend archive_sites_conf_values portfetch::mirror_sites::sites($cur_name) $processed_urls
+ set sites($cur_name) $processed_urls
+ } else {
+ lappend archive_sites_conf_values portfetch::mirror_sites::archive_${option}($cur_name) $trimmedval
+ set archive_${option}($cur_name) $trimmedval
+ }
+ } else {
+ ui_warn "archive_sites.conf: ignoring '$option' occurring before name"
+ }
+ } else {
+ ui_warn "archive_sites.conf: ignoring unknown key '$option'"
+ }
+ }
+ }
+ close $fd
+
+ # check for unspecified values and set to defaults
+ foreach cur_name $all_names {
+ foreach key [array names defaults] {
+ if {![info exists archive_${key}($cur_name)]} {
+ set archive_${key}($cur_name) $defaults($key)
+ lappend archive_sites_conf_values portfetch::mirror_sites::archive_${key}($cur_name) $defaults($key)
+ }
+ }
+ if {![info exists archive_frameworks_dir($cur_name)]} {
+ set archive_frameworks_dir($cur_name) $archive_prefix($cur_name)/Library/Frameworks
+ lappend archive_sites_conf_values portfetch::mirror_sites::archive_frameworks_dir($cur_name) $archive_frameworks_dir($cur_name)
+ }
+ if {![info exists sites($cur_name)]} {
+ ui_warn "archive_sites.conf: no urls set for $cur_name"
+ set sites($cur_name) ""
+ lappend archive_sites_conf_values portfetch::mirror_sites::sites($cur_name) ""
+ }
+ }
+ }
+ }
+ return $archive_sites_conf_values
+}
Modified: trunk/base/src/package1.0/portarchivefetch.tcl
===================================================================
--- trunk/base/src/package1.0/portarchivefetch.tcl 2012-03-21 15:08:20 UTC (rev 91008)
+++ trunk/base/src/package1.0/portarchivefetch.tcl 2012-03-21 15:39:24 UTC (rev 91009)
@@ -36,7 +36,7 @@
package require Pextlib 1.0
set org.macports.archivefetch [target_new org.macports.archivefetch portarchivefetch::archivefetch_main]
-target_init ${org.macports.archivefetch} portarchivefetch::archivefetch_init
+#target_init ${org.macports.archivefetch} portarchivefetch::archivefetch_init
target_provides ${org.macports.archivefetch} archivefetch
target_requires ${org.macports.archivefetch} main
target_prerun ${org.macports.archivefetch} portarchivefetch::archivefetch_start
@@ -65,19 +65,32 @@
default archive.subdir {${subport}}
proc portarchivefetch::filter_sites {} {
- global prefix porturl
+ global prefix frameworks_dir applications_dir porturl
+
+ # get defaults from ports tree resources
set mirrorfile [get_full_archive_sites_path]
if {[file exists $mirrorfile]} {
source $mirrorfile
}
+ # get archive_sites.conf values
+ foreach {key val} [get_archive_sites_conf_values] {
+ set $key $val
+ }
+
set ret {}
foreach site [array names portfetch::mirror_sites::archive_prefix] {
- if {$portfetch::mirror_sites::archive_prefix($site) == $prefix} {
- lappend ret $site
+ if {$portfetch::mirror_sites::archive_prefix($site) == $prefix &&
+ $portfetch::mirror_sites::archive_frameworks_dir($site) == $frameworks_dir &&
+ $portfetch::mirror_sites::archive_applications_dir($site) == $applications_dir &&
+ ![catch {archiveTypeIsSupported $portfetch::mirror_sites::archive_type($site)}]} {
+ # using the archive type as a tag
+ lappend ret ${site}::$portfetch::mirror_sites::archive_type($site)
}
}
- if {[file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]]} {
- lappend ret [string range $porturl 0 end-[string length [file tail $porturl]]]
+
+ # check if porturl itself points to an archive
+ if {[file rootname [file tail $porturl]] == [file rootname [get_portimage_name]] && [file extension $porturl] != ""} {
+ lappend ret [string range $porturl 0 end-[string length [file tail $porturl]]]:[string range [file extension $porturl] 1 end]
archive.subdir
}
return $ret
@@ -87,21 +100,22 @@
# Checks possible archive files to assemble url lists for later fetching
proc portarchivefetch::checkarchivefiles {urls} {
- global all_archive_files archivefetch.fulldestpath portarchivetype \
- version revision portvariants archive_sites
+ global all_archive_files archivefetch.fulldestpath archive_sites
upvar $urls fetch_urls
- # throws an error if unsupported
- archiveTypeIsSupported $portarchivetype
-
# Define archive directory path
set archivefetch.fulldestpath [file join [option portdbpath] incoming/verified]
- set archive.file [get_portimage_name]
- set archive.path [file join ${archivefetch.fulldestpath} ${archive.file}]
+ set archive.rootname [file rootname [get_portimage_name]]
- lappend all_archive_files ${archive.file}
- if {[info exists archive_sites]} {
- lappend fetch_urls archive_sites ${archive.file}
+ foreach entry [option archive_sites] {
+ # the archive type is used as a tag
+ set type [lindex [split $entry :] end]
+ if {![info exists seen($type)]} {
+ set archive.file "${archive.rootname}.${type}"
+ lappend all_archive_files ${archive.file}
+ lappend fetch_urls $type ${archive.file}
+ set seen($type) 1
+ }
}
}
@@ -229,9 +243,11 @@
}
file delete -force $signature
set archive_exists 1
+ break
}
} else {
set archive_exists 1
+ break
}
}
if {[info exists archive_exists]} {
@@ -250,14 +266,9 @@
}
# Initialize archivefetch target and call checkfiles.
-proc portarchivefetch::archivefetch_init {args} {
- global porturl portarchivetype
- # installing straight from a binary archive
- if {[file rootname [file tail $porturl]] == [file rootname [get_portimage_name]] && [file extension $porturl] != ""} {
- set portarchivetype [string range [file extension $porturl] 1 end]
- }
- return 0
-}
+#proc portarchivefetch::archivefetch_init {args} {
+# return 0
+#}
proc portarchivefetch::archivefetch_start {args} {
variable archivefetch_urls
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120321/f294bb77/attachment.html>
More information about the macports-changes
mailing list