From 3f6ea93e316bc76dc8bca2aef71280cc6c06aca7 Mon Sep 17 00:00:00 2001 From: Tim Sharpe Date: Wed, 17 Jul 2019 16:50:30 +1000 Subject: [PATCH] Turn CentOS factset duplicating into a rake task --- README.md | 4 +--- rakelib/rhel_alts.rake | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 rakelib/rhel_alts.rake diff --git a/README.md b/README.md index d9689dd7..8eb82da5 100644 --- a/README.md +++ b/README.md @@ -162,9 +162,7 @@ for file in facts/*/*-x86_64.facts; do cat $file | sed -e 's/x86_64/i386/' -e 's Create RedHat, Scientific, OracleLinux facts from CentOS's ones ``` -for file in facts/*/centos-*.facts; do cat $file | sed -e 's/CentOS/RedHat/' > $(echo $file | sed 's/centos/redhat/'); done -for file in facts/*/centos-*.facts; do cat $file | sed -e 's/CentOS/Scientific/' > $(echo $file | sed 's/centos/scientific/'); done -for file in facts/*/centos-*.facts; do cat $file | sed -e 's/CentOS/OracleLinux/' > $(echo $file | sed 's/centos/oraclelinux/'); done +$ bundle exec rake rhel_alts ``` Then update array `Facter version and Operating System coverage` with output of rake task `table`. diff --git a/rakelib/rhel_alts.rake b/rakelib/rhel_alts.rake new file mode 100644 index 00000000..eaccbb33 --- /dev/null +++ b/rakelib/rhel_alts.rake @@ -0,0 +1,24 @@ +desc 'Create RHEL/OracleLinux/Scientific factsets from CentOS factsets' +task :rhel_alts do + Dir[File.join(__dir__, '..', 'facts', '*', 'centos-*-x86_64.facts')].each do |f| + centos_factset = File.read(f) + + rhel_path = f.gsub(%r{centos-}, 'redhat-') + File.open(rhel_path, 'w') do |fd| + fd.puts centos_factset.gsub(%r{CentOS}, 'RedHat') + end + + oracle_path = f.gsub(%r{centos-}, 'oraclelinux-') + File.open(oracle_path, 'w') do |fd| + fd.puts centos_factset.gsub(%r{CentOS}, 'OracleLinux') + end + + # Scientific isn't going to be updated to 8 + if File.basename(f)[%r{-(\d+)-}, 1].to_i <= 7 + scientific_path = f.gsub(%r{centos-}, 'scientific-') + File.open(scientific_path, 'w') do |fd| + fd.puts centos_factset.gsub(%r{CentOS}, 'Scientific') + end + end + end +end