apm_generate_package_spec

one of the documented procedures in this installation of the ACS
Usage:
apm_generate_package_spec   version_id
What it does:
Generates an XML-formatted specification for a version of a package.
Defined in: /web/philip/packages/acs-core/apm-procs.tcl

Source code:


    db_1row "
        select p.package_key, p.package_url, v.*
        from   apm_packages p, apm_package_versions v
        where  v.version_id = $version_id
        and    v.package_id = p.package_id
    "
    
    append spec "<?xml version=\"1.0\"?>
<!-- Generated by the ArsDigita Package Manager -->

<package key=\"[ad_quotehtml $package_key]\" url=\"[ad_quotehtml $package_url]\">
    <version name=\"$version_name\" url=\"[ad_quotehtml $version_url]\">
        <package-name>[ad_quotehtml $package_name]</package-name>
"

    db_foreach "
        select owner_url, owner_name
        from   apm_package_owners
        where  version_id = $version_id
        order by sort_key
    " {
        append spec "        <owner"
        if { ![empty_string_p $owner_url] } {
    	append spec " url=\"[ad_quotehtml $owner_url]\""
        }
        append spec ">[ad_quotehtml $owner_name]</owner>\n"
    }
    
    if { ![empty_string_p $summary] } {
        append spec "        <summary>[ad_quotehtml $summary]</summary>\n"
    }
    if { ![empty_string_p $release_date] } {
        append spec "        <release-date>[ad_quotehtml $release_date]</release-date>\n"
    }
    if { ![empty_string_p $vendor] || ![empty_string_p $vendor_url] } {
        append spec "        <vendor"
        if { ![empty_string_p $vendor_url] } {
    	append spec " url=\"[ad_quotehtml $vendor_url]\""
        }
        append spec ">[ad_quotehtml $vendor]</vendor>\n"
    }
    if { ![empty_string_p $description] } {
        append spec "        <description"
        if { ![empty_string_p $description_format] } {
	    append spec " format=\"[ad_quotehtml $description_format]\""
        }
        append spec ">[ad_quotehtml $description]</description>\n"
    }
    if { ![empty_string_p $distribution] } {
        append spec "        <distribution>[ad_quotehtml $distribution]</distribution>\n"
    }
    if { ![empty_string_p $package_group] } {
        append spec "        <group>[ad_quotehtml $package_group]</group>\n"
    }
    append spec "\n"
    
    db_foreach "
        select dependency_type, service_url, service_version
        from   apm_package_dependencies
        where  version_id = $version_id
        order by dependency_type, service_url
    " {
        append spec "        <$dependency_type url=\"[ad_quotehtml $service_url]\" version=\"[ad_quotehtml $service_version]\"/>\n"
    } else {
        append spec "        <!-- No dependency information -->\n"
    }

    db_foreach "
        select version_url
        from   apm_package_includes
        where  version_id = $version_id
        order by version_url
    " {
	append spec "        <include url=\"[ad_quotehtml $version_url]\"/>\n"
    } else {
	append spec "        <!-- No included packages -->\n"
    }

    append spec "\n        <files>\n"
    
    db_foreach "select path, file_type from apm_package_files where version_id = $version_id order by path" {
        append spec "            <file"
        if { ![empty_string_p $file_type] } {
    	append spec " type=\"$file_type\""
        }
        append spec " path=\"[ad_quotehtml $path]\"/>\n"
    } else {
        append spec "            <!-- No files -->\n"
    }
    
    append spec "        </files>
    </version>
</package>
"
    return $spec


philg@mit.edu