| 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | PACKAGE=$1 |
| 5 | |
| 6 | tdnf install -y ${TDNF_OPTIONS} rpm-build git tar build-essential createrepo_c |
| 7 | |
| 8 | SPEC=${PACKAGE}.spec |
| 9 | VERSION=$(rpmspec -q --srpm --queryformat "[%{VERSION}\n]" ${SPEC}) |
| 10 | FULLNAME=${PACKAGE}-${VERSION} |
| 11 | |
| 12 | saved_IFS=${IFS} |
| 13 | IFS=$'\n' BUILD_REQUIRES=( $(rpmspec -q --buildrequires ${SPEC} 2>/dev/null) ) |
| 14 | IFS=${saved_IFS} |
| 15 | |
| 16 | TARBALL=$(rpmspec -q --srpm --queryformat "[%{SOURCE}\n]" ${SPEC}) |
| 17 | ARCH=$(uname -m) |
| 18 | RPM_BUILD_DIR="/usr/src/photon" |
| 19 | DIST=.ph5 |
| 20 | |
| 21 | echo BuildRequires: "${BUILD_REQUIRES[@]}" |
| 22 | |
| 23 | # if checked out as a submodule .git is a file, pointing to the parent |
| 24 | # if pwd is mounted the parent is not accessible |
| 25 | # if checked out as sub module it's presumably clean so we can just pack all files |
| 26 | if [ -d .git ] ; then |
| 27 | # https://github.com/actions/checkout/issues/760 |
| 28 | git config --global --add safe.directory $(pwd) |
| 29 | |
| 30 | tar zcf ${TARBALL} --transform "s,^,${FULLNAME}/," $(git ls-files) |
| 31 | else |
| 32 | # prevent "tar: .: file changed as we read it" |
| 33 | touch ${TARBALL} |
| 34 | tar zcf ${TARBALL} --exclude=${TARBALL} --transform "s,^./,${FULLNAME}/," . |
| 35 | fi |
| 36 | |
| 37 | tdnf install -y ${TDNF_OPTIONS} "${BUILD_REQUIRES[@]}" |
| 38 | |
| 39 | mkdir -p ${RPM_BUILD_DIR} |
| 40 | mkdir -p ${RPM_BUILD_DIR}/{SOURCES,BUILD,RPMS,SRPMS} |
| 41 | mv ${TARBALL} ${RPM_BUILD_DIR}/SOURCES/ |
| 42 | |
| 43 | rpmbuild --nodeps -D "dist ${DIST}" -D "_topdir ${RPM_BUILD_DIR}" -ba ${SPEC} |
| 44 | createrepo_c ${RPM_BUILD_DIR}/RPMS |