aboutsummaryrefslogtreecommitdiff
path: root/documentation/tools/global-pgpkeys-creator.rb
blob: 5e5596bab6f7d67e1b85296fdefb1cd19dcd172d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby

=begin

BSD 2-Clause License
Copyright (c) 2020-2025, The FreeBSD Project
Copyright (c) 2020-2025, Sergio Carlavilla <carlavilla@FreeBSD.org>

This script will merge all the pgpkeys into one single file

=end

def getAllPGPKeys()
  return Dir.glob('./static/pgpkeys/*.key').sort
end

def processAllPGPKeys(keysFiles, pgpKeysFile)
  keysFiles.each{ |keyFile|
    processPGPKey(keyFile, pgpKeysFile)
  }
end

def processPGPKey(keyFile, pgpKeysFile)
  File.readlines(keyFile).each do |line|
    if # remove script comment and AsciiDoc syntax
        not line.include? "// sh addkey.sh" and
        not line.include? "[.literal-block-margin]" and
        not line.include? "...."
      pgpKeysFile.puts(line)
    end
  end
end

# Main method
keysFiles = getAllPGPKeys()

pgpKeysFile = File.new("./static/pgpkeys/pgpkeys.txt", "w")

processAllPGPKeys(keysFiles, pgpKeysFile)