summaryrefslogtreecommitdiffstats
path: root/contrib/build
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/build')
-rwxr-xr-xcontrib/build/build.sh38
-rw-r--r--contrib/build/havege_sample.c97
-rw-r--r--contrib/build/lib.spec76
-rw-r--r--contrib/build/nolib.spec40
4 files changed, 251 insertions, 0 deletions
diff --git a/contrib/build/build.sh b/contrib/build/build.sh
new file mode 100755
index 0000000..99a4b43
--- /dev/null
+++ b/contrib/build/build.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+##
+## Toggle between library and non-library builds. Fix messed up libtool environment
+## Build and run haveged-devel sample
+##
+case "$1" in
+nolib)
+ sed -i.bak -e '/^##libtool_start##/,/^##libtool_end##/s,^,##,g' ../../configure.ac
+ sed -i.bak -e '/^####nolibtool_start##/,/^####nolibtool_end##/s,^##,,g' \
+ -e '/^##libtool_start##/,/^##libtool_end##/s,^,##,g' ../../src/Makefile.am
+ cp nolib.spec ../../haveged.spec
+;;
+lib)
+ sed -i.bak -e '/^####libtool_start##/,/^####libtool_end##/s,^##,,g' ../../configure.ac
+ sed -i.bak -e '/^##nolibtool_start##/,/^##nolibtool_end##/s,^,##,g' \
+ -e '/^####libtool_start##/,/^####libtool_end##/s,^##,,g' ../../src/Makefile.am
+ cp lib.spec ../../haveged.spec
+;;
+new)
+ cd ../..
+ make distclean
+ rm -rf autom4te.cache
+ libtoolize --force --install
+ autoreconf --force
+ ./configure
+;;
+sample)
+ echo "gcc -o havege_sample -DUSE_SOURCE -I../../src -Wall havege_sample.c ../../src/.libs/libhavege.a"
+ gcc -o havege_sample -DUSE_SOURCE -I../../src -Wall havege_sample.c ../../src/.libs/libhavege.a
+ echo "./havege_sample > /dev/null"
+ ./havege_sample > /dev/null
+;;
+
+*)
+ echo "usage: build [new|nolib|lib|sample]";
+;;
+esac
+
diff --git a/contrib/build/havege_sample.c b/contrib/build/havege_sample.c
new file mode 100644
index 0000000..8a407ee
--- /dev/null
+++ b/contrib/build/havege_sample.c
@@ -0,0 +1,97 @@
+/*
+Simple test of build - writes 1k of RNG runs to stdout
+
+gcc -o havege_sample -DUSE_SOURCE -I../../src -Wall havege_sample.c ../../src/.libs/libhavege.a
+./havege_sample > /dev/null
+
+After package is installed into test RAM disk /dev/shm/1
+gcc -Wall -o havege_sample -I/dev/shm/1/include -L/dev/shm/1/lib havege_sample.c -lhavege
+LD_LIBRARY_PATH=/dev/shm/1/lib ./havege_sample > /dev/shm/havege_random
+
+
+
+*/
+
+#include <stdio.h>
+
+#ifdef USE_SOURCE
+#include "havege.h"
+#else
+#include <haveged/havege.h>
+#endif
+
+int my_status_dump ( H_PTR h, char *buf, size_t buflen) {
+ H_SD_TOPIC topics[4] = {H_SD_TOPIC_BUILD, H_SD_TOPIC_TUNE, H_SD_TOPIC_TEST, H_SD_TOPIC_SUM};
+ int ret=0, i;
+
+ for(i=0;i<4 && ret<(buflen-2);i++) {
+ ret += havege_status_dump(h, topics[i], buf + ret, buflen-ret);
+ if (ret>(buflen-2))
+ break;
+ buf[ret++] = '\n';
+ }
+ return ret;
+}
+/**
+ * RNG output is written to stdout
+ */
+int main(void) {
+ int rc;
+ H_UINT* buf;
+ H_PARAMS havege_parameters={0};
+ H_PTR havege_state = NULL;
+ const int status_buf_size = 8192;
+ char status_buf[status_buf_size];
+ int i, size;
+
+ //havege_parameters.msg_out = print_msg;
+ fprintf(stderr, "library version is %s\n", havege_version(NULL));
+ havege_state = havege_create(&havege_parameters);
+
+ rc = havege_state==NULL? H_NOHANDLE : havege_state->error;
+ if (H_NOERR==rc) {
+ buf = havege_state->io_buf;
+ size = havege_state->i_readSz /sizeof(H_UINT);
+ fprintf(stderr, "havege_create: buffer size is %d\n", havege_state->i_readSz);
+ }
+ else {
+ if (H_NOTESTSPEC==rc)
+ fprintf(stderr, "ERROR: havege_create: unrecognized test setup: %s", havege_parameters.testSpec);
+ else fprintf(stderr, "ERROR: havege_create has returned %d\n",rc);
+ if (H_NOHANDLE!=rc)
+ havege_destroy(havage_state);
+ return 1;
+ }
+ rc = havege_run(havege_state);
+ if ( rc ) {
+ fprintf(stderr, "ERROR: havege_run has returned %d\n", havege_state->error);
+ havege_destroy(havege_state);
+ return 1;
+ }
+
+ if ( my_status_dump(havege_state, status_buf, status_buf_size) > 0 )
+ fprintf(stderr,"%s\n", status_buf);
+ for (i=0;i<1024;i++) {
+
+ rc = havege_rng(havege_state, buf, size);
+ if ( rc != (int) size ) {
+ fprintf(stderr, "ERROR: havege_rng has returned %d\n", havege_state->error);
+ havege_destroy(havege_state);
+ return 1;
+ }
+
+ rc = fwrite(buf, 1, size, stdout);
+ if ( rc < size ) {
+ fprintf(stderr, "ERROR: fwrite\n");
+ havege_destroy(havege_state);
+ return 1;
+ }
+ }
+
+ if ( my_status_dump(havege_state, status_buf, status_buf_size) > 0 )
+ fprintf(stderr,"%s\n", status_buf);
+ havege_destroy(havege_state);
+ return 0;
+}
+
+
diff --git a/contrib/build/lib.spec b/contrib/build/lib.spec
new file mode 100644
index 0000000..e278101
--- /dev/null
+++ b/contrib/build/lib.spec
@@ -0,0 +1,76 @@
+#
+# Sample spec file for haveged and haveged-devel
+# Copyright (c) 2013-2014
+# This file and all modifications and additions to the pristine
+# package are under the same license as the package itself.
+#
+%define have_systemd 0
+
+Name: haveged
+Version: 1.9
+Release: 0
+License: GPLv3
+Group: System Environment/Daemons
+Summary: Feed entropy into random pool
+URL: http://www.issihosts.com/haveged/
+Source0: http://www.issihosts.com/haveged/haveged-%{version}.tar.gz
+BuildRoot: %{_builddir}/%{name}-root
+%if 0%{?have_systemd}
+BuildRequires: systemd
+%endif
+
+%description
+The haveged daemon feeds the linux entropy pool with random
+numbers generated from hidden processor state.
+
+%package devel
+Summary: haveged development files
+Group: Development/Libraries
+
+%description devel
+Headers and shared object symbolic links for the haveged library
+
+This package contains the haveged implementation of the HAVEGE
+algorithm and supporting features.
+
+%prep
+%setup -q
+
+%build
+%configure \
+ --enable-daemon\
+ --enable--init=sysv.redhat
+make
+
+%check
+make check
+
+%install
+%makeinstall
+%{__install} -D -m0755 %{_sysconfdir}/init.d/%{name}
+%if 0%{?have_systemd}
+%{__install} -D -m0644 %{S:2} %{buildroot}%{_unitdir}/%{name}.service
+%endif
+%{__rm} -f %{buildroot}%{_libdir}/libhavege.*a
+
+%clean
+%{?buildroot:%__rm -rf "%{buildroot}"}
+
+%files
+%defattr(-, root, root, -)
+%doc COPYING
+%{_mandir}/man8/haveged.8*
+%{_sbindir}/haveged
+%if 0%{?have_systemd}
+%{_unitdir}/haveged.service
+%endif
+
+%files devel
+%doc COPYING
+%defattr(-, root, root, -)
+%{_mandir}/man3/libhavege.3*
+%dir %{_includedir}/%{name}
+%{_includedir}/%{name}/havege*.h
+%doc contrib/build/havege_sample.c
+%{_libdir}/*.so*
+
diff --git a/contrib/build/nolib.spec b/contrib/build/nolib.spec
new file mode 100644
index 0000000..1e08735
--- /dev/null
+++ b/contrib/build/nolib.spec
@@ -0,0 +1,40 @@
+#
+# Sample spec file for haveged
+# Copyright (c) 2013-2014
+# This file and all modifications and additions to the pristine
+# package are under the same license as the package itself.
+#
+Name: haveged
+Version: 1.9
+Release: 1
+License: GPLv3
+Group: System Environment/Daemons
+Summary: Feed entropy into random pool
+URL: http://www.issihosts.com/haveged/
+Source0: http://www.issihosts.com/haveged/haveged-%{version}.tar.gz
+BuildRoot: %{_builddir}/%{name}-root
+
+%description
+The haveged daemon feeds the linux entropy pool with random
+numbers generated from hidden processor state.
+
+%prep
+%setup -q
+
+%build
+./configure
+make
+make check
+
+%install
+[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%clean
+[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+/usr/local/sbin/haveged
+/usr/local/share/man/man8/haveged.8
+/etc/init.d/haveged