← Back to team overview

curtin-dev team mailing list archive

[Merge] ~xnox/curtin:snap-stage-aware into curtin:master

 

Dimitri John Ledkov has proposed merging ~xnox/curtin:snap-stage-aware into curtin:master.

Commit message:
bin/curtin: make it snap stage aware

if curtin is staged into any snap, and is in default path inside the snap make it possible to call curtin via `$ snap run --shell $mysnap curtin --help` and make it find staged python, staged python's modules, and be able to use them.

This has potential of simplifying snapcraft.yaml packaging changes in subiquity & ubuntu-desktop-installer.

But this also seems to be fragile, if for example multiple versions of python are ever staged in a single snap.

Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~xnox/curtin/+git/curtin/+merge/453314
-- 
Your team curtin developers is requested to review the proposed merge of ~xnox/curtin:snap-stage-aware into curtin:master.
diff --git a/bin/curtin b/bin/curtin
index 89cb319..ba40958 100755
--- a/bin/curtin
+++ b/bin/curtin
@@ -26,6 +26,14 @@ if [ "${mydir#${updir}/}" = "bin" -a -d "$updir/${PY3OR2_MCHECK%%.*}" ]; then
     esac
 fi
 
+if [ -n "$SNAP" ]; then
+    snap_pypath=$(find $SNAP -path $SNAP/lib/python*/site-packages/curtin/deps/check.py)
+    if [ -n "$snap_pypath" ]; then
+	export PYTHONPATH="${snap_pypath%%/curtin/deps/check.py}${PYTHONPATH:+:$PYTHONPATH}"
+	debug "setting PYTHONPATH to '$PYTHONPATH'"
+    fi
+fi
+
 if [ ! -n "$PYTHON" ]; then
     first_exe=""
     oifs="$IFS"; IFS=":"

Follow ups