xiph / rav1e

The fastest and safest AV1 encoder.
BSD 2-Clause "Simplified" License
3.72k stars 253 forks source link

install-rav1e-c requires elevation in MSYS2/MinGW under Windows #2420

Open LigH-de opened 4 years ago

LigH-de commented 4 years ago

Details available in media-autobuild suite issue 1606

/opt/cargo/bin/cargo.exe cinstall --release --prefix /build/rav1e-git/install-32bit --jobs 3
error: could not execute process `E:/MABS/msys64/opt/cargo\bin\cargo-cinstall.exe cinstall --release --prefix 'E:/MABS/build/rav1e-git/install-32bit' --jobs 3` (never executed)

Caused by:
{{Process requires elevation}}. (os error 740)

logs.zip collected by media-autobuild suite

lu-zero commented 4 years ago

I guess the readme could explicitly mention --destdir.

1480c1 commented 4 years ago

@lu-zero, what is the difference between --prefix and --destdir? I see these lines https://github.com/lu-zero/cargo-c/blob/e22e54a01372375ce5b578c8d442c88b5d2e4d30/src/cinstall.rs#L97-L100 and these https://github.com/lu-zero/cargo-c/blob/5806c3a740ffc46408a55ad1b60f3037bc6ac2af/src/install_paths.rs#L16-L23 , but I can't mentally map destdir to any options in autotools or cmake, at least immediately

lu-zero commented 4 years ago

DESTDIR is used to tell the install process where to put the files temporary, prefix is the path you put over the default bin/lib/...etc directorires. By default is /usr/local.

Ideally when you package you install with --destdir /tmp/some/unique/path and then tar it up. When you install after building with a non-root user you first use --destdir and the do sudo cp -a or similar.

lu-zero commented 4 years ago

I see that cmake warns about windows in its documentation for destdir.

1480c1 commented 4 years ago

Oh, you mean the variable, I was thinking about something like --destdir ... or -DCMAKE_INSTALL_DESTDIR=...

lu-zero commented 4 years ago

That's its usage anyway :)

1480c1 commented 4 years ago

I see, so

cargo cinstall --release --prefix "${LOCALDESTDIR:-/mingw64}" --destdir "$PWD/install-$bits" --jobs $(nproc)
install ...

?

lu-zero commented 4 years ago

Yes

lu-zero commented 4 years ago

@LigH-de would gsudo be a solution?

1480c1 commented 4 years ago

@LigH-de patch to try gsudo, it will pop up a uac prompt when it runs cargo-c (at least on my machine)

diff --git a/build/media-suite_compile.sh b/build/media-suite_compile.sh
index c5d854c..85fbd64 100644
--- a/build/media-suite_compile.sh
+++ b/build/media-suite_compile.sh
@@ -1053,6 +1053,14 @@ if { [[ $dav1d = y ]] || { [[ $ffmpeg != no ]] && enabled libdav1d; }; } &&
     do_checkIfExist
 fi

+# Get gsudo
+if enabled librav1e &&
+    [[ ! "$(/opt/bin/gsudo.exe --version 2> /dev/null | head -1)" = "gsudo v0.7.1" ]] &&
+    do_wget -h 56d2f93ac2f772981569c185c753969354702b1f0d069040ab4b945e6987421c \
+        "https://github.com/gerardog/gsudo/releases/download/v0.7.1/gsudo.v0.7.1.zip"; then
+    do_install gsudo.exe /opt/bin/gsudo.exe
+fi
+
 _check=(/opt/cargo/bin/cargo-c{build,install}.exe)
 if enabled librav1e &&
     [[ ! -x /opt/cargo/bin/cargo-cbuild || $(/opt/cargo/bin/cargo-cbuild --version) =~ 0.6* ]] &&
@@ -1095,7 +1103,9 @@ if { [[ $rav1e = y ]] || enabled librav1e; } &&
         export CPATH LIBRARY_PATH

         rm -f "$CARGO_HOME/config" 2> /dev/null
-        log "install-rav1e-c" "$RUSTUP_HOME/bin/cargo.exe" \
+        log -e "install-rav1e-c" "$RUSTUP_HOME/bin/cargo.exe" \
+            cinstall --release --prefix "$PWD/install-$bits" --jobs "$cpuCount" ||
+            log "install-rav1e-c.gsudo" /opt/bin/gsudo.exe "$RUSTUP_HOME/bin/cargo.exe" \
             cinstall --release --prefix "$PWD/install-$bits" --jobs "$cpuCount"

         mapfile -t compiler_builtins < <(
LigH-de commented 4 years ago

I did not try the gsudo patch yet as @1480c1 first let me try a patch which renames some files from "install" to "inst" and adds the dest-dir. For me this appeared to be sufficient.