mirror of
https://github.com/macports/mpbb.git
synced 2026-07-12 18:18:44 -07:00
mpbb list-subports: check for archives from Tcl
This has several performance benefits: * MacPorts only has to be started up once * Each portfile only has to be parsed at most once * libcurl can keep the connection open and reuse it
This commit is contained in:
@@ -94,6 +94,9 @@ Subcommand scripts may use but not modify these global shell parameters:
|
||||
- `$option_failcache_dir`:
|
||||
A directory for storing information about previously failed builds which
|
||||
saves time because builds that are known to fail will not be attempted.
|
||||
- `$option_license_db_dir`:
|
||||
A directory for storing information about port licenses used by the
|
||||
port_binary_distributable.tcl script.
|
||||
|
||||
|
||||
## Runtime Requirements ##
|
||||
|
||||
@@ -58,6 +58,7 @@ parseopt prefix:,work-dir: "$@" || exit
|
||||
option_log_dir=${option_work_dir}/logs
|
||||
}
|
||||
option_failcache_dir=${option_work_dir}/failcache
|
||||
option_license_db_dir=${option_work_dir}/license_db
|
||||
|
||||
# Inform the user if old repositories are still present.
|
||||
if [[ -d ${option_work_dir}/tools/.svn ]]; then
|
||||
|
||||
+3
-48
@@ -31,60 +31,15 @@ print-subports() {
|
||||
local archive_site_public=$1
|
||||
local archive_site_private=$2
|
||||
local portnames=$3
|
||||
local port
|
||||
local ports
|
||||
local exclude
|
||||
local exclude_reasons
|
||||
local reason
|
||||
|
||||
# $option_prefix is set in mpbb
|
||||
# shellcheck disable=SC2154
|
||||
tclsh=${option_prefix}/bin/port-tclsh
|
||||
# $option_prefix is set in mpbb
|
||||
# shellcheck disable=SC2154
|
||||
ports=$("${tclsh}" "${thisdir}/tools/sort-with-subports.tcl" ${portnames}) || return
|
||||
for port in $ports; do
|
||||
exclude=0
|
||||
exclude_reasons=()
|
||||
|
||||
if [[ -n "${archive_site_public}" || -n "${archive_site_private}" ]]; then
|
||||
# FIXME: this doesn't take selected variants into account
|
||||
# $thisdir is set in mpbb
|
||||
# shellcheck disable=SC2154
|
||||
archive_path=$("${tclsh}" "${thisdir}/tools/archive-path.tcl" "${port}")
|
||||
archive_basename=$(basename "${archive_path}")
|
||||
|
||||
# $option_jobs_dir is set in mpbb
|
||||
# shellcheck disable=SC2154
|
||||
if "${tclsh}" "${option_jobs_dir}/port_binary_distributable.tcl" "${port}"; then
|
||||
archive_type=public
|
||||
archive_distributable="distributable"
|
||||
archive_site="${archive_site_public}"
|
||||
else
|
||||
archive_type=private
|
||||
archive_distributable="not distributable"
|
||||
archive_site="${archive_site_private}"
|
||||
fi
|
||||
|
||||
if [[ -n "${archive_site}" ]] && curl -fIsL "${archive_site}/${port}/${archive_basename}" > /dev/null; then
|
||||
exclude=1
|
||||
exclude_reasons+=("it is ${archive_distributable} and has already been built and uploaded to the ${archive_type} server")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $exclude -eq 0 ]; then
|
||||
echo "$port"
|
||||
else
|
||||
if [ ${#exclude_reasons[@]} -eq 1 ]; then
|
||||
echo >&2 "Excluding '${port}' because ${exclude_reasons[0]}."
|
||||
else
|
||||
echo >&2 "Excluding '${port}' for the following reasons:"
|
||||
for reason in "${exclude_reasons[@]}"; do
|
||||
echo >&2 " - ${reason}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
"${tclsh}" "${thisdir}/tools/sort-with-subports.tcl" --jobs_dir "${option_jobs_dir}" \
|
||||
--license_db_dir "${option_license_db_dir}" --archive_site_public "${archive_site_public}" \
|
||||
--archive_site_private "${archive_site_private}" ${portnames} || return
|
||||
}
|
||||
|
||||
list-subports() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# sub-ports of the specified ports.
|
||||
#
|
||||
# Copyright (c) 2006,2008 Bryan L Blackburn. All rights reserved.
|
||||
# Copyright (c) 2018 The MacPorts Project
|
||||
# Copyright (c) 2018-2019 The MacPorts Project
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@@ -65,6 +65,42 @@ if {[catch {mportinit "" "" ""} result]} {
|
||||
error "Failed to initialize ports system: $result"
|
||||
}
|
||||
|
||||
set archive_site_private ""
|
||||
set archive_site_public ""
|
||||
set jobs_dir ""
|
||||
set license_db_dir ""
|
||||
while {[string range [lindex $::argv 0] 0 1] eq "--"} {
|
||||
switch -- [lindex $::argv 0] {
|
||||
--archive_site_private {
|
||||
set archive_site_private [lindex $::argv 1]
|
||||
set ::argv [lrange $::argv 1 end]
|
||||
}
|
||||
--archive_site_public {
|
||||
set archive_site_public [lindex $::argv 1]
|
||||
set ::argv [lrange $::argv 1 end]
|
||||
}
|
||||
--jobs_dir {
|
||||
set jobs_dir [lindex $::argv 1]
|
||||
set ::argv [lrange $::argv 1 end]
|
||||
}
|
||||
--license_db_dir {
|
||||
set license_db_dir [lindex $::argv 1]
|
||||
set ::argv [lrange $::argv 1 end]
|
||||
}
|
||||
default {
|
||||
error "unknown option: [lindex $::argv 0]"
|
||||
}
|
||||
}
|
||||
set ::argv [lrange $::argv 1 end]
|
||||
}
|
||||
|
||||
if {$jobs_dir ne ""} {
|
||||
source ${jobs_dir}/distributable_lib.tcl
|
||||
if {$license_db_dir ne ""} {
|
||||
init_license_db $license_db_dir
|
||||
}
|
||||
}
|
||||
|
||||
set is_64bit_capable [sysctl hw.cpu64bit_capable]
|
||||
|
||||
array set portdepinfo {}
|
||||
@@ -114,6 +150,7 @@ while {$todo ne {}} {
|
||||
}
|
||||
}
|
||||
|
||||
set opened 0
|
||||
if {[info exists outputports($p)] && $outputports($p) == 1} {
|
||||
if {[info exists portinfo(replaced_by)]} {
|
||||
puts stderr "Excluding $portinfo(name) because it is replaced by $portinfo(replaced_by)"
|
||||
@@ -121,8 +158,31 @@ while {$todo ne {}} {
|
||||
} elseif {[info exists portinfo(known_fail)] && [string is true -strict $portinfo(known_fail)]} {
|
||||
puts stderr "Excluding $portinfo(name) because it is known to fail"
|
||||
set outputports($p) 0
|
||||
} elseif {$::macports::os_major <= 10} {
|
||||
} elseif {$archive_site_public ne ""} {
|
||||
# FIXME: support non-default variants
|
||||
if {![catch {mportopen $portinfo(porturl) [list subport $portinfo(name)] ""} result]} {
|
||||
set opened 1
|
||||
set workername [ditem_key $result workername]
|
||||
set archive_name [$workername eval get_portimage_name]
|
||||
if {![catch {curl getsize ${archive_site_public}/$portinfo(name)/${archive_name}} size] && $size > 0} {
|
||||
puts stderr "Excluding $portinfo(name) because it has already been built and uploaded to the public server"
|
||||
set outputports($p) 0
|
||||
}
|
||||
} else {
|
||||
puts stderr "Excluding $portinfo(name) because it failed to open: $result"
|
||||
set outputports($p) 0
|
||||
}
|
||||
if {$outputports($p) == 1 && $archive_site_private ne "" && $jobs_dir ne ""} {
|
||||
# FIXME: support non-default variants
|
||||
set results [check_licenses $portinfo(name) [list]]
|
||||
if {[lindex $results 0] == 1 && ![catch {curl getsize ${archive_site_private}/$portinfo(name)/${archive_name}} size] && $size > 0} {
|
||||
puts stderr "Excluding $portinfo(name) because it is not distributable and it has already been built and uploaded to the private server"
|
||||
set outputports($p) 0
|
||||
}
|
||||
}
|
||||
}
|
||||
if {$outputports($p) == 1 && $::macports::os_major <= 10} {
|
||||
if {$opened == 1 || ![catch {mportopen $portinfo(porturl) [list subport $portinfo(name)] ""} result]} {
|
||||
set supported_archs [_mportkey $result supported_archs]
|
||||
if {$::macports::os_arch eq "i386" && !${is_64bit_capable} && $supported_archs ne "" && ("x86_64" ni $supported_archs || "i386" ni $supported_archs)} {
|
||||
puts stderr "Excluding $portinfo(name) because the ${::macports::macosx_version}_x86_64 builder will build it"
|
||||
@@ -159,6 +219,10 @@ while {$todo ne {}} {
|
||||
}
|
||||
}
|
||||
|
||||
if {$jobs_dir ne "" && $license_db_dir ne ""} {
|
||||
write_license_db $license_db_dir
|
||||
}
|
||||
|
||||
set portlist [list]
|
||||
foreach portname [lsort -dictionary [array names portdepinfo]] {
|
||||
if {[info exists portdepinfo($portname)]} {
|
||||
|
||||
Reference in New Issue
Block a user