diff options
-rw-r--r-- | etc/package.spec | 1 | ||||
-rw-r--r-- | subr.ex/ex_rtl_rpm.subr | 50 |
2 files changed, 31 insertions, 20 deletions
diff --git a/etc/package.spec b/etc/package.spec index 82a9a9df..6fa9ddb7 100644 --- a/etc/package.spec +++ b/etc/package.spec @@ -23,7 +23,6 @@ cp -pPr "%{pkg_destdir}/." "${RPM_BUILD_ROOT}" %post %postun %files -%{pkg_files_list} %changelog diff --git a/subr.ex/ex_rtl_rpm.subr b/subr.ex/ex_rtl_rpm.subr index d4a8446d..871abf6a 100644 --- a/subr.ex/ex_rtl_rpm.subr +++ b/subr.ex/ex_rtl_rpm.subr @@ -23,18 +23,19 @@ # Returns: zero (0) on success, non-zero (>0) on failure # N.B.: The following variables are substituted prior to running rpmbuild(1): # %{pkg_destdir} -# %{pkg_files_list} # %{pkg_name} # %{pkg_url} # %{pkg_version_full} # %{pkg_version_rpm} # +# The \n-separated list of package files is inserted after the `%files' line. +# ex_rtl_build_rpm() { local _erbr_destdir="${1}" _erbr_jobs_max="${2}" _erbr_jobs_semaphore="${3}" _erbr_jobs_wait="${4}" \ _erbr_name="${5}" _erbr_rpms_dname="${6}" _erbr_spec_fname="${7}" _erbr_spec_fname_tgt="${8}" \ _erbr_tmp_dname="${9}" _erbr_topdir="${10}" _erbr_url="${11}" _erbr_version="${12}" \ _erbr_version_rpm="${13}" \ - _erbr_files_list="" _erbr_job_count=0 _erbr_rc=0 _erbr_rc_jobs=0; + _erbr_spec_fname_tgt_tmp="" _erbr_job_count=0 _erbr_rc=0 _erbr_rc_jobs=0; ( while true; do @@ -77,33 +78,44 @@ ex_rtl_build_rpm() { exit 0) 4<>"${_erbr_jobs_semaphore}"' \ EXIT HUP INT TERM USR1 USR2; - if ! rtl_fileop cp "${_erbr_spec_fname}" "${_erbr_spec_fname_tgt}"; then - _erbr_rc=1; - elif ! _erbr_files_list="$( \ - cd "${_erbr_destdir}"; \ - find -mindepth 1 \( -type f -or -type l \) | \ - sed -e 's,^./,'"/"',' -e '$!s/$/\\/')"; \ - then - _erbr_rc=1; - elif ! sed -i"" \ - -ne '/^#REMOVEDBYSED#/!p' \ - "${_erbr_spec_fname_tgt}"; \ - then - _erbr_rc=1; + ( + _erbr_spec_fname_tgt_tmp="${_erbr_spec_fname_tgt}.tmp"; + trap "rm -f \"${_erbr_spec_fname_tgt_tmp}\"" EXIT HUP INT TERM USR1 USR2; + # # N.B. Keep list in sync w/ list in function documentation comment block at top. # - elif ! sed -i"" \ + if rtl_fileop cp "${_erbr_spec_fname}" "${_erbr_spec_fname_tgt_tmp}" \ + && sed -i"" \ + -ne '/^#REMOVEDBYSED#/!p' \ + "${_erbr_spec_fname_tgt_tmp}" \ + && sed -i"" \ -e 's#%{pkg_destdir}#'"${_erbr_destdir}"'#g' \ - -e 's#%{pkg_files_list}#'"${_erbr_files_list}"'#g' \ -e 's#%{pkg_name}#'"${_erbr_name}"'#g' \ -e 's#%{pkg_url}#'"${_erbr_url}"'#g' \ -e 's#%{pkg_version_full}#'"${_erbr_version}"'#g' \ -e 's#%{pkg_version_rpm}#'"${_erbr_version_rpm}"'#g' \ - "${_erbr_spec_fname_tgt}"; \ + "${_erbr_spec_fname_tgt_tmp}" \ + && sed -n -e '1,/^%files$/p' \ + "${_erbr_spec_fname_tgt_tmp}" \ + > "${_erbr_spec_fname_tgt}" \ + && (cd "${_erbr_destdir}"; \ + find -mindepth 1 \( -type f -or -type l \) | \ + sed -e 's,^./,'"/"',') \ + >> "${_erbr_spec_fname_tgt}" \ + && sed -n -e '/^%files$/,${/^%files$/d;p}' \ + "${_erbr_spec_fname_tgt_tmp}" \ + >> "${_erbr_spec_fname_tgt}" \ + ; \ then - _erbr_rc=1; + _erbr_rc=0; else + _erbr_rc=1; + fi; + exit "${_erbr_rc}"; + ); _erbr_rc="${?}"; + + if [ "${_erbr_rc}" -eq 0 ]; then while true; do rpmbuild \ -bb \ |