From 4a3eed183434905acc3075ecae8355bca0e8fdb2 Mon Sep 17 00:00:00 2001 From: James Larrowe Date: Wed, 17 Oct 2018 19:21:30 -0400 Subject: [PATCH] Add rng_tools package (#2766) * Add rng_tools package * Use 'install' command instead of 'cp' --- packages/rng_tools.rb | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 packages/rng_tools.rb diff --git a/packages/rng_tools.rb b/packages/rng_tools.rb new file mode 100644 index 000000000..261ce3b96 --- /dev/null +++ b/packages/rng_tools.rb @@ -0,0 +1,75 @@ +require 'package' + +class Rng_tools < Package + description 'This is a random number generator daemon.' + homepage 'https://github.com/nhorman/rng-tools' + version '6.5' + source_url 'https://github.com/nhorman/rng-tools/archive/v6.5.tar.gz' + source_sha256 '5fecd904f7d01262b3209ff78dd3b9594aac8daa41badd5a1e6438658e80c36e' + + binary_url ({ + }) + binary_sha256 ({ + }) + + depends_on 'curl' + depends_on 'libgcrypt' + depends_on 'sysfsutils' + depends_on 'psmisc' + + def self.build + system './autogen.sh' + system "./configure", "--prefix=#{CREW_PREFIX}", "--libdir=#{CREW_LIB_PREFIX}" + system 'make' + system "echo '#!/bin/bash' > startrngd" + system "echo 'RNGD=#{CREW_PREFIX}/sbin/rngd' >> startrngd" + system "echo 'RNG=\$(pidof \$RNGD 2> /dev/null)' >> startrngd" + system "echo 'if [ -z \"\$RNG\" ]; then' >> startrngd" + system "echo ' sudo LD_LIBRARY_PATH=\$LD_LIBRARY_PATH rngd &>/dev/null' >> startrngd" + system "echo ' sleep 3' >> startrngd" + system "echo 'fi' >> startrngd" + system "echo 'RNG=\$(pidof \$RNGD 2> /dev/null)' >> startrngd" + system "echo 'if [ ! -z \"\$RNG\" ]; then' >> startrngd" + system "echo ' echo \"rngd process \$RNG is running\"' >> startrngd" + system "echo 'else' >> startrngd" + system "echo ' echo \"rngd failed to start\"' >> startrngd" + system "echo ' exit 1' >> startrngd" + system "echo 'fi' >> startrngd" + system "echo '#!/bin/bash' > stoprngd" + system "echo 'RNGD=#{CREW_PREFIX}/sbin/rngd' >> stoprngd" + system "echo 'RNG=\$(pidof \$RNGD 2> /dev/null)' >> stoprngd" + system "echo 'if [ ! -z \"\$RNG\" ]; then' >> stoprngd" + system "echo ' sudo killall rngd' >> stoprngd" + system "echo ' sleep 3' >> stoprngd" + system "echo 'fi' >> stoprngd" + system "echo 'RNG=\$(pidof \$RNGD 2> /dev/null)' >> stoprngd" + system "echo 'if [ -z \"\$RNG\" ]; then' >> stoprngd" + system "echo ' echo \"rngd process stopped\"' >> stoprngd" + system "echo 'else' >> stoprngd" + system "echo ' echo \"rngd process \$RNG is running\"' >> stoprngd" + system "echo ' exit 1' >> stoprngd" + system "echo 'fi' >> stoprngd" + end + + def self.install + system "make", "DESTDIR=#{CREW_DEST_DIR}", "install" + system "install", "-Dm755", "startrngd", "stoprngd", "#{CREW_DEST_PREFIX}/bin/" + end + + def self.postinstall + puts + puts "To start the rngd daemon, execute the following:".lightblue + puts "startrngd".lightblue + puts + puts "To stop the rngd daemon, execute the following:".lightblue + puts "stoprngd".lightblue + puts + puts "To start the rngd daemon at login, execute the following:".lightblue + puts "echo '# start the rngd daemon' >> ~/.bashrc".lightblue + puts "echo 'if [ -f #{CREW_PREFIX}/bin/startrngd ]; then' >> ~/.bashrc".lightblue + puts "echo ' #{CREW_PREFIX}/bin/startrngd' >> ~/.bashrc".lightblue + puts "echo 'fi' >> ~/.bashrc".lightblue + puts "source ~/.bashrc".lightblue + puts + end +end