apm_generate_tarball (public)
apm_generate_tarball version_id
Defined in packages/acs-tcl/tcl/apm-file-procs.tcl
Generates a tarball for a version, placing it in the content repository. DCW - 2001-05-03, change to use the content repository for tarball storage.
- Parameters:
- version_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- apm_tarballs
Source code: set package_key [apm_package_key_from_version_id $version_id] set files [apm_get_package_files -all -package_key $package_key] set tmpfile [ad_tmpnam] db_1row package_key_select {} # Generate a command like: # # tar cf - -C /web/arsdigita/packages acs-kernel/00-proc-procs.tcl # -C /web/arsdigita/packages 10-database-procs.tcl ... # | gzip -c > $tmpfile # # Note that -C changes the working directory before compressing the next # file; we need this to ensure that the tarballs are relative to the # package root directory ($::acs::rootdir/packages). set cmd [list exec [apm_tar_cmd] cf - 2> [apm_dev_null]] foreach file $files { lappend cmd -C "$::acs::rootdir/packages" lappend cmd "$package_key/$file" } lappend cmd "|" [apm_gzip_cmd] -c ">" $tmpfile {*}$cmd # At this point, the APM tarball is sitting in $tmpfile. Save it in # the database. set creation_ip [ad_conn peeraddr] set user_id [ad_conn user_id] set name "tarball-for-package-version-${version_id}" set title "${package_key}-tarball" set description "gzipped tarfile" set mime_type "text/plain" db_1row item_exists_p {} if {!$item_id} { # content item hasen't been created yet - create one. set item_id [content::item::new -name $name -title $title -description $description -mime_type $mime_type -creation_user $user_id -creation_ip $creation_ip -is_live true] db_dml set_item_id {} } set revision_id [content::item::get_live_revision -item_id $item_id] # No live revision for this item. Possible if somebody already # generated the archive, then deleted or modified the revision # manually or by other means. We create a new live revision. if {$revision_id eq ""} { set revision_id [content::revision::new -item_id $item_id -title $title -description $description -mime_type $mime_type -creation_user $user_id -creation_ip $creation_ip -is_live true] } db_dml update_tarball {} -blob_files [list $tmpfile] db_dml update_content_length {} file delete -- $tmpfileGeneric XQL file: <fullquery name="apm_generate_tarball.item_exists_p"> <querytext> select case when item_id is null then 0 else item_id end as item_id from apm_package_versions where version_id = :version_id </querytext> </fullquery> <fullquery name="apm_generate_tarball.set_item_id"> <querytext> update apm_package_versions set item_id = :item_id where version_id = :version_id </querytext> </fullquery> <fullquery name="apm_generate_tarball.package_key_select"> <querytext> select package_key from apm_package_version_info where version_id = :version_id </querytext> </fullquery>packages/acs-tcl/tcl/apm-file-procs.xql
PostgreSQL XQL file: <fullquery name="apm_generate_tarball.update_tarball"> <querytext> update cr_revisions set content = '[set content_file [cr_create_content_file $item_id $revision_id $tmpfile]]' where revision_id = :revision_id </querytext> </fullquery> <fullquery name="apm_generate_tarball.update_content_length"> <querytext> update apm_package_versions set content_length = [cr_file_size $content_file] where version_id = :version_id </querytext> </fullquery>packages/acs-tcl/tcl/apm-file-procs-postgresql.xql
Oracle XQL file: <fullquery name="apm_generate_tarball.update_tarball"> <querytext> update cr_revisions set filename = '[set content_file [cr_create_content_file $item_id $revision_id $tmpfile]]' where revision_id = :revision_id </querytext> </fullquery> <fullquery name="apm_generate_tarball.update_content_length"> <querytext> update apm_package_versions set content_length = [cr_file_size $content_file] where version_id = :version_id </querytext> </fullquery>packages/acs-tcl/tcl/apm-file-procs-oracle.xql