Can i install and run programs from inside chroot directory?

New to Debian (Or Linux in general)? Ask your questions here!

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-11 19:49

pcalvert wrote:
emil_21 wrote:It's not just firefox, but any program that i want to have with different setup.

In that case, I think you may be interested in this: https://nixos.org/nix/


emil_21 wrote:Also, it will be great if you can create portable apps like that - everything run from one folder and saves data in that folder.

If you want to keep the data separate, you can do that using Firejail.

For example:
Code: Select all
mkdir -p ~/Firejail_home/Firefox_old  <=== You only need to do this once.
firejail --private=~/Firejail_home/Firefox_old /path/to/old/firefox -no-remote

mkdir -p ~/Firejail_home/Firefox_new  <=== You only need to do this once.
firejail --private=~/Firejail_home/Firefox_new /path/to/new/firefox -no-remote


Phil


I haven't heard of nix, i have to check it.

I have heard of fairjail but haven't test it extensively. Do you mean i can use firejail for any application and set the folder in which the application saves its data?
emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-11 19:51

Head_on_a_Stick wrote:
emil_21 wrote:it will be great if you can create portable apps like that - everything run from one folder and saves data in that folder

How about https://docs.appimage.org/packaging-guide/index.html? Or perhaps https://docs.flatpak.org/en/latest/first-build.html

And there's also nix (as pcalvert notes), GUIX and NetBSD's pkgsrc.



AppImage and Flatpak are good but they do not save the data in the same folder. For example, if i want to use Kodi 17 and Kodi 18 i can't, because they both will save they data in ~/.kodi.
emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby pcalvert » 2020-02-11 21:51

emil_21 wrote:Do you mean i can use firejail for any application and set the folder in which the application saves its data?

Yes, by giving each program its own home directory. Normally, programs run by a normal user “think” that "~/" is the home directory (because it is). Using Firejail, you can fool a program into “thinking” that a different directory is the home directory. For example, you could fool Kodi 17 into “thinking” that "~/Kodi_17" is the home directory, and you could fool Kodi 18 into “thinking” that "~/Kodi_18" is the home directory. This is done using the "--private=" option.

Phil
“Property is the fruit of labor; property is desirable; it is a positive good
in the world. That some should be rich shows that others may become
rich, and hence is just encouragement to industry and enterprise.”
— Abraham Lincoln
pcalvert
 
Posts: 1873
Joined: 2006-04-21 11:19
Location: Sol Sector

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-12 07:32

It will be great if i can do that with Kodi using firejail. But what is the best way to install kodi 17 and kodi 18? I can't use .deb files and install them both system wide. Kodi is not available as appimage, and as flatpak only kodi 18 is available.

That is why i wanted to install kodi 17 and kodi 18 in separate chroot directory and run them from them, which probably is still possible, but as i understand running application in gui mode from chroot environment is not that easy.
emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-12 07:57

pcalvert wrote:
Code: Select all
mkdir -p ~/Firejail_home/Firefox_old  <=== You only need to do this once.
firejail --private=~/Firejail_home/Firefox_old /path/to/old/firefox -no-remote

mkdir -p ~/Firejail_home/Firefox_new  <=== You only need to do this once.
firejail --private=~/Firejail_home/Firefox_new /path/to/new/firefox -no-remote


Phil


Is '/path/to/old/firefox' this directory ~/.mozilla? Because if i run:

Code: Select all
firejail --private=~/Firejail_home/Firefox_old ~/.mozilla/ -no-remote


i get this error:

Code: Select all
Error: invalid command name
emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby Chrisdb » 2020-02-12 08:20

emil_21 wrote:Is '/path/to/old/firefox' this directory ~/.mozilla? Because if i run:

Code: Select all
firejail --private=~/Firejail_home/Firefox_old ~/.mozilla/ -no-remote


i get this error:

Code: Select all
Error: invalid command name


replace:
Code: Select all
-no-remote

with:
Code: Select all
--no-remote
Chrisdb
 
Posts: 226
Joined: 2018-04-10 07:16

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-12 09:32

Tried '--no-remore' but got the same error.

But i need to use this command? Isn't this way more simple:

I created three folders:
Code: Select all
~/Firejail_home/firefox1
~/Firejail_home/firefox2
~/Firejail_home/firefox3


And if i want to run any of the three firefox profiles i use these commands:

Code: Select all
firejail --private=~/Firejail_home/firefox1 firefox
firejail --private=~/Firejail_home/firefox2 firefox
firejail --private=~/Firejail_home/firefox3 firefox
emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby Chrisdb » 2020-02-12 11:21

The 'no-remote' option is used to avoid connecting to a running instance
Something like:
Code: Select all
firejail --private=~/Firefox_old firefox --no-remote

should work..
Chrisdb
 
Posts: 226
Joined: 2018-04-10 07:16

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-12 13:43

Yes, this worked.
I tested firefjail --private option with kodi 17, which is in the debian repository, and it worked too.
emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby pcalvert » 2020-02-12 14:14

emil_21 wrote:It will be great if i can do that with Kodi using firejail. But what is the best way to install kodi 17 and kodi 18? I can't use .deb files and install them both system wide. Kodi is not available as appimage, and as flatpak only kodi 18 is available.


Here is a potential solution: https://bedrocklinux.org/

I've never used it, but I believe that it can provide you with the capability that you are seeking. However, the Nix package manager I told you about earlier seems like a much simpler solution.

Phil
“Property is the fruit of labor; property is desirable; it is a positive good
in the world. That some should be rich shows that others may become
rich, and hence is just encouragement to industry and enterprise.”
— Abraham Lincoln
pcalvert
 
Posts: 1873
Joined: 2006-04-21 11:19
Location: Sol Sector

Re: Can i install and run programs from inside chroot direct

Postby Chrisdb » 2020-02-12 14:24

pcalvert wrote:However, the Nix package manager I told you about earlier seems like a much simpler solution.

Indeed, it looks really interesting.

@pcalvert, any personal experience :D ?
Chrisdb
 
Posts: 226
Joined: 2018-04-10 07:16

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-13 08:08

@pcalvert, i installed Nix package manager but it doesn't seem to work. If i type
Code: Select all
sudo nix-env --install firefox
i get
Code: Select all
sudo: nix-env: command not found
emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby pcalvert » 2020-02-13 16:42

emil_21 wrote:@pcalvert, i installed Nix package manager but it doesn't seem to work. If i type
Code: Select all
sudo nix-env --install firefox
i get
Code: Select all
sudo: nix-env: command not found



This is from the end of the install script:
Code: Select all
Installation finished!  To ensure that the necessary environment
variables are set, please add the line

  . $p

to your shell profile (e.g. ~/.profile).
EOF
else
    cat >&2 <<EOF

Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . $p

in your shell.
EOF
fi

After installing nix, did you do what the installer script told you to do?

I just found something that may be helpful: Nix tutorial

It appears to be rather thorough. There is also the manual: https://nixos.org/nix/manual/

Phil
“Property is the fruit of labor; property is desirable; it is a positive good
in the world. That some should be rich shows that others may become
rich, and hence is just encouragement to industry and enterprise.”
— Abraham Lincoln
pcalvert
 
Posts: 1873
Joined: 2006-04-21 11:19
Location: Sol Sector

Re: Can i install and run programs from inside chroot direct

Postby emil_21 » 2020-02-14 07:04

I got this at the end of the installation:

Code: Select all
Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . /home/user/.nix-profile/etc/profile.d/nix.sh


I execute the command but still get 'command not found' when i try to execute nix-env. This is my .profile file:

Code: Select all
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
   . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
if [ -e /home/user/.nix-profile/etc/profile.d/nix.sh ]; then . /home/user/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer

emil_21
 
Posts: 67
Joined: 2017-04-14 06:13

Re: Can i install and run programs from inside chroot direct

Postby stevepusser » 2020-02-15 00:06

Is the search function broken in these forums? I posted a way to install my buster backport of Kodi 18.5 only a day or so ago!
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Kodi 18.5, Mesa 19.3.3, 5.5 kernels, KeepassXC 2.5.3, Nvidia-driver 440.59, LibreOffice 6.4.1~rc1
User avatar
stevepusser
 
Posts: 11437
Joined: 2009-10-06 05:53

PreviousNext

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 10 guests

fashionable