Add RPM build

This commit is contained in:
Derry Hamilton 2019-06-11 15:12:45 +01:00
parent bba3377b9e
commit 41f149f5ab
7 changed files with 145 additions and 46 deletions

6
build_util/build_in_docker Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
set -e
docker build --rm -t local/c7-buildhost docker
docker run -it -v `pwd`:/root/build local/c7-buildhost /root/build/build_util/build_rpm

12
build_util/build_rpm Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
set -e
cd /root
cp -Rv build build2
cd build2
SPEC=$(ls *.spec)
VER=$(grep Version $SPEC | awk '{print $2}')
tar cvf $HOME/rpmbuild/SOURCES/DataMigrator-${VER}.tar.gz --show-transformed --transform="s/^\./PPL_DataMigrationTools-${VER}/" .
rpmbuild -ba $SPEC
cp /root/rpmbuild/RPMS/x86_64/PPL_DataMigrationTools-* /root/build/

28
docker/Dockerfile Normal file
View file

@ -0,0 +1,28 @@
# General build RPM environment for CentOS 6.x
#
# VERSION 0.0.1
FROM centos:centos7
MAINTAINER Derry Hamilton <derryh@postcodelottery.co.uk>
# Install up-to-date epel rpm repository
RUN yum -y install epel-release
# Install various packages to get compile environment
RUN yum -y groupinstall 'Development Tools'
# Install git command to access GitHub repository
RUN yum -y install git
# Install rpm-build to use rpmrebuild command
RUN yum -y install rpm-build
# Install yum-utils to use yumdownloader command
RUN yum -y install yum-utils
# Install rpmdevtools to use rpmdev-setuptree command
RUN yum -y install rpmdevtools
# Install rpmdevtools to use rpmdev-setuptree command
RUN yum -y install maven
RUN mkdir -p /root/rpmbuild/SOURCES

View file

@ -0,0 +1,28 @@
log4j.rootLogger=info, stdout, R, SYSLOG
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=info
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
#log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %d - %m%n
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2} %x - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/tmp/DefaultCopyingApp.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c %d - %m%n
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.Threshold=info
log4j.appender.SYSLOG.syslogHost=localhost
log4j.appender.SYSLOG.Facility=LOCAL4
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.conversionPattern=%d{ISO8601} %-5p [%t] %c{2} %x - %m%n

38
install_extra/run_copying_job Executable file
View file

@ -0,0 +1,38 @@
#!/bin/bash
JOBNAME=${1:-undef}
if [ -z "${JOBNAME}" ]
then
echo "Job name not specified"
exit 1
fi
if [ ! -e "/etc/ujetl/${JOBNAME}_config_live.xml" ]
then
echo "Could not find config file for $JOBNAME"
exit 2
fi
LOG_PROPS=/etc/ujetl/copying_defaults_log4j.properties
if [ -e "/etc/ujetl/${JOBNAME}_log4j.properties" ]
then
echo Using log config "/etc/ujetl/${JOBNAME}_log4j.properties"
LOG_PROPS="/etc/ujetl/${JOBNAME}_log4j.properties"
else
echo Using default logging.
fi
#LOCKFILE=/tmp/"${JOBNAME}"_copying.lock
#/usr/bin/lockfile -r ${RETRIES:-"1"} $LOCKFILE || exit 1
#trap "rm -f $LOCKFILE; exit" INT TERM EXIT
/usr/bin/java \
-Xms1g \
-Xmx2g \
-cp /usr/share/ujetl/lib/CopyingApp.jar \
com.ujetl.data.CopyingApp \
--log4j "$LOG_PROPS" \
--config "/etc/ujetl/${JOBNAME}_config_live.xml"
#rm -f $LOCKFILE

View file

@ -1,46 +0,0 @@
#!/bin/bash
set -e
JOBNAME=${1:-undef}
if [ -z "${JOBNAME}" ]
then
echo "Job name not specified"
exit 1
fi
if [ ! -e "/etc/ujetl/${JOBNAME}_config_live.xml" ]
then
echo "Could not find config file for $JOBNAME"
exit 2
fi
LOG_PROPS=/etc/ujetl/copying_defaults_log4j.xml
if [ -e "/etc/ujetl/${JOBNAME}_log4j.xml" ]
then
echo Using log config "/etc/ujetl/${JOBNAME}_log4j.xml"
LOG_PROPS="/etc/ujetl/${JOBNAME}_log4j.xml"
else
echo Using default logging.
fi
test -e "$LOG_PROPS"
LOCKFILE=/tmp/"${JOBNAME}"_copying.lock
/usr/bin/lockfile -r ${RETRIES:-"1"} $LOCKFILE || exit 1
trap "rm -f $LOCKFILE; exit" INT TERM EXIT
/usr/bin/java \
-Xms1g \
-Xmx2g \
-jar target/CopyingApp-2.0.0-jar-with-dependencies.jar \
--log4j "$LOG_PROPS" \
--config "/etc/ujetl/${JOBNAME}_config_live.xml"
if [ -e "/etc/ujetl/${JOBNAME}_post.sql" ]
then
psql -f "/etc/ujetl/${JOBNAME}_post.sql" data_hub
fi
rm -f $LOCKFILE

33
uJETL.spec Normal file
View file

@ -0,0 +1,33 @@
Summary: Java app to facilitate moving data between databases.
Name: uJETL
Version: 2.0.0
Release: 1
Group: Applications/Database
License: All rights reserved.
Source: uJETL-%{version}.tar.gz
URL: https://github.com/rasilon/ujetl.git
Distribution: derryh
Vendor: derryh
Packager: Derry Hamilton <derryh@rasilon.net>
#BuildRoot: .
%description
A very small ETL app
%prep
%setup
%build
#mvn -Dmaven.test.skip=true clean package
true
%install
mkdir -p $RPM_BUILD_ROOT/usr/share/ujetl/lib $RPM_BUILD_ROOT/etc/ujetl $RPM_BUILD_ROOT/usr/bin
cp target/CopyingApp-*-jar-with-dependencies.jar $RPM_BUILD_ROOT/usr/share/ujetl/lib/CopyingApp.jar
cp install_extra/run_copying_job $RPM_BUILD_ROOT/usr/bin
cp install_extra/copying_defaults_log4j.properties $RPM_BUILD_ROOT/etc/ujetl
%files
/usr/share/ujetl/lib/CopyingApp.jar
/usr/bin/run_copying_job
/etc/ujetl/copying_defaults_log4j.properties