Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Can i install and run programs from inside chroot directory?

New to Debian (Or Linux in general)? Ask your questions here!
Message
Author
emil_21
Posts: 98
Joined: 2017-04-14 06:13

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

#16 Post by emil_21 »

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: 98
Joined: 2017-04-14 06:13

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

#17 Post by emil_21 »

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.

pcalvert
Posts: 1939
Joined: 2006-04-21 11:19
Location: Sol Sector
Has thanked: 1 time
Been thanked: 2 times

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

#18 Post by pcalvert »

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
Freespoke is a new search engine that respects user privacy and does not engage in censorship.

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

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

#19 Post by emil_21 »

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: 98
Joined: 2017-04-14 06:13

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

#20 Post by emil_21 »

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

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

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

#21 Post by Chrisdb »

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

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

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

#22 Post by emil_21 »

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

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

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

#23 Post by Chrisdb »

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..

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

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

#24 Post by emil_21 »

Yes, this worked.
I tested firefjail --private option with kodi 17, which is in the debian repository, and it worked too.

pcalvert
Posts: 1939
Joined: 2006-04-21 11:19
Location: Sol Sector
Has thanked: 1 time
Been thanked: 2 times

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

#25 Post by pcalvert »

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
Freespoke is a new search engine that respects user privacy and does not engage in censorship.

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

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

#26 Post by Chrisdb »

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 ?

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

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

#27 Post by emil_21 »

@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

pcalvert
Posts: 1939
Joined: 2006-04-21 11:19
Location: Sol Sector
Has thanked: 1 time
Been thanked: 2 times

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

#28 Post by pcalvert »

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
Freespoke is a new search engine that respects user privacy and does not engage in censorship.

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

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

#29 Post by emil_21 »

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


User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 72 times

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

#30 Post by stevepusser »

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!
MX Linux packager and developer

pcalvert
Posts: 1939
Joined: 2006-04-21 11:19
Location: Sol Sector
Has thanked: 1 time
Been thanked: 2 times

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

#31 Post by pcalvert »

emil_21 wrote: I execute the command but still get 'command not found' when i try to execute nix-env.
Did you try logging out after you installed it?

If that doesn't help, what is the output of these commands?:

Code: Select all

ls -al ~/.nix-profile
ls -al /nix
Phil
Freespoke is a new search engine that respects user privacy and does not engage in censorship.

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

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

#32 Post by emil_21 »

This is the output:

Code: Select all

lrwxrwxrwx 1 user user 42 фев 13 10:39 /home/user/.nix-profile -> /nix/var/nix/profiles/per-user/user/profile

Code: Select all

drwxr-xr-x  4 user  root 4096 фев 13 10:39 .
drwxr-xr-x 19 root root 4096 фев 13 10:39 ..
drwxr-xr-x 35 user  user  4096 фев 13 10:39 store
drwxr-xr-x  4 user  user  4096 фев 13 10:39 var

pcalvert
Posts: 1939
Joined: 2006-04-21 11:19
Location: Sol Sector
Has thanked: 1 time
Been thanked: 2 times

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

#33 Post by pcalvert »

I'm not sure what the problem is, but it's possible that Nix doesn't properly install itself on Debian. Or maybe the installation instructions are incomplete.

I found a possible clue, though:
At this stage, nix is properly installed on your system, but some extra configuration is required, especially to activate the “profiles” feature.
I found that here: Working with profiles : create several user environments


Phil
Freespoke is a new search engine that respects user privacy and does not engage in censorship.

Post Reply