From 651d9f587f57695e0fc95b0cbfd28f883d016886 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Tue, 20 Nov 2018 14:29:59 +0100 Subject: [PATCH] depot.inc: 'append_src_and_api_depot_packages_to_tar' function This function adds the src and api depot packages for the given pkg or src packages to the given tar archive. Issue #3048 --- tool/run/depot.inc | 59 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/tool/run/depot.inc b/tool/run/depot.inc index 68de9ffde..2661a0f73 100644 --- a/tool/run/depot.inc +++ b/tool/run/depot.inc @@ -36,26 +36,33 @@ set _missing_depot_archives {} # -# Pattern to parse an version-less archive path into , , +# Pattern to parse a version-less archive path into , , # proc _depot_archive_path_pattern { } { return {^([\w\d]+)/([\w]+)/([\w\d\-_]+)$} } # -# Pattern to parse an versioned archive path into , , , +# Pattern to parse a versioned archive path into , , , # proc _depot_archive_versioned_path_pattern { } { return {^([\w\d]+)/([\w]+)/([\w\d\-_]+)/([\w\d\-\._]+)$} } # -# Pattern to parse an binary archive path into , , . +# Pattern to parse a binary archive path into , , . # proc _depot_bin_archive_path_pattern { } { return {^([\w\d]+)/bin/([\w\d]+)/([\w\d\-_]+)$} } +# +# Pattern to parse a versioned api name into , +# +proc _depot_api_versioned_name_pattern { } { + return {^([\w\d\-_]+)/([\w\d\-\._]+)$} } + + ## # Determine content of a pkg archive and its dependencies # @@ -104,7 +111,7 @@ proc _collect_raw_archive_from_depot { user name version } { ## -# Determine binary content for a given source archive +# Determine binary and api content for a given source archive # proc _collect_src_archive_from_depot { user name version } { @@ -112,14 +119,35 @@ proc _collect_src_archive_from_depot { user name version } { set src_archive_dir "$user/src/$name/$version" set bin_archive_dir "$user/bin/[depot_spec]/$name/$version" + set used_apis_file "[depot_dir]/$src_archive_dir/used_apis" + + set content {} if {[file exists [depot_dir]/$bin_archive_dir]} { - return [list $src_archive_dir $bin_archive_dir] + append content [list $src_archive_dir $bin_archive_dir] } else { lappend _missing_depot_archives [list $user bin [depot_spec] $name $version] } - return {} + if {![file exists $used_apis_file]} { + puts stderr "Error: missing file $used_apis_file" + exit 1 + } + + set fh [open $used_apis_file "RDONLY"] + set used_apis [read $fh] + close $fh + + foreach api $used_apis { + regexp [_depot_api_versioned_name_pattern] $api dummy api_name api_version + if {![_depot_contains_archive $user api $api_name $api_version]} { + lappend _missing_depot_archives [list $user api "" $api_name $api_version] + continue + } + lappend content $user/api/$api_name/$api_version + } + + return $content } @@ -250,6 +278,25 @@ proc create_tar_from_depot_binaries { archive_path args } { } +## +# Append src and api packages to the tar archive +# +proc append_src_and_api_depot_packages_to_tar { archive_path args } { + + set content {} + foreach subdir [_collect_from_depot $args] { + if {[regexp [_depot_archive_versioned_path_pattern] $subdir dummy user type]} { + if {($type != "src") && ($type != "api")} continue; + lappend content $subdir + } + } + + check_for_missing_depot_archives + + eval "exec tar rf $archive_path -C [depot_dir] [lsort -unique $content]" +} + + proc _locally_available_recipe { user type name version } { if {$type == "bin"} { set type "src" }