From d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb Mon Sep 17 00:00:00 2001 From: PKI Team Date: Tue, 18 Mar 2008 22:36:57 +0000 Subject: Initial open source version based upon proprietary Red Hat Certificate System (RHCS) 7.3. git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@2 c9f7a03b-bd48-0410-a16d-cbbf54688b0b --- pki/linux/setup/build_linux | 38 ++++ pki/linux/setup/config-ext/build_linux_pki | 318 +++++++++++++++++++++++++++++ pki/linux/setup/config/product.xml | 305 +++++++++++++++++++++++++++ pki/linux/setup/config/release.xml | 86 ++++++++ pki/linux/setup/pki-setup.spec | 223 ++++++++++++++++++++ 5 files changed, 970 insertions(+) create mode 100755 pki/linux/setup/build_linux create mode 100755 pki/linux/setup/config-ext/build_linux_pki create mode 100644 pki/linux/setup/config/product.xml create mode 100644 pki/linux/setup/config/release.xml create mode 100644 pki/linux/setup/pki-setup.spec (limited to 'pki/linux/setup') diff --git a/pki/linux/setup/build_linux b/pki/linux/setup/build_linux new file mode 100755 index 000000000..84726f767 --- /dev/null +++ b/pki/linux/setup/build_linux @@ -0,0 +1,38 @@ +#!/bin/bash +# BEGIN COPYRIGHT BLOCK +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# (C) 2007 Red Hat, Inc. +# All rights reserved. +# END COPYRIGHT BLOCK + +# Always switch into the base directory of this +# shell script prior to executing it so that all +# of its output is written to this directory +cd `dirname $0` + +# Retrieve the directory name housing this component +PWD=`pwd` + +# Set Linux component-specific environment variables +LINUX_BUILD_SCRIPT=`basename $0` +export LINUX_BUILD_SCRIPT +LINUX_COMPONENT=`basename ${PWD}` +export LINUX_COMPONENT +LINUX_SPECFILE="pki-setup.spec" +export LINUX_SPECFILE + +# Invoke the shared Linux PKI build script +config-ext/build_linux_pki $@ + diff --git a/pki/linux/setup/config-ext/build_linux_pki b/pki/linux/setup/config-ext/build_linux_pki new file mode 100755 index 000000000..d9ea91e8c --- /dev/null +++ b/pki/linux/setup/config-ext/build_linux_pki @@ -0,0 +1,318 @@ +#!/bin/bash +# BEGIN COPYRIGHT BLOCK +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# (C) 2007 Red Hat, Inc. +# All rights reserved. +# END COPYRIGHT BLOCK + +# Always switch into the base directory above this +# shared shell script prior to executing it so that +# all of its output is written to this directory +cd `dirname $0`/.. + +# Set pre-defined variables +# +# NOTE: Variables prefixed with "LINUX" are defined in the invoking script. +# Variables prefixed with "PKI" are defined in this shared script. +# Variables containing no prefix are reserved for the generated script. +# +PKI_ABORT_SCRIPT="false" +PKI_BASEDIR="../../.." +PKI_BUILD_XML=build.xml +PKI_DIR=pki +PKI_LINUX_DIR=linux +PKI_RELEASE_DIR=release +PKI_RELEASE_SCRIPT=release +PKI_SHARED_SCRIPT=`basename $0` +PKI_SRC_DIR=base + +# Check the values of the passed-in environment variables +if [ "${LINUX_BUILD_SCRIPT}" == "" ]; then + printf "ERROR: The 'LINUX_BUILD_SCRIPT' environment variable is undefined!\n" + PKI_ABORT_SCRIPT="true" +fi +if [ "${LINUX_COMPONENT}" == "" ]; then + printf "ERROR: The 'LINUX_COMPONENT' environment variable is undefined!\n" + PKI_ABORT_SCRIPT="true" +fi +if [ "${LINUX_SPECFILE}" == "" ]; then + printf "ERROR: The 'LINUX_SPECFILE' environment variable is undefined!\n" + PKI_ABORT_SCRIPT="true" +fi +if [ "${PKI_ABORT_SCRIPT}" == "true" ]; then + printf "\n" + printf "The '${PKI_SHARED_SCRIPT}' shared build script MUST be invoked by " + printf "a\nPKI component-specific build script (e. g. - '${LINUX_BUILD_SCRIPT}')\n" + printf "which defines ALL environment variables prefixed by 'LINUX'!\n" + exit 255 +fi + +# Compute remaining variables by assigning their values from the specfile +PKI_SOURCE_CODE_URL="https://pki-svn.fedora.redhat.com/svn/pki/trunk/${PKI_DIR}/${PKI_SRC_DIR}/${LINUX_COMPONENT}" +PKI_PRODUCT_UI_PREFIX=`grep " base_ui_prefix" ${LINUX_SPECFILE} | awk '{ print $3; }'` +PKI_PRODUCT_PREFIX=`grep " base_prefix" ${LINUX_SPECFILE} | awk '{ print $3; }'` +PKI_PRODUCT=`grep " base_component" ${LINUX_SPECFILE} | awk '{ print $3; }'` +if [ "${PKI_PRODUCT_UI_PREFIX}" != "" ]; then + PKI_PRODUCT_BUILD_XML="${PKI_BUILD_XML}" + PKI_PRODUCT_NAME="${PKI_PRODUCT_PREFIX}-${PKI_PRODUCT}" + PKI_PRODUCT_SOURCE_PATH="${PKI_DIR}/${PKI_LINUX_DIR}/${LINUX_COMPONENT}" +elif [ "${PKI_PRODUCT_PREFIX}" != "" ]; then + PKI_PRODUCT_BUILD_XML="${PKI_BASEDIR}/${PKI_DIR}/${PKI_SRC_DIR}/${LINUX_COMPONENT}/${PKI_BUILD_XML}" + PKI_PRODUCT_NAME="${PKI_PRODUCT_PREFIX}-${PKI_PRODUCT}" + PKI_PRODUCT_SOURCE_PATH="${PKI_DIR}/${PKI_SRC_DIR}/${LINUX_COMPONENT}" +else + PKI_PRODUCT_BUILD_XML="${PKI_BASEDIR}/${PKI_DIR}/${PKI_SRC_DIR}/${LINUX_COMPONENT}/${PKI_BUILD_XML}" + PKI_PRODUCT_NAME="${PKI_PRODUCT}" + PKI_PRODUCT_SOURCE_PATH="${PKI_DIR}/${PKI_SRC_DIR}/${LINUX_COMPONENT}" +fi +PKI_RELEASE_ROOT="${PKI_BASEDIR}/${PKI_RELEASE_DIR}/${PKI_PRODUCT_SOURCE_PATH}" +PKI_SOURCE_CODE_LOCAL_REPOSITORY="`pwd`/${PKI_BASEDIR}/${PKI_PRODUCT_SOURCE_PATH}" + +# Always check that local source code for this PKI component is available +if [ ! -d "${PKI_SOURCE_CODE_LOCAL_REPOSITORY}" ]; then + printf "Please checkout the '${LINUX_COMPONENT}' source code from:\n\n" + printf " '${PKI_SOURCE_CODE_URL}'\n\n" + printf "to:\n\n" + printf " '${PKI_SOURCE_CODE_LOCAL_REPOSITORY}'\n\n" + exit 255 +fi + +# Define awk scripts +check_targets=' +BEGIN { + success = "false"; +} + +{ + while( getline < FILENAME > 0 ) { + if( substr( $0, 0, 80 ) ~ "target name" ) { + start = substr( $0, + match( $0, "\"" ) + 1 ); + target = substr( start, + start, + match( start, "\"" ) - 1 ); + if( build_target == target ) { + success = "true"; + } + } + } +} + +END { + printf( "%s", success ); +}' + +display_targets='{ + while( getline < FILENAME > 0 ) { + if( substr( $0, 0, 80 ) ~ "target name" ) { + start = substr( $0, + match( $0, "\"" ) + 1 ); + target = substr( start, + start, + match( start, "\"" ) - 1 ); + } + if( substr( $0, 0, 80 ) ~ "description" ) { + start = substr( $0, + match( $0, "\"" ) + 1 ); + description[target] = substr( start, + start, + match( start, "\"" ) - 1 ); + printf( "'%20s' %s\n", target, description[target] ); + } + } +}' + +# Provide a usage function +usage() { + if [ $# -gt 0 ] ; then + echo + echo "$1" + fi + echo + echo "Usage: ${LINUX_BUILD_SCRIPT} [target]" + echo + echo " where [target] is one of the optional values:" + echo + echo " help --> display '${PKI_PRODUCT_NAME}' usage statement" + awk "$display_targets" ${PKI_PRODUCT_BUILD_XML} + echo + exit 255 +} + +# Verify that the appropriate number of +# command-line parameters have been entered +# and that a valid target has been specified +if [ $# -eq 0 ] ; then + RELEASE_TARGET=main + BUILD_TARGET="" +elif [ $# -eq 1 ] ; then + if [ "$1" == "help" ]; then + usage + else + SUCCESS=`awk -v build_target=$1 "$check_targets" ${PKI_PRODUCT_BUILD_XML}` + if [ "${SUCCESS}" == "false" ]; then + usage "ERROR: Invalid target '$1' specified for '${PKI_PRODUCT_NAME}'!" + else + RELEASE_TARGET=local + BUILD_TARGET="$1" + fi + fi +elif [ $# -gt 1 ] ; then + usage "ERROR: Too many parameters specified for '${PKI_PRODUCT_NAME}'!" +fi + +# This script may ONLY be run on Linux! +PKI_OS=`uname` +if [ "${PKI_OS}" != "Linux" ]; then + printf "The '${LINUX_BUILD_SCRIPT}' script is ONLY executable on a 'Linux' machine!\n" + exit 255 +fi + +# Always start with a new release root directory +rm -rf ${PKI_RELEASE_ROOT} +mkdir -p ${PKI_RELEASE_ROOT} + +# Copy the source code to the release root +cd ${PKI_BASEDIR} +find ${PKI_PRODUCT_SOURCE_PATH} -name .svn -prune -o -name *.swp -prune -o -print | cpio -pdum ${PKI_RELEASE_DIR} > /dev/null 2>&1 +cd - > /dev/null 2>&1 + +# Remove unused files +rm -rf ${PKI_RELEASE_ROOT}/build_* +rm -rf ${PKI_RELEASE_ROOT}/*.spec +if [ -d ${PKI_RELEASE_ROOT}/config-ext ]; then + rm -rf ${PKI_RELEASE_ROOT}/config-ext +fi + +# Create the default spec file +cp ${LINUX_SPECFILE} ${PKI_RELEASE_ROOT}/${PKI_PRODUCT_NAME}.spec + +# Use bash-specific syntax to create the default build script +cat >> ${PKI_RELEASE_ROOT}/${PKI_RELEASE_SCRIPT} << END_OF_SCRIPT +#!/bin/bash + +##################################################################### +### DO NOT EDIT! This script has been automatically generated! ### +##################################################################### + +# Always switch into the base directory of this +# shell script prior to executing it so that all +# of its output is written to this directory +cd \`dirname \$0\` + +# Set pre-defined variables +BUILD_SCRIPT=\`basename \$0\` +BUILD_XML=${PKI_BUILD_XML} +SPECFILE=${PKI_PRODUCT_NAME}.spec + +# Define awk scripts +check_targets=' +BEGIN { + success = "false"; +} + +{ + while( getline < FILENAME > 0 ) { + if( substr( \$0, 0, 80 ) ~ "target name" ) { + start = substr( \$0, + match( \$0, "\"" ) + 1 ); + target = substr( start, + start, + match( start, "\"" ) - 1 ); + if( build_target == target ) { + success = "true"; + } + } + } +} + +END { + printf( "%s", success ); +}' + +display_targets='{ + while( getline < FILENAME > 0 ) { + if( substr( \$0, 0, 80 ) ~ "target name" ) { + start = substr( \$0, + match( \$0, "\"" ) + 1 ); + target = substr( start, + start, + match( start, "\"" ) - 1 ); + } + if( substr( \$0, 0, 80 ) ~ "description" ) { + start = substr( \$0, + match( \$0, "\"" ) + 1 ); + description[target] = substr( start, + start, + match( start, "\"" ) - 1 ); + printf( "'%20s' %s\n", target, description[target] ); + } + } +}' + +# Provide a usage function +usage() { + if [ \$# -gt 0 ] ; then + echo + echo "\$1" + fi + echo + echo "Usage: \${BUILD_SCRIPT} [target]" + echo + echo " where [target] is one of the optional values:" + echo + echo " help --> display '${PKI_PRODUCT_NAME}' usage statement" + awk "\$display_targets" \${BUILD_XML} + echo + exit 255 +} + +# Verify that the appropriate number of +# command-line parameters have been entered +# and that a valid target has been specified +if [ \$# -eq 0 ] ; then + RELEASE_TARGET=main + BUILD_TARGET=main +elif [ \$# -eq 1 ] ; then + if [ "\$1" == "help" ]; then + usage + else + SUCCESS=\`awk -v build_target=\$1 "\$check_targets" \${BUILD_XML}\` + if [ "\${SUCCESS}" == "false" ]; then + usage "ERROR: Invalid target '\$1' specified for '${PKI_PRODUCT_NAME}'!" + else + RELEASE_TARGET=local + BUILD_TARGET="\$1" + fi + fi +elif [ \$# -gt 1 ] ; then + usage "ERROR: Too many parameters specified for '${PKI_PRODUCT_NAME}'!" +fi + +# This script may ONLY be run on Linux! +OS=\`uname\` +if [ "\${OS}" != "Linux" ]; then + printf "The '\${BUILD_SCRIPT}' script is ONLY executable on a 'Linux' machine!\n" + exit 255 +fi + +ant -f config/release.xml -Dbasedir=. -Dspecfile=\${SPECFILE} -Dtarget=\${BUILD_TARGET} \${RELEASE_TARGET} + +END_OF_SCRIPT +chmod 00755 ${PKI_RELEASE_ROOT}/${PKI_RELEASE_SCRIPT} + +cd ${PKI_RELEASE_ROOT} +./${PKI_RELEASE_SCRIPT} ${BUILD_TARGET} + diff --git a/pki/linux/setup/config/product.xml b/pki/linux/setup/config/product.xml new file mode 100644 index 000000000..33caf48ed --- /dev/null +++ b/pki/linux/setup/config/product.xml @@ -0,0 +1,305 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pki/linux/setup/config/release.xml b/pki/linux/setup/config/release.xml new file mode 100644 index 000000000..fc43aaeb7 --- /dev/null +++ b/pki/linux/setup/config/release.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pki/linux/setup/pki-setup.spec b/pki/linux/setup/pki-setup.spec new file mode 100644 index 000000000..806aa49cf --- /dev/null +++ b/pki/linux/setup/pki-setup.spec @@ -0,0 +1,223 @@ +# BEGIN COPYRIGHT BLOCK +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# (C) 2007 Red Hat, Inc. +# All rights reserved. +# END COPYRIGHT BLOCK + +############################################################################### +### D E F I N I T I O N S ### +############################################################################### + +## Entity Definitions +%define base_entity Dogtag +%define base_prefix pki + +## Product Definitions +%define base_system Certificate System +%define base_product PKI Instance Creation and Removal Scripts +%define base_component setup +%define base_pki %{base_entity} %{base_system} + +## Package Header Definitions +%define base_name %{base_prefix}-%{base_component} +%define base_version 1.0.0 +%define base_release 1 +%define base_group System Environment/Shells +%define base_vendor Red Hat, Inc. +%define base_license GPLv2 with exceptions +%define base_packager %{base_vendor} +%define base_summary %{base_pki} - %{base_product} +%define base_url http://pki-svn.fedora.redhat.com/wiki/PKI_Documentation + +## Helper Definitions +%define pki_ca %{base_entity} Certificate Authority +%define pki_drm %{base_entity} Data Recovery Manager +%define pki_ds Fedora Directory Server +%define pki_ocsp %{base_entity} Online Certificate Status Protocol Manager +%define pki_ra %{base_entity} Registration Authority +%define pki_tks %{base_entity} Token Key Service +%define pki_tps %{base_entity} Token Processing System + +## Don't build the debug packages +%define debug_package %{nil} + + +##===================## +## Linux Definitions ## +##===================## +%ifos Linux +## A distribution model is required on certain Linux operating systems! +## +## check for a pre-defined distribution model +%define undefined_distro %(test "%{dist}"="" && echo 1 || echo 0) +%if %{undefined_distro} +%define is_fedora %(test -e /etc/fedora-release && echo 1 || echo 0) +%if %{is_fedora} +## define a default distribution model on Fedora Linux +%define dist_prefix .fc +%define dist_version %(echo `rpm -qf --qf='%{VERSION}' /etc/fedora-release` | tr -d [A-Za-z]) +%define dist %{dist_prefix}%{dist_version} +%else +%define is_redhat %(test -e /etc/redhat-release && echo 1 || echo 0) +%if %{is_redhat} +## define a default distribution model on Red Hat Linux +%define dist_prefix .el +%define dist_version %(echo `rpm -qf --qf='%{VERSION}' /etc/redhat-release` | tr -d [A-Za-z]) +%define dist %{dist_prefix}%{dist_version} +%endif +%endif +%endif +%endif + + + +############################################################################### +### P A C K A G E H E A D E R ### +############################################################################### + +Name: %{base_name} +Version: %{base_version} +Release: %{base_release}%{?dist} +Summary: %{base_summary} +Vendor: %{base_vendor} +URL: %{base_url} +License: %{base_license} +Packager: %{base_packager} +Group: %{base_group} + + +## Without AutoReqProv: no, rpmbuild finds all sorts of crazy +## dependencies that we don't care about, and refuses to install +AutoReqProv: no + +BuildArch: noarch +BuildRoot: %{_builddir}/%{base_name}-root + + +## NOTE: This spec file may require a specific JDK, "gcc", and/or "gcc-c++" +## packages as well as the "rpm" and "rpm-build" packages. +## +## Technically, "ant" should not need to be in "BuildRequires" since +## it is the Java equivalent of "make" (and/or "Autotools"). +## +BuildRequires: ant >= 1.6.2 + +## Without Requires something, rpmbuild will abort! +Requires: %{base_prefix}-native-tools >= 1.0.0, perl >= 5.8.0 + + +## This package is non-relocatable! +#Prefix: + +Source0: %{base_name}-%{base_version}.tar.gz + +## This package currently contains no patches! +#Patch0: + + +%description +Public Key Infrastructure (PKI) setup scripts used to create and remove +instances from %{base_entity} PKI deployments. + + + +############################################################################### +### P R E P A R A T I O N & S E T U P ### +############################################################################### + +## On Linux systems, prep and setup expect there to be a Source file +## in the /usr/src/redhat/SOURCES directory - it will be unpacked +## in the _builddir (not BuildRoot) +%prep + + +%setup -q + + +## This package currently contains no patches! +#%patch0 +# patches + + + +############################################################################### +### B U I L D P R O C E S S ### +############################################################################### + +%build +ant -Dspecfile=%{base_name}.spec + + + +############################################################################### +### I N S T A L L A T I O N P R O C E S S ### +############################################################################### + +%install +cd dist/binary +unzip %{name}-%{version}.zip -d ${RPM_BUILD_ROOT} + + + +############################################################################### +### C L E A N U P P R O C E S S ### +############################################################################### + +%clean +rm -rf ${RPM_BUILD_ROOT} + + + +############################################################################### +### P R E & P O S T I N S T A L L / U N I N S T A L L S C R I P T S ### +############################################################################### + +## This package currently contains no pre-installation process! +#%pre + + +## This package currently contains no post-installation process! +#%post + + +## This package currently contains no pre-uninstallation process! +#%preun + + +## This package currently contains no post-uninstallation process! +#%postun + + + +############################################################################### +### I N V E N T O R Y O F F I L E S A N D D I R E C T O R I E S ### +############################################################################### + +%files +%attr(00755,root,root) %{_bindir}/* +%attr(-,root,root) %{_datadir}/doc/%{base_name}-%{base_version}/* +%attr(-,root,root) %{_datadir}/%{base_prefix}/scripts/* + + + +############################################################################### +### C H A N G E L O G ### +############################################################################### + +%changelog +* Tue Feb 19 2008 PKI Team 1.0.0-1 +- Initial open source version based upon proprietary + Red Hat Certificate System (RHCS) 7.3. + -- cgit