From 942a69f5e845884716ef7f0b3b82f0888637f6e3 Mon Sep 17 00:00:00 2001 From: SaltwaterC Date: Thu, 17 Jun 2021 01:40:45 +0100 Subject: [PATCH] Add repository export command. Now it's possible to export without add-pkg. --- CHANGELOG.md | 4 ++++ Rakefile | 5 ++++- lib/repo_mgr/backends/deb.rb | 4 ++++ lib/repo_mgr/backends/rpm.rb | 4 ++++ lib/repo_mgr/cli.rb | 12 ++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e93ee97..5a90bfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 + + * Add repo exporter to rebuild a local repo. + ## v0.2.0 * Add git publisher. diff --git a/Rakefile b/Rakefile index bdca6c0..0d3142d 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,7 @@ begin Jeweler::Tasks.new do |gem| gem.name = 'repo-mgr' - gem.version = '0.2.0' + gem.version = '0.2.1' gem.summary = %(deb and rpm repository manager) gem.description = %(deb and rpm repository manager) gem.author = 'Ștefan Rusu' @@ -28,6 +28,9 @@ rescue LoadError warn 'Rubocop, or one of its dependencies, is not available.' end +task cop: %i[rubocop] +task lint: %i[rubocop] + desc 'Remove build artefacts' task :clean_pkg do rm_rf 'pkg' diff --git a/lib/repo_mgr/backends/deb.rb b/lib/repo_mgr/backends/deb.rb index e78be3a..ad3f8c9 100644 --- a/lib/repo_mgr/backends/deb.rb +++ b/lib/repo_mgr/backends/deb.rb @@ -88,6 +88,10 @@ def rebuild_pkg_list(repo) pkgs.map { |e| "#{e}.deb" } end + def export(repo) + repo_publish repo + end + private def init_aptly_config diff --git a/lib/repo_mgr/backends/rpm.rb b/lib/repo_mgr/backends/rpm.rb index 8d1454a..123836b 100644 --- a/lib/repo_mgr/backends/rpm.rb +++ b/lib/repo_mgr/backends/rpm.rb @@ -75,6 +75,10 @@ def rebuild_pkg_list(repo) end end + def export(repo) + sync_repo repo + end + private def extract_arch(pkg) diff --git a/lib/repo_mgr/cli.rb b/lib/repo_mgr/cli.rb index ed07fe3..f94704d 100644 --- a/lib/repo_mgr/cli.rb +++ b/lib/repo_mgr/cli.rb @@ -176,6 +176,18 @@ def sync puts "-- Synchronised #{options[:repo]} using #{pub_type} publisher" end + desc 'export', 'Export packages and metadata as local repository' + option :repo, type: :string, required: true, aliases: %w[-r], + desc: 'The repository to export' + def export + config = Config.new + backend = Backends.load config.cfg[:repos][options[:repo]][:type], config + + backend.export options[:repo] + + puts "-- Exported #{options[:repo]} repo" + end + private def load_backend(path)