apm_register_new_packages { -callback apm_dummy_callback }What it does:
Looks for unregistered packages in the packages directory, registering them in the database if found.Defined in: /web/philip/packages/acs-core/apm-procs.tcl
Source code:
arg_parser_for_apm_register_new_packages $args
ns_log "Notice" "Scanning for new packages..."
# Obtain paths and mtimes for the spec files of all installed packages, in order
# to avoid reading spec files which haven't changed.
db_foreach "
select package_key, spec_file_path, spec_file_mtime
from apm_packages
" {
set spec_file_paths($package_key) $spec_file_path
set spec_file_mtimes($package_key) $spec_file_mtime
}
# Loop through all directories in the /packages directory, searching each for a
# .info file.
set n_registered_packages 0
foreach dir [lsort [glob -nocomplain "[acs_root_dir]/packages/*"]] {
set package_key [file tail $dir]
if { ![file isdirectory $dir] || [apm_ignore_file_p $dir] } {
apm_callback_and_log $callback "Skipping $package_key."
continue
}
# Locate the .info file for this package.
if { [catch { set info_file [apm_package_info_file_path $package_key] } error] } {
apm_callback_and_log -severity Warning $callback "Unable to locate specification file for package $package_key: $error"
continue
}
# If the mtime for this package hasn't changed since the last time we
# examined it, don't bother reregistering it.
if { [info exists spec_file_paths($package_key)] && [file isfile $spec_file_paths($package_key)] && [file mtime $spec_file_paths($package_key)] == $spec_file_mtimes($package_key) } {
apm_callback_and_log $callback "[ad_make_relative_path $spec_file_paths($package_key)] has not changed; skipping."
continue
}
# Try to register the .info file in the database.
if { [catch { set version_id [apm_register_package -callback $callback $info_file] } error] } {
apm_callback_and_log -severity Error $callback "Unable to register package $package_key: $error"
# Ensure that the package is not marked as installed, since we've established
# that there is no valid .info file in the filesystem!
db_dml "
update apm_package_versions
set installed_p = 'f'
where package_id in (select package_id from apm_packages
where package_key = '$package_key')
"
} else {
incr n_registered_packages
array set version [apm_read_package_info_file $info_file]
# Remember that we've examined this .info file.
db_dml "
update apm_packages
set spec_file_path = '[db_quote $version(path)]',
spec_file_mtime = $version(mtime)
where package_key = '$package_key'
"
# Mark this version of the package as installed, and other versions as un-installed.
db_dml "
update apm_package_versions
set installed_p = decode(version_id, $version_id, 't', 'f')
where package_id in (select package_id from apm_packages
where package_key = '$package_key')
"
}
}
db_release_unused_handles
if { $n_registered_packages == 0 } {
ns_log "Notice" "No new packages found."
}