This series of patches modifies the method for generating RPMs to remove hard-coded directory structure expectations and some other minor clean ups.
Spencer Shimko (4): Switch rpm gen to use command-line macro defs. Add generated files to ignore list. Switch from curly braces to parens in Makefile Minor cleanups in Makefile
rhel6/src/.gitignore | 2 + rhel6/src/Makefile | 201 ++++++++++++-------- .../input/rpmbuild/scap-security-guide-alpha.spec | 11 +- 3 files changed, 132 insertions(+), 82 deletions(-)
Instead of relying on a user's ~/.rpmmacros file define macros via the command line thus avoiding any deps on user environment (aside from rpmbuild).
Additionally, gen the RPM from a src RPM ensuring the src RPM is suitable for distribution to vendors.
Signed-off-by: Spencer Shimko sshimko@tresys.com --- rhel6/src/Makefile | 97 ++++++++++++++----- .../input/rpmbuild/scap-security-guide-alpha.spec | 11 ++- 2 files changed, 78 insertions(+), 30 deletions(-)
diff --git a/rhel6/src/Makefile b/rhel6/src/Makefile index cc6f237..763a18a 100644 --- a/rhel6/src/Makefile +++ b/rhel6/src/Makefile @@ -1,8 +1,48 @@ +VERSION := 0.1 +RELEASE := 1 IN=input OUT=output TRANS=transforms REFS=references -DIST=scap-security-guide-alpha +PKGNAME := scap-security-guide +DIST := $(PKGNAME)-$(VERSION) + +ARCH := noarch +VENDOR := scap-security-guide +PACKAGER := scap-security-guide + +################################################### +# Used for rolling an RPM + +RPM_SPEC := ${IN}/rpmbuild/scap-security-guide-alpha.spec + +ROOT_DIR ?= ${CURDIR} +OUTPUT_DIR ?= ${ROOT_DIR} +SRPM_OUTPUT_DIR ?= ${OUTPUT_DIR} + +# This file will be created by tar'ing up ${OUT}/ +TARBALL = ${SRPM_OUTPUT_DIR}/${DIST}.tar.gz + +# exhaustive list of deps for the RPM, used to determine if RPM needs to be rebuilt +TAR_DEPS = $(wildcard $(DIST)/*) +RPM_DEPS := $(TARBALL) $(RPM_SPEC) Makefile + +RPM_TMPDIR ?= ${ROOT_DIR}/tmp +RPM_TOPDIR ?= ${RPM_TMPDIR}/src/redhat +RPM_BUILDROOT ?= ${RPM_TMPDIR}/rpm-buildroot + +MKDIR = test -d $(1) || mkdir -p $(1) + +RPMBUILD_ARGS := --define '_topdir ${RPM_TOPDIR}' --define '_tmppath ${RPM_TMPDIR}' + +define rpm-prep + $(call MKDIR,$(RPM_TOPDIR)/SOURCES) + $(call MKDIR,$(RPM_TOPDIR)/SPECS) + $(call MKDIR,$(RPM_TOPDIR)/BUILD) + $(call MKDIR,$(RPM_TOPDIR)/RPMS/$(ARCH)) + $(call MKDIR,$(RPM_TOPDIR)/SRPMS) +endef +
all: shorthand-guide shorthand2xccdf tables guide checks content dist rpm
@@ -21,12 +61,12 @@ checks: xmlwf ${IN}/checks/*.xml ${TRANS}/combinechecks.py ${IN}/checks > ${OUT}/rhel6-oval.xml xmllint --format --output ${OUT}/rhel6-oval.xml ${OUT}/rhel6-oval.xml -# SCC might return someday +# SCC might return someday
guide: shorthand-guide shorthand2xccdf oscap xccdf generate guide --profile allrules ${OUT}/rhel6-xccdf.xml > ${OUT}/rhel6-guide.html -# specifying a nonexistent profile, "allrules," to make oscap print all Rules +# specifying a nonexistent profile, "allrules," to make oscap print all Rules
# example, if needed: for converting XCCDF into shorthand #xccdf2shorthand: @@ -75,6 +115,9 @@ eval-common: oscap xccdf eval --profile common --results /tmp/results-test.xml ${OUT}/rhel6-xccdf-scap-security-guide.xml
dist: content guide tables + $(call MKDIR,${DIST}/guide) + $(call MKDIR,${DIST}/content) + $(call MKDIR,${DIST}/policytables) cp -r ${IN}/dist_template/ ${DIST}/ cp ${OUT}/rhel6-guide.html ${DIST}/guide cp ${OUT}/rhel6-xccdf-scap-security-guide.xml ${DIST}/content @@ -84,35 +127,37 @@ dist: content guide tables cp ${OUT}/rhel6-table-cnssrefs.html ${DIST}/policytables cp ${OUT}/rhel6-table-dcidrefs.html ${DIST}/policytables
-rpm: dist +tarball: ${TARBALL}
- # A few quick notes on preparing your system to build the SSG RPMs: - # (1) May the flies of a thousand horses annoy you for eternity - # if you build an RPM as root. Don't do it! - # (2) This build process assumes you have your rpmbuild structure setup - # $ sudo yum -y install rpm-build - # $ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} - # (3) The value if ${DIST} in this Makefile needs to match - # the %{name}-%{version} string from the .spec file, i.e. - # scap-security-guide-alpha - # (4) If you're making an RPM, chances are the code has changed. Make - # sure you update the %changelog in the .spec to reflect what's new +${TARBALL}: dist $(TAR_DEPS) + tar -czf $@ $(TAR_DEPS)
- # copy template .spec over to rpmbuild - cp ${IN}/rpmbuild/scap-security-guide-alpha.spec ${OUT}/ +srpm: ${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm
- # tar up the sources - tar -zcvf ${OUT}/scap-security-guide-alpha.tar.gz ${DIST} - mv ${OUT}/scap-security-guide-alpha.tar.gz ~/rpmbuild/SOURCES/ - - # let's see if a build works - rpmbuild -ba ${OUT}/scap-security-guide-alpha.spec +${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm: $(RPM_DEPS) + echo "Building ${PKGNAME} SRPM..." + $(call rpm-prep) + cp ${TARBALL} ${RPM_TOPDIR}/SOURCES/ + echo -e "%define arch $(ARCH)\n%define pkgname ${PKGNAME}\n%define _sysconfdir /etc\n%define version ${VERSION}\n%define release ${RELEASE}\n%define vendor ${VENDOR}\n%define packager ${PACKAGER}" > ${RPM_TOPDIR}/SPECS/$(notdir ${RPM_SPEC}) + cat ${RPM_SPEC} >> ${RPM_TOPDIR}/SPECS/$(notdir ${RPM_SPEC}) + cd ${RPM_TOPDIR} && rpmbuild ${RPMBUILD_ARGS} --target=$(ARCH) -bs SPECS/$(notdir ${RPM_SPEC}) --nodeps + mv ${RPM_TOPDIR}/SRPMS/${DIST}-${RELEASE}.src.rpm ${SRPM_OUTPUT_DIR}
- # Our RPM(s) will be waiting for us in ${HOMEDIR}, so copy them back - mv ~/rpmbuild/RPMS/ ${OUT}/ +rpm: ${OUTPUT_DIR}/${DIST}-${RELEASE}.$(ARCH).rpm
+${OUTPUT_DIR}/${DIST}-${RELEASE}.$(ARCH).rpm: ${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm + @echo "Building ${DIST} RPM..." + $(call rpm-prep) + cd ${RPM_TOPDIR}/SRPMS && rpmbuild --rebuild --target=$(ARCH) ${RPMBUILD_ARGS} --buildroot ${RPM_BUILDROOT} -bb $< + mv ${RPM_TOPDIR}/RPMS/$(ARCH)/${DIST}-${RELEASE}*.rpm ${OUTPUT_DIR}
clean: rm -f ${OUT}/*.xml ${OUT}/*.html ${OUT}/*.pdf ${OUT}/*.spec ${OUT}/*.tar ${OUT}/*.gz ${OUT}/*.ini rm -rf ${DIST}/ - rm -rf ${OUT}/RPMS/ + rm -rf ${RPM_TMPDIR} + +bare: clean + rm -rf $(TARBALL) $(OUTPUT_DIR)/$(notdir ${OUTPUT_DIR}/${DIST}-${RELEASE}.$(ARCH).rpm) + rm -rf $(OUTPUT_DIR)/$(notdir ${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm) + +.PHONY: rpm srpm tarball clean all shorthand-guide shorthand2xccdf checks guide table-profilenistrefs table-refs table-srgmap tables content validate eval-test eval-ftp eval-common diff --git a/rhel6/src/input/rpmbuild/scap-security-guide-alpha.spec b/rhel6/src/input/rpmbuild/scap-security-guide-alpha.spec index 01ad83f..b97debf 100644 --- a/rhel6/src/input/rpmbuild/scap-security-guide-alpha.spec +++ b/rhel6/src/input/rpmbuild/scap-security-guide-alpha.spec @@ -1,6 +1,6 @@ Name: scap-security-guide -Version: alpha -Release: 1%{?dist} +Version: %{version} +Release: %{release} Summary: The scap-security-guide project, or SSG for short, aims to deliver security guidance, baselines, and associated validation mechanisms for Red Hat Enterprise Linux.
Group: Testing @@ -10,7 +10,7 @@ URL: https://fedorahosted.org/scap-security-guide/ Source0: %{name}-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-BuildArch: noarch +BuildArch: %{arch}
BuildRequires: /bin/rm, /bin/mkdir, /bin/cp Requires: /bin/bash, /bin/date, /usr/bin/oscap @@ -29,7 +29,7 @@ you will be able to find documentation, support, and information on getting involved in the SCAP Security Guide community.
%prep -%setup -q +%setup -q
%build @@ -60,5 +60,8 @@ rm -rf $RPM_BUILD_ROOT %attr(0750,root,root)/usr/local/scap-security-guide/
%changelog +* Thu Apr 19 2012 Spencer Shimko sshimko@tresys.com 1.0-2 +- Minor updates to pass some variables in from build system. + * Mon Apr 02 2012 Shawn Wells shawn@redhat.com 1.0-1 - First attempt at SSG RPM. May ${diety} help us...
We are generating some RPMs and tarballs. Ignore these for git commits.
Signed-off-by: Spencer Shimko sshimko@tresys.com --- rhel6/src/.gitignore | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/rhel6/src/.gitignore b/rhel6/src/.gitignore index 4852292..6d2e685 100644 --- a/rhel6/src/.gitignore +++ b/rhel6/src/.gitignore @@ -1 +1,3 @@ scap-security-guide-*/ +*.gz +*.rpm
I haven't seen this before but it looks like curly braces causes variables to be treated as simply expanded variables even if they are declared with a " = " instead of " := ". We need certain variables to be recursively expanded vars so might as well switch to parens everywhere to make things consistent and less error-prone.
Signed-off-by: Spencer Shimko sshimko@tresys.com --- rhel6/src/Makefile | 146 ++++++++++++++++++++++++++-------------------------- 1 files changed, 73 insertions(+), 73 deletions(-)
diff --git a/rhel6/src/Makefile b/rhel6/src/Makefile index 763a18a..0ac5e5c 100644 --- a/rhel6/src/Makefile +++ b/rhel6/src/Makefile @@ -14,26 +14,26 @@ PACKAGER := scap-security-guide ################################################### # Used for rolling an RPM
-RPM_SPEC := ${IN}/rpmbuild/scap-security-guide-alpha.spec +RPM_SPEC := $(IN)/rpmbuild/scap-security-guide-alpha.spec
-ROOT_DIR ?= ${CURDIR} -OUTPUT_DIR ?= ${ROOT_DIR} -SRPM_OUTPUT_DIR ?= ${OUTPUT_DIR} +ROOT_DIR ?= $(CURDIR) +OUTPUT_DIR ?= $(ROOT_DIR) +SRPM_OUTPUT_DIR ?= $(OUTPUT_DIR)
-# This file will be created by tar'ing up ${OUT}/ -TARBALL = ${SRPM_OUTPUT_DIR}/${DIST}.tar.gz +# This file will be created by tar'ing up $(OUT)/ +TARBALL = $(SRPM_OUTPUT_DIR)/$(DIST).tar.gz
# exhaustive list of deps for the RPM, used to determine if RPM needs to be rebuilt TAR_DEPS = $(wildcard $(DIST)/*) RPM_DEPS := $(TARBALL) $(RPM_SPEC) Makefile
-RPM_TMPDIR ?= ${ROOT_DIR}/tmp -RPM_TOPDIR ?= ${RPM_TMPDIR}/src/redhat -RPM_BUILDROOT ?= ${RPM_TMPDIR}/rpm-buildroot +RPM_TMPDIR ?= $(ROOT_DIR)/tmp +RPM_TOPDIR ?= $(RPM_TMPDIR)/src/redhat +RPM_BUILDROOT ?= $(RPM_TMPDIR)/rpm-buildroot
MKDIR = test -d $(1) || mkdir -p $(1)
-RPMBUILD_ARGS := --define '_topdir ${RPM_TOPDIR}' --define '_tmppath ${RPM_TMPDIR}' +RPMBUILD_ARGS := --define '_topdir $(RPM_TOPDIR)' --define '_tmppath $(RPM_TMPDIR)'
define rpm-prep $(call MKDIR,$(RPM_TOPDIR)/SOURCES) @@ -47,51 +47,51 @@ endef all: shorthand-guide shorthand2xccdf tables guide checks content dist rpm
shorthand-guide: - xsltproc -o ${OUT}/rhel6-shorthand.xml ${IN}/guide.xslt ${IN}/guide.xml - xmllint --format --output ${OUT}/rhel6-shorthand.xml ${OUT}/rhel6-shorthand.xml + xsltproc -o $(OUT)/rhel6-shorthand.xml $(IN)/guide.xslt $(IN)/guide.xml + xmllint --format --output $(OUT)/rhel6-shorthand.xml $(OUT)/rhel6-shorthand.xml
shorthand2xccdf: - xsltproc -o ${OUT}/rhel6-xccdf-noprofiles.xml ${TRANS}/shorthand2xccdf.xslt ${OUT}/rhel6-shorthand.xml - xsltproc -stringparam profile "allprofiles" -o ${OUT}/rhel6-xccdf.xml ${TRANS}/xccdf-addprofiles.xslt ${OUT}/rhel6-xccdf-noprofiles.xml - xsltproc -stringparam fixes "../${IN}/fixes/bash-ks.xml" -o ${OUT}/rhel6-xccdf.xml ${TRANS}/xccdf-addfixes.xslt ${OUT}/rhel6-xccdf.xml -# xsltproc -stringparam fixes "../${IN}/fixes/puppet-example.xml" -o ${OUT}/rhel6-xccdf.html ${TRANS}/xccdf-addfixes.xslt ${OUT}/rhel6-xccdf.xml - xmllint --format --output ${OUT}/rhel6-xccdf.xml ${OUT}/rhel6-xccdf.xml + xsltproc -o $(OUT)/rhel6-xccdf-noprofiles.xml $(TRANS)/shorthand2xccdf.xslt $(OUT)/rhel6-shorthand.xml + xsltproc -stringparam profile "allprofiles" -o $(OUT)/rhel6-xccdf.xml $(TRANS)/xccdf-addprofiles.xslt $(OUT)/rhel6-xccdf-noprofiles.xml + xsltproc -stringparam fixes "../$(IN)/fixes/bash-ks.xml" -o $(OUT)/rhel6-xccdf.xml $(TRANS)/xccdf-addfixes.xslt $(OUT)/rhel6-xccdf.xml +# xsltproc -stringparam fixes "../$(IN)/fixes/puppet-example.xml" -o $(OUT)/rhel6-xccdf.html $(TRANS)/xccdf-addfixes.xslt $(OUT)/rhel6-xccdf.xml + xmllint --format --output $(OUT)/rhel6-xccdf.xml $(OUT)/rhel6-xccdf.xml
checks: - xmlwf ${IN}/checks/*.xml - ${TRANS}/combinechecks.py ${IN}/checks > ${OUT}/rhel6-oval.xml - xmllint --format --output ${OUT}/rhel6-oval.xml ${OUT}/rhel6-oval.xml + xmlwf $(IN)/checks/*.xml + $(TRANS)/combinechecks.py $(IN)/checks > $(OUT)/rhel6-oval.xml + xmllint --format --output $(OUT)/rhel6-oval.xml $(OUT)/rhel6-oval.xml # SCC might return someday
guide: shorthand-guide shorthand2xccdf - oscap xccdf generate guide --profile allrules ${OUT}/rhel6-xccdf.xml > ${OUT}/rhel6-guide.html + oscap xccdf generate guide --profile allrules $(OUT)/rhel6-xccdf.xml > $(OUT)/rhel6-guide.html # specifying a nonexistent profile, "allrules," to make oscap print all Rules
# example, if needed: for converting XCCDF into shorthand #xccdf2shorthand: -# xsltproc -o ${XCCDF_OUTPUT_DIR}/rhel5-shorthand.xml ${TRANS}/xccdf2shorthand.xslt ${REFS}/usgcb-rhel5desktop-xccdf.xml -# tidy -m -xml -utf8 --indent-spaces=0 ${XCCDF_OUTPUT_DIR}/rhel5-shorthand.xml +# xsltproc -o $(XCCDF_OUTPUT_DIR)/rhel5-shorthand.xml $(TRANS)/xccdf2shorthand.xslt $(REFS)/usgcb-rhel5desktop-xccdf.xml +# tidy -m -xml -utf8 --indent-spaces=0 $(XCCDF_OUTPUT_DIR)/rhel5-shorthand.xml
table-profilenistrefs: shorthand-guide shorthand2xccdf -# xsltproc -o ${POLICYMAPPING_OUTPUT_DIR}/rhel6-table-nistrefs.html ${TRANS}/xccdf2table-nistrefs.xslt ${XCCDF_OUTPUT_DIR}/rhel6-xccdf.xml - xsltproc -stringparam profile "desktop" -o ${OUT}/rhel6-table-nistrefs-desktop.html ${TRANS}/xccdf2table-profilenistrefs.xslt ${OUT}/rhel6-xccdf.xml - xsltproc -stringparam profile "server" -o ${OUT}/rhel6-table-nistrefs-server.html ${TRANS}/xccdf2table-profilenistrefs.xslt ${OUT}/rhel6-xccdf.xml - xsltproc -stringparam profile "common" -o ${OUT}/rhel6-table-nistrefs-common.html ${TRANS}/xccdf2table-profilenistrefs.xslt ${OUT}/rhel6-xccdf.xml - xsltproc -stringparam profile "ftp" -o ${OUT}/rhel6-table-nistrefs-ftp.html ${TRANS}/xccdf2table-profilenistrefs.xslt ${OUT}/rhel6-xccdf.xml +# xsltproc -o $(POLICYMAPPING_OUTPUT_DIR)/rhel6-table-nistrefs.html $(TRANS)/xccdf2table-nistrefs.xslt $(XCCDF_OUTPUT_DIR)/rhel6-xccdf.xml + xsltproc -stringparam profile "desktop" -o $(OUT)/rhel6-table-nistrefs-desktop.html $(TRANS)/xccdf2table-profilenistrefs.xslt $(OUT)/rhel6-xccdf.xml + xsltproc -stringparam profile "server" -o $(OUT)/rhel6-table-nistrefs-server.html $(TRANS)/xccdf2table-profilenistrefs.xslt $(OUT)/rhel6-xccdf.xml + xsltproc -stringparam profile "common" -o $(OUT)/rhel6-table-nistrefs-common.html $(TRANS)/xccdf2table-profilenistrefs.xslt $(OUT)/rhel6-xccdf.xml + xsltproc -stringparam profile "ftp" -o $(OUT)/rhel6-table-nistrefs-ftp.html $(TRANS)/xccdf2table-profilenistrefs.xslt $(OUT)/rhel6-xccdf.xml
table-refs: shorthand-guide shorthand2xccdf - xsltproc -stringparam ref "nist" -o ${OUT}/rhel6-table-nistrefs.html ${TRANS}/xccdf2table-byref.xslt ${OUT}/rhel6-xccdf.xml - xsltproc -stringparam ref "cnss" -o ${OUT}/rhel6-table-cnssrefs.html ${TRANS}/xccdf2table-byref.xslt ${OUT}/rhel6-xccdf.xml - xsltproc -stringparam ref "dcid" -o ${OUT}/rhel6-table-dcidrefs.html ${TRANS}/xccdf2table-byref.xslt ${OUT}/rhel6-xccdf.xml + xsltproc -stringparam ref "nist" -o $(OUT)/rhel6-table-nistrefs.html $(TRANS)/xccdf2table-byref.xslt $(OUT)/rhel6-xccdf.xml + xsltproc -stringparam ref "cnss" -o $(OUT)/rhel6-table-cnssrefs.html $(TRANS)/xccdf2table-byref.xslt $(OUT)/rhel6-xccdf.xml + xsltproc -stringparam ref "dcid" -o $(OUT)/rhel6-table-dcidrefs.html $(TRANS)/xccdf2table-byref.xslt $(OUT)/rhel6-xccdf.xml # break apart references by delimiter: - xsltproc -stringparam ref "nist" -stringparam delim "," -o ${OUT}/rhel6-table-nistrefs-delim.html ${TRANS}/xccdf2table-byref.xslt ${OUT}/rhel6-xccdf.xml + xsltproc -stringparam ref "nist" -stringparam delim "," -o $(OUT)/rhel6-table-nistrefs-delim.html $(TRANS)/xccdf2table-byref.xslt $(OUT)/rhel6-xccdf.xml # then sort them: - xsltproc --html -o ${OUT}/rhel6-table-nistrefs-delim-sorted.html ${TRANS}/table-sortbyref.xslt ${OUT}/rhel6-table-nistrefs-delim.html + xsltproc --html -o $(OUT)/rhel6-table-nistrefs-delim-sorted.html $(TRANS)/table-sortbyref.xslt $(OUT)/rhel6-table-nistrefs-delim.html
table-srgmap: shorthand-guide shorthand2xccdf # the map-to-rules filename must be provided relative to the root of the main document being processed - xsltproc -stringparam map-to-rules "../${OUT}/rhel6-xccdf.xml" -o ${OUT}/rhel6-table-srgmap.html ${TRANS}/table-srgmap.xslt ${REFS}/disa-os-srg-v1r1.xml + xsltproc -stringparam map-to-rules "../$(OUT)/rhel6-xccdf.xml" -o $(OUT)/rhel6-table-srgmap.html $(TRANS)/table-srgmap.xslt $(REFS)/disa-os-srg-v1r1.xml
tables: table-refs table-profilenistrefs table-srgmap
@@ -99,65 +99,65 @@ content: shorthand-guide shorthand2xccdf checks # the relabelids.py script chdirs to ./output, so refer to files from there. # the second argument controls the IDs, as well as the output filenames. # thus, this creates rhel6-xccdf-scap-security-guide.xml and rhel6-oval-scap-security-guide.xml. - ${TRANS}/relabelids.py rhel6-xccdf.xml scap-security-guide + $(TRANS)/relabelids.py rhel6-xccdf.xml scap-security-guide
validate: - oscap xccdf validate-xml ${OUT}/rhel6-xccdf-scap-security-guide.xml - oscap oval validate-xml ${OUT}/rhel6-oval-scap-security-guide.xml + oscap xccdf validate-xml $(OUT)/rhel6-xccdf-scap-security-guide.xml + oscap oval validate-xml $(OUT)/rhel6-oval-scap-security-guide.xml
eval-test: - oscap xccdf eval --profile test ${OUT}/rhel6-xccdf-scap-security-guide.xml + oscap xccdf eval --profile test $(OUT)/rhel6-xccdf-scap-security-guide.xml
eval-ftp: - oscap xccdf eval --profile ftp ${OUT}/rhel6-xccdf-scap-security-guide.xml + oscap xccdf eval --profile ftp $(OUT)/rhel6-xccdf-scap-security-guide.xml
eval-common: - oscap xccdf eval --profile common --results /tmp/results-test.xml ${OUT}/rhel6-xccdf-scap-security-guide.xml + oscap xccdf eval --profile common --results /tmp/results-test.xml $(OUT)/rhel6-xccdf-scap-security-guide.xml
dist: content guide tables - $(call MKDIR,${DIST}/guide) - $(call MKDIR,${DIST}/content) - $(call MKDIR,${DIST}/policytables) - cp -r ${IN}/dist_template/ ${DIST}/ - cp ${OUT}/rhel6-guide.html ${DIST}/guide - cp ${OUT}/rhel6-xccdf-scap-security-guide.xml ${DIST}/content - cp ${OUT}/rhel6-oval-scap-security-guide.xml ${DIST}/content - cp ${OUT}/rhel6-table-nistrefs-delim-sorted.html ${DIST}/policytables - cp ${OUT}/rhel6-table-nistrefs.html ${DIST}/policytables - cp ${OUT}/rhel6-table-cnssrefs.html ${DIST}/policytables - cp ${OUT}/rhel6-table-dcidrefs.html ${DIST}/policytables - -tarball: ${TARBALL} - -${TARBALL}: dist $(TAR_DEPS) + $(call MKDIR,$(DIST)/guide) + $(call MKDIR,$(DIST)/content) + $(call MKDIR,$(DIST)/policytables) + cp -r $(IN)/dist_template/ $(DIST)/ + cp $(OUT)/rhel6-guide.html $(DIST)/guide + cp $(OUT)/rhel6-xccdf-scap-security-guide.xml $(DIST)/content + cp $(OUT)/rhel6-oval-scap-security-guide.xml $(DIST)/content + cp $(OUT)/rhel6-table-nistrefs-delim-sorted.html $(DIST)/policytables + cp $(OUT)/rhel6-table-nistrefs.html $(DIST)/policytables + cp $(OUT)/rhel6-table-cnssrefs.html $(DIST)/policytables + cp $(OUT)/rhel6-table-dcidrefs.html $(DIST)/policytables + +tarball: $(TARBALL) + +$(TARBALL): dist $(TAR_DEPS) tar -czf $@ $(TAR_DEPS)
-srpm: ${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm +srpm: $(SRPM_OUTPUT_DIR)/$(DIST)-$(RELEASE).src.rpm
-${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm: $(RPM_DEPS) - echo "Building ${PKGNAME} SRPM..." +$(SRPM_OUTPUT_DIR)/$(DIST)-$(RELEASE).src.rpm: $(RPM_DEPS) + echo "Building $(PKGNAME) SRPM..." $(call rpm-prep) - cp ${TARBALL} ${RPM_TOPDIR}/SOURCES/ - echo -e "%define arch $(ARCH)\n%define pkgname ${PKGNAME}\n%define _sysconfdir /etc\n%define version ${VERSION}\n%define release ${RELEASE}\n%define vendor ${VENDOR}\n%define packager ${PACKAGER}" > ${RPM_TOPDIR}/SPECS/$(notdir ${RPM_SPEC}) - cat ${RPM_SPEC} >> ${RPM_TOPDIR}/SPECS/$(notdir ${RPM_SPEC}) - cd ${RPM_TOPDIR} && rpmbuild ${RPMBUILD_ARGS} --target=$(ARCH) -bs SPECS/$(notdir ${RPM_SPEC}) --nodeps - mv ${RPM_TOPDIR}/SRPMS/${DIST}-${RELEASE}.src.rpm ${SRPM_OUTPUT_DIR} + cp $(TARBALL) $(RPM_TOPDIR)/SOURCES/ + echo -e "%define arch $(ARCH)\n%define pkgname $(PKGNAME)\n%define _sysconfdir /etc\n%define version $(VERSION)\n%define release $(RELEASE)\n%define vendor $(VENDOR)\n%define packager $(PACKAGER)" > $(RPM_TOPDIR)/SPECS/$(notdir $(RPM_SPEC)) + cat $(RPM_SPEC) >> $(RPM_TOPDIR)/SPECS/$(notdir $(RPM_SPEC)) + cd $(RPM_TOPDIR) && rpmbuild $(RPMBUILD_ARGS) --target=$(ARCH) -bs SPECS/$(notdir $(RPM_SPEC)) --nodeps + mv $(RPM_TOPDIR)/SRPMS/$(DIST)-$(RELEASE).src.rpm $(SRPM_OUTPUT_DIR)
-rpm: ${OUTPUT_DIR}/${DIST}-${RELEASE}.$(ARCH).rpm +rpm: $(OUTPUT_DIR)/$(DIST)-$(RELEASE).$(ARCH).rpm
-${OUTPUT_DIR}/${DIST}-${RELEASE}.$(ARCH).rpm: ${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm - @echo "Building ${DIST} RPM..." +$(OUTPUT_DIR)/$(DIST)-$(RELEASE).$(ARCH).rpm: $(SRPM_OUTPUT_DIR)/$(DIST)-$(RELEASE).src.rpm + @echo "Building $(DIST) RPM..." $(call rpm-prep) - cd ${RPM_TOPDIR}/SRPMS && rpmbuild --rebuild --target=$(ARCH) ${RPMBUILD_ARGS} --buildroot ${RPM_BUILDROOT} -bb $< - mv ${RPM_TOPDIR}/RPMS/$(ARCH)/${DIST}-${RELEASE}*.rpm ${OUTPUT_DIR} + cd $(RPM_TOPDIR)/SRPMS && rpmbuild --rebuild --target=$(ARCH) $(RPMBUILD_ARGS) --buildroot $(RPM_BUILDROOT) -bb $< + mv $(RPM_TOPDIR)/RPMS/$(ARCH)/$(DIST)-$(RELEASE)*.rpm $(OUTPUT_DIR)
clean: - rm -f ${OUT}/*.xml ${OUT}/*.html ${OUT}/*.pdf ${OUT}/*.spec ${OUT}/*.tar ${OUT}/*.gz ${OUT}/*.ini - rm -rf ${DIST}/ - rm -rf ${RPM_TMPDIR} + rm -f $(OUT)/*.xml $(OUT)/*.html $(OUT)/*.pdf $(OUT)/*.spec $(OUT)/*.tar $(OUT)/*.gz $(OUT)/*.ini + rm -rf $(DIST)/ + rm -rf $(RPM_TMPDIR)
bare: clean - rm -rf $(TARBALL) $(OUTPUT_DIR)/$(notdir ${OUTPUT_DIR}/${DIST}-${RELEASE}.$(ARCH).rpm) - rm -rf $(OUTPUT_DIR)/$(notdir ${SRPM_OUTPUT_DIR}/${DIST}-${RELEASE}.src.rpm) + rm -rf $(TARBALL) $(OUTPUT_DIR)/$(notdir $(OUTPUT_DIR)/$(DIST)-$(RELEASE).$(ARCH).rpm) + rm -rf $(OUTPUT_DIR)/$(notdir $(SRPM_OUTPUT_DIR)/$(DIST)-$(RELEASE).src.rpm)
.PHONY: rpm srpm tarball clean all shorthand-guide shorthand2xccdf checks guide table-profilenistrefs table-refs table-srgmap tables content validate eval-test eval-ftp eval-common
Remove some trailing whitespace as this can lead to problems as make never ignores a trailing space.
Fixup some variable declarations for consistency.
Signed-off-by: Spencer Shimko sshimko@tresys.com --- rhel6/src/Makefile | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/rhel6/src/Makefile b/rhel6/src/Makefile index 0ac5e5c..7eae8e0 100644 --- a/rhel6/src/Makefile +++ b/rhel6/src/Makefile @@ -1,9 +1,9 @@ VERSION := 0.1 RELEASE := 1 -IN=input -OUT=output -TRANS=transforms -REFS=references +IN = input +OUT = output +TRANS = transforms +REFS = references PKGNAME := scap-security-guide DIST := $(PKGNAME)-$(VERSION)
@@ -48,23 +48,23 @@ all: shorthand-guide shorthand2xccdf tables guide checks content dist rpm
shorthand-guide: xsltproc -o $(OUT)/rhel6-shorthand.xml $(IN)/guide.xslt $(IN)/guide.xml - xmllint --format --output $(OUT)/rhel6-shorthand.xml $(OUT)/rhel6-shorthand.xml + xmllint --format --output $(OUT)/rhel6-shorthand.xml $(OUT)/rhel6-shorthand.xml
shorthand2xccdf: xsltproc -o $(OUT)/rhel6-xccdf-noprofiles.xml $(TRANS)/shorthand2xccdf.xslt $(OUT)/rhel6-shorthand.xml xsltproc -stringparam profile "allprofiles" -o $(OUT)/rhel6-xccdf.xml $(TRANS)/xccdf-addprofiles.xslt $(OUT)/rhel6-xccdf-noprofiles.xml xsltproc -stringparam fixes "../$(IN)/fixes/bash-ks.xml" -o $(OUT)/rhel6-xccdf.xml $(TRANS)/xccdf-addfixes.xslt $(OUT)/rhel6-xccdf.xml # xsltproc -stringparam fixes "../$(IN)/fixes/puppet-example.xml" -o $(OUT)/rhel6-xccdf.html $(TRANS)/xccdf-addfixes.xslt $(OUT)/rhel6-xccdf.xml - xmllint --format --output $(OUT)/rhel6-xccdf.xml $(OUT)/rhel6-xccdf.xml + xmllint --format --output $(OUT)/rhel6-xccdf.xml $(OUT)/rhel6-xccdf.xml
checks: xmlwf $(IN)/checks/*.xml $(TRANS)/combinechecks.py $(IN)/checks > $(OUT)/rhel6-oval.xml - xmllint --format --output $(OUT)/rhel6-oval.xml $(OUT)/rhel6-oval.xml + xmllint --format --output $(OUT)/rhel6-oval.xml $(OUT)/rhel6-oval.xml # SCC might return someday
-guide: shorthand-guide shorthand2xccdf +guide: shorthand-guide shorthand2xccdf oscap xccdf generate guide --profile allrules $(OUT)/rhel6-xccdf.xml > $(OUT)/rhel6-guide.html # specifying a nonexistent profile, "allrules," to make oscap print all Rules
@@ -99,9 +99,9 @@ content: shorthand-guide shorthand2xccdf checks # the relabelids.py script chdirs to ./output, so refer to files from there. # the second argument controls the IDs, as well as the output filenames. # thus, this creates rhel6-xccdf-scap-security-guide.xml and rhel6-oval-scap-security-guide.xml. - $(TRANS)/relabelids.py rhel6-xccdf.xml scap-security-guide + $(TRANS)/relabelids.py rhel6-xccdf.xml scap-security-guide
-validate: +validate: oscap xccdf validate-xml $(OUT)/rhel6-xccdf-scap-security-guide.xml oscap oval validate-xml $(OUT)/rhel6-oval-scap-security-guide.xml
ACK. Please commit this and the rest in the batch.
On 04/20/2012 10:13 AM, Spencer Shimko wrote:
This series of patches modifies the method for generating RPMs to remove hard-coded directory structure expectations and some other minor clean ups.
Spencer Shimko (4): Switch rpm gen to use command-line macro defs. Add generated files to ignore list. Switch from curly braces to parens in Makefile Minor cleanups in Makefile
rhel6/src/.gitignore | 2 + rhel6/src/Makefile | 201 ++++++++++++-------- .../input/rpmbuild/scap-security-guide-alpha.spec | 11 +- 3 files changed, 132 insertions(+), 82 deletions(-)
scap-security-guide mailing list scap-security-guide@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/scap-security-guide
scap-security-guide@lists.fedorahosted.org