mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
Install login scripts and proot only if needed
This commit is contained in:
parent
eb2fcc80f5
commit
ed05a33fc0
3 changed files with 43 additions and 36 deletions
|
|
@ -15,6 +15,7 @@ let
|
|||
activationBinPaths = lib.makeBinPath [
|
||||
pkgs.bash
|
||||
pkgs.coreutils
|
||||
pkgs.diffutils
|
||||
pkgs.findutils
|
||||
pkgs.gnused
|
||||
pkgs.ncurses # For `tput`.
|
||||
|
|
|
|||
|
|
@ -50,15 +50,33 @@ in
|
|||
config = {
|
||||
|
||||
build.activation = {
|
||||
installLoginScripts = ''
|
||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin /usr/lib
|
||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${login} /bin/login
|
||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${loginInner} /usr/lib/login-inner
|
||||
installLogin = ''
|
||||
if ! diff /bin/login ${login} > /dev/null; then
|
||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${login} /bin/.login.tmp
|
||||
$DRY_RUN_CMD chmod $VERBOSE_ARG u+w /bin/.login.tmp
|
||||
$DRY_RUN_CMD mv $VERBOSE_ARG /bin/.login.tmp /bin/login
|
||||
fi
|
||||
'';
|
||||
|
||||
installLoginInner = ''
|
||||
if (test -e /usr/lib/.login-inner.new && ! diff /usr/lib/.login-inner.new ${loginInner} > /dev/null) || \
|
||||
(! test -e /usr/lib/.login-inner.new && ! diff /usr/lib/login-inner ${loginInner} > /dev/null); then
|
||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /usr/lib
|
||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${loginInner} /usr/lib/.login-inner.tmp
|
||||
$DRY_RUN_CMD chmod $VERBOSE_ARG u+w /usr/lib/.login-inner.tmp
|
||||
$DRY_RUN_CMD mv $VERBOSE_ARG /usr/lib/.login-inner.tmp /usr/lib/.login-inner.new
|
||||
fi
|
||||
'';
|
||||
|
||||
installProotStatic = ''
|
||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${cfg.prootStatic}/bin/proot-static /bin/.proot-static.new
|
||||
if (test -e /bin/.proot-static.new && ! diff /bin/.proot-static.new ${cfg.prootStatic}/bin/proot-static > /dev/null) || \
|
||||
(! test -e /bin/.proot-static.new && ! diff /bin/proot-static ${cfg.prootStatic}/bin/proot-static > /dev/null); then
|
||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${cfg.prootStatic}/bin/proot-static /bin/.proot-static.tmp
|
||||
$DRY_RUN_CMD chmod $VERBOSE_ARG u+w /bin/.proot-static.tmp
|
||||
$DRY_RUN_CMD mv $VERBOSE_ARG /bin/.proot-static.tmp /bin/.proot-static.new
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||
|
||||
{ config, lib, writeScript }:
|
||||
{ config, writeScript }:
|
||||
|
||||
let
|
||||
inherit (config.build) installationDir;
|
||||
|
|
@ -15,35 +15,23 @@ writeScript "login" ''
|
|||
export PROOT_TMP_DIR=${installationDir}/tmp
|
||||
export PROOT_L2S_DIR=${installationDir}/.l2s
|
||||
|
||||
${
|
||||
if config.build.initialBuild
|
||||
then ''
|
||||
${installationDir}/bin/proot-static \
|
||||
-b ${installationDir}/nix:/nix \
|
||||
-b ${installationDir}/bin:/bin \
|
||||
-b ${installationDir}/etc:/etc \
|
||||
-b ${installationDir}/tmp:/tmp \
|
||||
-b ${installationDir}/usr:/usr \
|
||||
-b /:/android \
|
||||
--link2symlink \
|
||||
${installationDir}/bin/sh ${installationDir}/usr/lib/login-inner "$@"
|
||||
if test -e ${installationDir}/bin/.proot-static.new; then
|
||||
echo "Install new proot-static..."
|
||||
/system/bin/mv ${installationDir}/bin/.proot-static.new ${installationDir}/bin/proot-static
|
||||
fi
|
||||
|
||||
exec ${installationDir}/bin/login "$@"
|
||||
''
|
||||
else ''
|
||||
if [[ -x ${installationDir}/bin/.proot-static.new ]] && ! $(/system/bin/pgrep proot-static); then
|
||||
/system/bin/mv ${installationDir}/bin/.proot-static.new ${installationDir}/bin/proot-static
|
||||
fi
|
||||
if test -e ${installationDir}/usr/lib/.login-inner.new; then
|
||||
echo "Install new login-inner..."
|
||||
/system/bin/mv ${installationDir}/usr/lib/.login-inner.new ${installationDir}/usr/lib/login-inner
|
||||
fi
|
||||
|
||||
exec ${installationDir}/bin/proot-static \
|
||||
-b ${installationDir}/nix:/nix \
|
||||
-b ${installationDir}/bin:/bin \
|
||||
-b ${installationDir}/etc:/etc \
|
||||
-b ${installationDir}/tmp:/tmp \
|
||||
-b ${installationDir}/usr:/usr \
|
||||
-b /:/android \
|
||||
--link2symlink \
|
||||
${installationDir}/bin/sh ${installationDir}/usr/lib/login-inner "$@"
|
||||
''
|
||||
}
|
||||
exec ${installationDir}/bin/proot-static \
|
||||
-b ${installationDir}/nix:/nix \
|
||||
-b ${installationDir}/bin:/bin \
|
||||
-b ${installationDir}/etc:/etc \
|
||||
-b ${installationDir}/tmp:/tmp \
|
||||
-b ${installationDir}/usr:/usr \
|
||||
-b /:/android \
|
||||
--link2symlink \
|
||||
${installationDir}/bin/sh ${installationDir}/usr/lib/login-inner "$@"
|
||||
''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue