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 [
|
activationBinPaths = lib.makeBinPath [
|
||||||
pkgs.bash
|
pkgs.bash
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
|
pkgs.diffutils
|
||||||
pkgs.findutils
|
pkgs.findutils
|
||||||
pkgs.gnused
|
pkgs.gnused
|
||||||
pkgs.ncurses # For `tput`.
|
pkgs.ncurses # For `tput`.
|
||||||
|
|
|
||||||
|
|
@ -50,15 +50,33 @@ in
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
build.activation = {
|
build.activation = {
|
||||||
installLoginScripts = ''
|
installLogin = ''
|
||||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin /usr/lib
|
if ! diff /bin/login ${login} > /dev/null; then
|
||||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${login} /bin/login
|
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
||||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${loginInner} /usr/lib/login-inner
|
$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 = ''
|
installProotStatic = ''
|
||||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
if (test -e /bin/.proot-static.new && ! diff /bin/.proot-static.new ${cfg.prootStatic}/bin/proot-static > /dev/null) || \
|
||||||
$DRY_RUN_CMD cp $VERBOSE_ARG ${cfg.prootStatic}/bin/proot-static /bin/.proot-static.new
|
(! 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.
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
{ config, lib, writeScript }:
|
{ config, writeScript }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.build) installationDir;
|
inherit (config.build) installationDir;
|
||||||
|
|
@ -15,35 +15,23 @@ writeScript "login" ''
|
||||||
export PROOT_TMP_DIR=${installationDir}/tmp
|
export PROOT_TMP_DIR=${installationDir}/tmp
|
||||||
export PROOT_L2S_DIR=${installationDir}/.l2s
|
export PROOT_L2S_DIR=${installationDir}/.l2s
|
||||||
|
|
||||||
${
|
if test -e ${installationDir}/bin/.proot-static.new; then
|
||||||
if config.build.initialBuild
|
echo "Install new proot-static..."
|
||||||
then ''
|
/system/bin/mv ${installationDir}/bin/.proot-static.new ${installationDir}/bin/proot-static
|
||||||
${installationDir}/bin/proot-static \
|
fi
|
||||||
-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/login "$@"
|
if test -e ${installationDir}/usr/lib/.login-inner.new; then
|
||||||
''
|
echo "Install new login-inner..."
|
||||||
else ''
|
/system/bin/mv ${installationDir}/usr/lib/.login-inner.new ${installationDir}/usr/lib/login-inner
|
||||||
if [[ -x ${installationDir}/bin/.proot-static.new ]] && ! $(/system/bin/pgrep proot-static); then
|
fi
|
||||||
/system/bin/mv ${installationDir}/bin/.proot-static.new ${installationDir}/bin/proot-static
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec ${installationDir}/bin/proot-static \
|
exec ${installationDir}/bin/proot-static \
|
||||||
-b ${installationDir}/nix:/nix \
|
-b ${installationDir}/nix:/nix \
|
||||||
-b ${installationDir}/bin:/bin \
|
-b ${installationDir}/bin:/bin \
|
||||||
-b ${installationDir}/etc:/etc \
|
-b ${installationDir}/etc:/etc \
|
||||||
-b ${installationDir}/tmp:/tmp \
|
-b ${installationDir}/tmp:/tmp \
|
||||||
-b ${installationDir}/usr:/usr \
|
-b ${installationDir}/usr:/usr \
|
||||||
-b /:/android \
|
-b /:/android \
|
||||||
--link2symlink \
|
--link2symlink \
|
||||||
${installationDir}/bin/sh ${installationDir}/usr/lib/login-inner "$@"
|
${installationDir}/bin/sh ${installationDir}/usr/lib/login-inner "$@"
|
||||||
''
|
|
||||||
}
|
|
||||||
''
|
''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue