generate_source_tarball.sh: Use tar exclude options for VCS files

- Related: RHEL-52734
This commit is contained in:
Thomas Fitzsimmons 2024-06-06 17:00:15 -04:00 committed by Andrew Hughes
parent f9f33b7b3d
commit faff59b15f
2 changed files with 13 additions and 21 deletions

View File

@ -2497,6 +2497,11 @@ cjc.mainProgram(args)
%endif
%changelog
* Sun Aug 04 2024 Anton Bobrov <abobrov@redhat.com> - 1:17.0.12.0.6-0.1.ea
- generate_source_tarball.sh: Use tar exclude options for VCS files
- generate_source_tarball.sh: Improve VCS exclusion
- Related: RHEL-52734
* Sun Aug 04 2024 Andrew Hughes <gnu.andrew@redhat.com> - 1:17.0.12.0.6-0.1.ea
- generate_source_tarball.sh: Update examples in header for clarity
- generate_source_tarball.sh: Cleanup message issued when checkout already exists

View File

@ -242,34 +242,21 @@ pushd "${FILE_NAME_ROOT}"
popd
rm -rf build
EA_PART="$(awk -F= \
'/^DEFAULT_PROMOTED_VERSION_PRE/ { if ($2) print "-"$2 }' \
"${VERSION}"/make/conf/version-numbers.conf)"
TARBALL_BASE=${FILE_NAME_ROOT}${EA_PART}.tar
pushd "${VERSION}"
# Omit commit checks, history, and GHA from archive.
for skip in .jcheck .hgtags .hgignore .gitattributes .gitignore .github
do
echo "${skip}"" export-ignore" >> .git/info/attributes
done
# Do not bother with --mtime here; specify it to tar below.
# Unforunately, git-archive sorts added files like .src-rev at the end;
# retar below to use GNU tar --sort=name ordering which sorts .src-rev
# at the start.
git archive --output "${TARBALL_BASE}" --prefix="${VERSION}"/ \
--add-file=.src-rev --format=tar "${VERSION}"
popd
mv "${VERSION}" "${VERSION}".git
tar xf "${VERSION}".git/"${TARBALL_BASE}"
echo "Compressing remaining forest"
if [ "$COMPRESSION" = "xz" ] ; then
SWITCH=cJf
else
SWITCH=czf
fi
TARBALL_NAME=${TARBALL_BASE}.${COMPRESSION}
EA_PART="$(awk -F= \
'/^DEFAULT_PROMOTED_VERSION_PRE/ { if ($2) print "-"$2 }' \
"${VERSION}"/make/conf/version-numbers.conf)"
TARBALL_NAME=${FILE_NAME_ROOT}${EA_PART}.tar.${COMPRESSION}
XZ_OPT=${XZ_OPT-"-T0"} \
tar --mtime="${TAR_TIME}" --owner=root --group=root --sort=name \
tar --exclude-vcs --exclude=.jcheck --exclude=.hgtags \
--exclude=.hgignore --exclude=.gitattributes \
--exclude=.gitignore --exclude=.github --exclude=.git \
--mtime="${TAR_TIME}" --owner=root --group=root --sort=name \
-$SWITCH "${TARBALL_NAME}" "${TO_COMPRESS}"
mv "${TARBALL_NAME}" ..
popd