[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] 2 commits: reproducible_pool_buildinfos: better handling of temp files

Holger Levsen gitlab at salsa.debian.org
Mon Mar 1 15:02:43 GMT 2021



Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net


Commits:
5935769c by Frédéric Pierret (fepitre) at 2021-03-01T16:01:24+01:00
reproducible_pool_buildinfos: better handling of temp files

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
f7290c04 by Holger Levsen at 2021-03-01T16:02:23+01:00
reproducible_pool_buildinfos: safer handling of temp files

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


1 changed file:

- bin/reproducible_pool_buildinfos.sh


Changes:

=====================================
bin/reproducible_pool_buildinfos.sh
=====================================
@@ -172,7 +172,7 @@ query_db_buildinfos() {
 	# We handle the case where ARCH has multiple concatenated values
 	PARSED_ARCH=$(for arch in ${ARCH//-/ }; do echo -n \'"$arch"\'\,; done)
 	PARSED_ARCH=${PARSED_ARCH::-1}
-	psql --tuples-only buildinfo <<EOF > "raw_packages_${LOCALSUITE}_${ARCH}.list"
+	psql --tuples-only buildinfo <<EOF > "${TMPDIR}/raw_packages_${LOCALSUITE}_${ARCH}.list"
 SELECT DISTINCT
 	p.source,p.version
 FROM
@@ -182,8 +182,16 @@ WHERE
 ORDER BY
 	p.source
 EOF
-	convert_db_output_to_buildinfo "raw_packages_${LOCALSUITE}_${ARCH}.list" "raw_buildinfo-pool_${LOCALSUITE}_${ARCH}.list"
-	filter_buildinfos "$POOLFILE" "raw_buildinfo-pool_${LOCALSUITE}_${ARCH}.list"
+	convert_db_output_to_buildinfo "${TMPDIR}/raw_packages_${LOCALSUITE}_${ARCH}.list" "${TMPDIR}/raw_buildinfo-pool_${LOCALSUITE}_${ARCH}.list"
+	filter_buildinfos "$POOLFILE" "${TMPDIR}/raw_buildinfo-pool_${LOCALSUITE}_${ARCH}.list"
+}
+
+exit_clean() {
+	local exit_code=$?
+	if [ -d "$TMPDIR" ] && [ "${TMPDIR:0:21}" = "/tmp/buildinfos-pool-" ]; then
+		rm -rf "$TMPDIR"
+	fi
+	exit "$exit_code"
 }
 
 #
@@ -270,11 +278,13 @@ ARCHES="
 
 SUITES="bullseye unstable"
 LOCALSUITE=""
+TMPDIR=$(mktemp -d -t buildinfos-pool-XXXXXX)
+
+trap 'exit_clean' INT TERM EXIT
 
 for ARCH in $ARCHES ; do
 	for SUITE in $SUITES ; do
 		get_localsuite
 		query_db_buildinfos
-		rm "raw_packages_${LOCALSUITE}_${ARCH}.list" "raw_buildinfo-pool_${LOCALSUITE}_${ARCH}.list"
 	done
 done



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/845b2b9d210da2a73fb192df983f4e5fc382eead...f7290c042052b1defcf0c6153401936fd0b19ccb

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/845b2b9d210da2a73fb192df983f4e5fc382eead...f7290c042052b1defcf0c6153401936fd0b19ccb
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20210301/9e0dd031/attachment-0001.htm>


More information about the Qa-jenkins-scm mailing list