Skip to content

Commit

Permalink
Turn CentOS factset duplicating into a rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek committed Jul 17, 2019
1 parent a9a22ea commit 3f6ea93
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
24 changes: 24 additions & 0 deletions rakelib/rhel_alts.rake
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3f6ea93

Please sign in to comment.