summaryrefslogtreecommitdiff
blob: 48f054e57a07b42fe43545fba63b4b097616d114 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
build-docbook-catalog: avoid usage of non-portable flock

Solaris has no flock(1), hence use shell-provided until instead to
simulate lock.

--- build-docbook-catalog
+++ build-docbook-catalog
@@ -65,10 +65,14 @@
 		mkdir -p "${ROOT}${ROOTCONFDIR}" || error "could not create ${ROOTCONFDIR}"
 	fi
 
+	local lock="${ROOT}${ROOTCONFDIR}"/build-docbook-catalog-lock
 	(
 	# Lock the dir to avoid trashing other runs that might
 	# be running parallel.
-	flock 123 || error "unable to lock ${ROOTCONFDIR}"
+	touch "${lock}".$$ && \
+		until ln "${lock}".$$ "${lock}" 2>/dev/null; do sleep 1; done && \
+		rm "${lock}".$$
+	[[ -f ${lock}.$$ ]] && error "unable to lock ${ROOTCONFDIR}"
 
 	create_catalogs			# will exit on error
 	for type in xsl xsl-ns xsl-saxon xsl-xalan; do
@@ -90,7 +94,8 @@
 		populate_entities
 	fi
 
-	) 123>"${ROOT}${ROOTCONFDIR}/.keep"
+	)
+	rm "${lock}"
 
 	exit 0
 }