diff options
author | Mark Ferrell <major@homeonderanged.org> | 2014-01-31 09:07:02 -0800 |
---|---|---|
committer | Mark Ferrell <major@homeonderanged.org> | 2014-01-31 09:07:02 -0800 |
commit | c46b94b454b3510eb930f1cff427f3127f65e59c (patch) | |
tree | 6bb32d676e8e9489aecf137bf56dc6701681145f | |
parent | 350015ffde621989eee2d45d54f696ba2ecd1be8 (diff) |
Feature: ability to export binary packages as RPM's
* While LICENSE is usually an optional package variable, it is required when
exporting packages to an RPM.
* In the future it may be worth-while to support exporting to other package
formats.
-rwxr-xr-x | build | 2 | ||||
-rwxr-xr-x | builder/build-export | 90 | ||||
-rwxr-xr-x | builder/build-makedeps | 16 |
3 files changed, 106 insertions, 2 deletions
@@ -55,6 +55,8 @@ Commands distclean Clean up specified package from sysroot, artifacts, and sources. + export Export the binary package to an rpm. + EOF } diff --git a/builder/build-export b/builder/build-export new file mode 100755 index 0000000..a873b4e --- /dev/null +++ b/builder/build-export @@ -0,0 +1,90 @@ +#!/usr/bin/env build + +import "${1}" + +if test -z "${LICENSE}"; then + die "no license set in '${1}'" +fi + +echo "exporting ${1}" + +for dir in "${S}" "${D}"; do + if ! test -d "${dir}"; then + continue + fi + mv "${dir}" "${dir}.old" + find "${dir}.old" -delete & +done +unset dir + +mkenv 'export' +EXPORT_LOGFILE="${L}/export.log" + +mkdir -p "${T}/${NAME}-${VERSION}.builder" +cp "${RULESFILE}" "${T}/${NAME}-${VERSION}.builder/" + +if ! test -z "${PATCHES}"; then + for patch in ${PATCHES}; do + cp "${F}/${NAME}-${VERSION}-${patch}.patch" "${T}/${NAME}-${VERSION}.builder/" + done +fi + +cd "${T}" + +for url in ${SOURCE_URI}; do + file="$(build-fetch --name "${url}")" + test -f "${BUILDER_SRCDIR}/${file}" || die "source does not exist '${file}'" + cp "${BUILDER_SRCDIR}/${file}" "${NAME}-${VERSION}.builder/" +done + +for dir in SOURCES SPECS RPMS BUILD; do + mkdir -p "${S}/${dir}" & +done +wait + +if ! tar czf "${S}/SOURCES/${NAME}-${VERSION}.builder.tar.gz" "${NAME}-${VERSION}.builder"; then + die "Failed to create base rpm tarball." +fi + +cat <<EOF > "${S}/SPECS/${NAME}-${VERSION}.spec" +Summary: ${DESCRIPTION} +Name: ${NAME} +Version: ${VERSION} +Release: ${RELEASE} +License: ${LICENSE} +Group: ${CATEGORY} +Source: ${NAME}-${VERSION}.builder.tar.gz +Buildroot: ${SYSROOT} +%description +${DESCRIPTION} + +%prep +%setup -c + +%build + +%install + +%clean + +%files +EOF +tr '\000' '\n' < "${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" | sed -e 's,^,/,' >> "${S}/SPECS/${NAME}-${VERSION}.spec" + +#mkdir -p "${D}" +#cd "${D}" +#tar xaf "${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}.${ARCHIVE_FORMAT}" + +rpmbuild --quiet --target "${CHOST}" \ + --define "_topdir ${S}" \ + --define "buildroot ${SYSROOT}" \ + --define '_unpackaged_files_terminate_build 0' \ + --define '_missing_doc_files_terminate_build 0' \ + --define "arch ${CHOST%%-*}" \ + -bb "${S}/SPECS/${NAME}-${VERSION}.spec" > "${L}/export.log" 2>&1 || die "Failed to integrate rpm spec file" + +mkdir -p "${BUILDER_TOPDIR}/exports" +# FIXME figure out the arch properly +mv "${S}/RPMS/${CHOST%%-*}/${NAME}-${VERSION}-${RELEASE}.${CHOST%%-*}.rpm" "${BUILDER_TOPDIR}/exports/" || die "Failed to move rpm" + +# vim: filetype=sh diff --git a/builder/build-makedeps b/builder/build-makedeps index e4b628c..b1624a9 100755 --- a/builder/build-makedeps +++ b/builder/build-makedeps @@ -6,6 +6,7 @@ all: ${PROJECT}_archive all_fetch: ${PROJECT}_all_fetch all_archive: ${PROJECT}_all_archive all_install: ${PROJECT}_all_install +all_export: ${PROJECT}_all_export all_makedeps: all_source: @@ -24,6 +25,11 @@ tmpdir_clean: echo "cleaning: tmpdir" ; \ find "${BUILDER_TMPDIR}" -delete ; \ fi +exports_clean: + @if test -d "${BUILDER_TOPDIR}/exports"; then \ + echo "cleaning: exports" ; \ + find "${BUILDER_TOPDIR}/exports" -delete ; \ + fi EOF PACKAGES_CLEAN= @@ -39,6 +45,7 @@ for package in $(cd "${BUILDER_PKGDIR}" && echo */*); do package_make="$(echo "${package}"|tr '/-' '__')" package_archive="${BUILDER_ATFDIR}/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${ARCHIVE_FORMAT}" package_install="${SYSROOT}/var/db/binpkgs/${CATEGORY}/${NAME}" + package_export="${BUILDER_TOPDIR}/exports/${CATEGORY}/${NAME}-${VERSION}-${RELEASE}.${CHOST%%-*}.rpm" package_logdir="${L}" package_sources="${RULESFILE}" @@ -126,6 +133,9 @@ ${package_archive}: ${package_sources} ${package_bdeps} ${package_make}_install: ${package_install} ${package_install}: ${package_archive} ${package_rdeps} @build-install "${CATEGORY}/${NAME}" +${package_make}_export: ${package_export} +${package_export}: ${package_install} + @build-export "${CATEGORY}/${NAME}" EOF ## @@ -164,6 +174,7 @@ EOF eval "${category}_SOURCES=\"\${${category}_SOURCES} ${package_sources}\"" eval "${category}_PACKAGES=\"\${${category}_PACKAGES} ${package_archive}\"" eval "${category}_INSTALL=\"\${${category}_INSTALL} ${package_install}\"" + eval "${category}_EXPORT=\"\${${category}_EXPORT} ${package_export}\"" eval "${category}_CLEAN=\"\${${category}_CLEAN} ${package_make}_clean\"" eval "${category}_DISTCLEAN=\"\${${category}_DISTCLEAN} ${package_make}_distclean\"" @@ -180,6 +191,7 @@ ${CATEGORY}_all: ${CATEGORY}_archive ${CATEGORY}_all_fetch: $(eval echo "\${${CATEGORY}_SOURCES}") ${CATEGORY}_all_archive: $(eval echo "\${${CATEGORY}_PACKAGES}") ${CATEGORY}_all_install: $(eval echo "\${${CATEGORY}_INSTALL}") +${CATEGORY}_all_export: $(eval echo "\${${CATEGORY}_EXPORT}") ${CATEGORY}_all_clean: $(eval echo "\${${CATEGORY}_CLEAN}") ${CATEGORY}_all_distclean: $(eval echo "\${${CATEGORY}_DISTCLEAN}") @@ -187,8 +199,8 @@ EOF done cat<<EOF >> "${BUILDER_MAKEFILE}" -all_clean: ${PACKAGES_CLEAN} -all_distclean: sysroot_clean artifacts_clean tmpdir_clean +all_clean: ${PACKAGES_CLEAN} exports_clean +all_distclean: sysroot_clean artifacts_clean tmpdir_clean exports_clean EOF # vim: filetype=sh |