Module: Pkg::Archive
- Defined in:
- lib/packaging/archive.rb
Class Method Summary collapse
-
.archive_paths ⇒ Object
Array of paths for temporarily staging artifacts before syncing to release-archives on s3.
-
.base_paths ⇒ Object
Array of base paths for foss artifacts on weth.
-
.delete_staged_archives ⇒ Object
Delete artifacts from archive staging paths (after they’ve been synced to s3).
-
.remove_dead_symlinks ⇒ Object
Delete broken symlinks from repo paths on weth.
-
.remove_empty_directories ⇒ Object
Delete empty directories from repo paths on weth.
-
.stage_apt_archives(directory) ⇒ Object
Move directories from freight path (aka repo staging path) to archive staging paths.
-
.stage_downloads_archives(directory) ⇒ Object
Move downloads directories to archive staging path.
-
.stage_yum_archives(directory) ⇒ Object
Move yum directories from repo path to archive staging path.
Class Method Details
.archive_paths ⇒ Object
Array of paths for temporarily staging artifacts before syncing to release-archives on s3
10 11 12 |
# File 'lib/packaging/archive.rb', line 10 def archive_paths [Pkg::Config.yum_archive_path, Pkg::Config.apt_archive_path, Pkg::Config.freight_archive_path, Pkg::Config.downloads_archive_path, '/opt/tmp-apt'].compact end |
.base_paths ⇒ Object
Array of base paths for foss artifacts on weth
5 6 7 |
# File 'lib/packaging/archive.rb', line 5 def base_paths [Pkg::Config.yum_repo_path, Pkg::Config.apt_repo_staging_path, Pkg::Config.apt_repo_path, '/opt/downloads'].compact end |
.delete_staged_archives ⇒ Object
Delete artifacts from archive staging paths (after they’ve been synced to s3)
120 121 122 123 124 125 |
# File 'lib/packaging/archive.rb', line 120 def delete_staged_archives archive_paths.each do |archive_path| command = "sudo rm -rf #{File.join(archive_path, '*')}" Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command) end end |
.remove_dead_symlinks ⇒ Object
Delete broken symlinks from repo paths on weth
112 113 114 115 116 117 |
# File 'lib/packaging/archive.rb', line 112 def remove_dead_symlinks base_paths.each do |path| command = "find #{path} -xtype l -delete" Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command) end end |
.remove_empty_directories ⇒ Object
Delete empty directories from repo paths on weth
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/packaging/archive.rb', line 92 def remove_empty_directories base_paths.each do |path| command = <<-CMD for directory in $(find #{path} -type d); do if [ ! -d $directory ]; then echo "Can't find directory $directory, it was probably already deleted, skipping . . ." continue fi files=$(find $directory -type f) if [ -z "$files" ]; then echo "No files in directory $directory, deleting . . ." sudo rm -rf $directory fi done CMD Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command) end end |
.stage_apt_archives(directory) ⇒ Object
Move directories from freight path (aka repo staging path) to archive staging paths
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/packaging/archive.rb', line 40 def stage_apt_archives(directory) find_command = "find #{Pkg::Config.apt_repo_staging_path} -type d -name #{directory}" find_command = "find #{Pkg::Config.apt_repo_staging_path} -maxdepth 2 -type f" if directory == 'main' command = <<-CMD for stuff in $(#{find_command}); do find $stuff -type l -delete codename=$(dirname ${stuff##{Pkg::Config.apt_repo_staging_path}/}) sudo mkdir --parents #{Pkg::Config.freight_archive_path}/$codename sudo chown root:release -R #{Pkg::Config.freight_archive_path}/$codename sudo chmod g+w -R #{Pkg::Config.freight_archive_path}/$codename mv $stuff #{Pkg::Config.freight_archive_path}/$codename pool_directory=#{Pkg::Config.apt_repo_path}/pool/$codename/#{directory} if [ ! -d $pool_directory ]; then echo "Can't find directory $pool_directory, it may have already been archived, skipping . . ." continue fi sudo mkdir --parents /opt/tmp-apt sudo chown root:release -R /opt/tmp-apt sudo chmod g+w -R /opt/tmp-apt mv $pool_directory /opt/tmp-apt done CMD Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command) end |
.stage_downloads_archives(directory) ⇒ Object
Move downloads directories to archive staging path
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/packaging/archive.rb', line 67 def stage_downloads_archives(directory) # /opt/downloads/#{directory} full_directory = File.join('/', 'opt', 'downloads', directory) archive_path = File.join(Pkg::Config.downloads_archive_path, directory) command = <<-CMD if [ ! -d #{full_directory} ]; then if [ -d #{archive_path} ]; then echo "Directory #{full_directory} has already been staged, skipping . . ." exit 0 else echo "ERROR: Couldn't find directory #{full_directory}, exiting . . ." exit 1 fi fi find #{full_directory} -type l -delete sudo chattr -i -R #{full_directory} sudo mkdir --parents #{File.dirname(archive_path)} sudo chown root:release -R #{Pkg::Config.downloads_archive_path} sudo chmod g+w -R #{Pkg::Config.downloads_archive_path} mv #{full_directory} #{archive_path} CMD Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command) end |
.stage_yum_archives(directory) ⇒ Object
Move yum directories from repo path to archive staging path
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/packaging/archive.rb', line 15 def stage_yum_archives(directory) # /opt/repository/yum/#{directory} full_directory = File.join(Pkg::Config.yum_repo_path, directory) archive_path = File.join(Pkg::Config.yum_archive_path, directory) command = <<-CMD if [ ! -d #{full_directory} ]; then if [ -d #{archive_path} ]; then echo "Directory #{full_directory} has already been staged, skipping . . ." exit 0 else echo "ERROR: Couldn't find directory #{full_directory}, exiting . . ." exit 1 fi fi find #{full_directory} -type l -delete sudo chattr -i -R #{full_directory} sudo mkdir --parents #{File.dirname(archive_path)} sudo chown root:release -R #{Pkg::Config.yum_archive_path} sudo chmod g+w -R #{Pkg::Config.yum_archive_path} mv #{full_directory} #{archive_path} CMD Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, command) end |