Defer loading of some packages

This commit is contained in:
Joshua Root
2026-06-18 05:39:46 +10:00
parent 63e51116d7
commit e545ebe8c5
6 changed files with 21 additions and 19 deletions
+16 -13
View File
@@ -35,15 +35,7 @@
package provide macports 1.0
package require macports_dlist 1.0
package require macports_util 1.0
package require mport_fetch_thread
package require diagnose 1.0
package require reclaim 1.0
package require selfupdate 1.0
package require snapshot 1.0
package require restore 1.0
package require migrate 1.0
package require Tclx
package require uri
# catch wrapper shared with port1.0
package require mpcommon 1.0
@@ -1154,6 +1146,8 @@ proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
package require registry 1.0
package require registry2 2.0
package require machista 1.0
package require mport_fetch_thread
package require uri
# Set the system encoding to utf-8
encoding system utf-8
@@ -1737,10 +1731,13 @@ match macports.conf.default."
# Check that the current platform is the one we were configured for, otherwise need to do migration
set skip_migration_check [expr {[info exists macports::global_options(ports_no_migration_check)] && $macports::global_options(ports_no_migration_check)}]
if {!$skip_migration_check && [migrate::needs_migration migrate_reason]} {
ui_error $migrate_reason
ui_error "Please run 'sudo port migrate' or follow the migration instructions: https://trac.macports.org/wiki/Migration"
return -code error "OS platform mismatch"
if {!$skip_migration_check} {
package require migrate 1.0
if {[migrate::needs_migration migrate_reason]} {
ui_error $migrate_reason
ui_error "Please run 'sudo port migrate' or follow the migration instructions: https://trac.macports.org/wiki/Migration"
return -code error "OS platform mismatch"
}
}
if {![info exists macosx_deployment_target]} {
@@ -5079,6 +5076,7 @@ proc macports::_variants_to_variations {variants} {
# selfupdate procedure
proc macports::selfupdate {{options {}} {updatestatusvar {}}} {
package require selfupdate 1.0
return [uplevel [list selfupdate::main $options $updatestatusvar]]
}
@@ -6269,7 +6267,7 @@ proc macports::diagnose_main {opts} {
# None
# Returns:
# 0 on successful execution.
package require diagnose 1.0
diagnose::main $opts
return 0
}
@@ -6284,6 +6282,7 @@ proc macports::reclaim_check_and_run {} {
return 0
}
package require reclaim 1.0
try {
return [reclaim::check_last_run]
} trap {POSIX SIG SIGINT} {} {
@@ -6311,6 +6310,7 @@ proc macports::snapshot_main {opts} {
# Returns:
# 0 on successful execution.
package require snapshot 1.0
return [snapshot::main $opts]
}
@@ -6324,6 +6324,7 @@ proc macports::restore_main {opts} {
# Returns:
# 0 on successful execution.
package require restore 1.0
return [restore::main $opts]
}
@@ -6334,6 +6335,7 @@ proc macports::restore_main {opts} {
# caller should re-run itself and invoke migration with the --continue
# flag set.
proc macports::migrate_main {opts} {
package require migrate 1.0
return [migrate::main $opts]
}
@@ -6345,6 +6347,7 @@ proc macports::reclaim_main {opts} {
# Returns:
# None
package require reclaim 1.0
try {
reclaim::main $opts
} trap {POSIX SIG SIGINT} {} {
+3 -2
View File
@@ -32,8 +32,6 @@ package provide snapshot 1.0
package require macports 1.0
package require registry 1.0
package require json
package require json::write
namespace eval snapshot {
proc print_usage {} {
@@ -259,6 +257,8 @@ namespace eval snapshot {
# Returns:
# string representation of the snapshot object
package require json::write
# The conversion can take quite a while because we're querying all
# files installed by the various ports, so display a progress bar
global macports::ui_options
@@ -344,6 +344,7 @@ namespace eval snapshot {
# Returns:
# The imported snapshot as a snapshot object
package require json
set data [json::json2dict $contents]
try {
+1 -1
View File
@@ -33,7 +33,6 @@
package provide portdestroot 1.0
package require portutil 1.0
package require fileutil
set org.macports.destroot [target_new org.macports.destroot portdestroot::destroot_main]
target_provides ${org.macports.destroot} destroot
@@ -225,6 +224,7 @@ proc portdestroot::destroot_finish {args} {
}
# Prune empty directories in ${destroot}
package require fileutil
foreach path ${destroot.keepdirs} {
# Prepend $destroot if $path isn't already inside it
set path [::fileutil::jail $destroot $path]
-1
View File
@@ -33,7 +33,6 @@
package provide portinstall 1.0
package require portutil 1.0
package require machista 1.0
set org.macports.install [target_new org.macports.install portinstall::install_main]
target_provides ${org.macports.install} install
-1
View File
@@ -37,7 +37,6 @@ package require receipt_flat 1.0
package require receipt_sqlite 1.0
package require portimage 2.0
package require registry_uninstall 2.0
package require msgcat
package require Pextlib 1.0
namespace eval registry {
+1 -1
View File
@@ -33,7 +33,6 @@
package provide registry_util 2.0
package require registry2 2.0
package require tdbc::sqlite3
namespace eval registry {
@@ -177,6 +176,7 @@ proc run_target {port target options} {
## Create and configure a tdbc connection to the registry
proc tdbc_connect {args} {
package require tdbc::sqlite3
variable tdbc_connection
set reg_path [::file join ${::macports::registry.path} registry registry.db]
set tdbc_connection [tdbc::sqlite3::connection new $reg_path]