tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Prevent surprising build failures involving symlinks



I've started a bulk build, and several packages failed surprisingly.
They didn't find their dependent libraries or include files, and some
other just didn't install any files. It took me quite a while to track
down the actual cause.

My actual setup is:

    /home/pbulk -> /scratch/pbulk

    sh /home/pbulk/pkgsrc/bootstrap/bootstrap --unprivileged

To prevent others from experiencing the same problem, I'd like to apply
the attached patch to the bootstrap. Any thoughts? Am I really the first
one to experience this?
diff --git a/bootstrap/bootstrap b/bootstrap/bootstrap
index 10e1c3d7dfc..956e90644a3 100755
--- a/bootstrap/bootstrap
+++ b/bootstrap/bootstrap
@@ -353,6 +353,39 @@ checkarg_sane_absolute_path() {
 	/*)	;;
 	*)	die "ERROR: The argument to $2 must be an absolute path." ;;
 	esac
+
+	checkarg_no_symlink_path "$1" "$2"
+}
+
+checkarg_no_symlink_path() {
+	[ "${ALLOW_SYMLINK_PATHS-}" = yes ] && return
+
+	_dir=$1
+	while [ ! -d "$_dir" ]; do
+		_dir=${_dir%/*}
+	done
+
+	_realdir=`cd "$_dir" && exec pwd`
+	[ "$_act" = "$_dir" ] && return
+
+	die "ERROR: The path $1 (from $2) must not contain symlinks.
+
+	Given path   : $1
+	Resolved path: $_realdir${1##${_dir}}
+
+	Several packages assume that the given path of $2 stays the same when
+	symlinks are resolved. When that assumption fails, they will:
+
+	* not find some include files or libraries during the build phase
+	  since the files from dependencies are not installed in
+	  \${WRKDIR}/.buildlink.
+
+	* install their files into the wrong path inside \${WRKDIR}/.destdir,
+	  which will fail the PLIST check during the install phase
+
+	To try pkgsrc despite this risk, set ALLOW_SYMLINK_PATHS=yes when
+	bootstrapping, which will disable this check. There won't be any
+	further hints when a package fails, though."
 }
 
 checkarg_sane_relative_path() {


Home | Main Index | Thread Index | Old Index