https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Head+on+a+Stick&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T11:53:27ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=15732Running glibc programs2019-02-26T19:34:26Z<p>Head on a Stick: /* Arch Linux */ fixed name of image</p>
<hr />
<div>{{Obsolete|Since 2014-04-09, Alpine has been shipping with {{Pkg|musl}} instead of [https://www.uclibc.org/ uclibc], as such, the instructions in this guide may be obsolete}}<br />
<br />
<br />
{{Draft}}<br />
<br />
If you want to run [https://www.gnu.org/software/libc/ glibc] programs in Alpine Linux, there are a few ways of doing so. You could install glibc as additional to [https://uclibc.org/about.html uclibc] (you would have to do this manually), or you could do it the easy way and use a chroot.<br><br />
<br />
Because there are different use cases, this is just a slight overview about what's possible and what's intelligent.<br><br />
<br />
<br />
= Your options =<br />
<br />
== Using BusyBox ==<br />
<br />
First, the simplest approach for setting up a chroot is by using a glibc build of [https://www.busybox.net/about.html BusyBox].<br />
<br />
This approach has just a few downsides:-<br />
* You have to link most <code>/bin/</code> and <code>/usr/bin</code> programs against <code>/bin/busybox</code>, and some BusyBox builds break if you don't configure them correctly.<br />
* You have to manually download every library you need for your program manually.<br />
<br />
However, if you want a small environment for one simple use case, then this is the solution you want.<br />
<br />
== Using a live CD ==<br />
<br />
If you prefer using any special distro, you can always download and extract a live CD and use it as a chroot enviroment.<br />
<br />
== Using an image ==<br />
<br />
For Gentoo, it is the slowest approach especially on slow machines since it is not binary distribution and can be indecisive, but you have the advantage of controlling the package version of whichever library you will install. A drawback would be a big build. You have to install a Portage tree, which uses up a lot of space. (It's not 100% necessary if you don't have to install any additional content that you won't need.) Sometimes the package will fail on compilation phase of emerge. You either end up patching it yourself or waiting for a fix to appear on their Bugzilla from an experienced user.<br />
<br />
For Arch or Debian, it is recommended since packages are precompiled and better at unattended package installation. This approach isn't as easily executed as the other alternatives, but this may be the cleanest and most recommended one for the every day user.<br />
<br />
= How to do it =<br />
<br />
This is just a quick draft, so here it comes.<br />
<br />
== Using BusyBox ==<br />
<br />
First, we need to download BusyBox. You can choose any of your favourite distros to download a prebuilt version. For instance, you could use Arch Linux [https://www.archlinux.org/packages/?q=busybox packages], as follows:<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment, which we will expand through all the commands included in BusyBox:<br />
<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
<br />
== Using a live CD ==<br />
{{Draft|Contributions welcome}}<br />
<br />
<br />
== Using an image ==<br />
<br />
=== Gentoo Linux ===<br />
<br />
Select a stage3 from [https://www.gentoo.org/downloads/ here] and portage latest from [https://www.gentoo.org/downloads/mirrors/ here] at gentoo/snapshots/portage-latest.tar.xz.<br />
<br />
First,<br />
<br />
sudo apk add xz<br />
<br />
You also may need the vanilla kernel. If any time Gentoo decides to update PAM, you need it for it to emerge successfully without problems.<br />
<br />
sudo apk add kernel-vanilla<br />
<br />
Add the kernel-vanilla to Grub and reboot with the vanilla kernel if you are going to pull in both git and layman which they use to download user community supported packages.<br />
<br />
Enter the chroot:<br />
mkdir ~/chroot<br />
cd ~/chroot<br />
tar -xvf stage3-*.tar.xz<br />
tar -xvf portage-latest.tar.xz<br />
mv portage usr<br />
sudo mount --bind /dev dev<br />
sudo mount --bind /sys sys<br />
sudo mount -t proc proc proc<br />
cp /etc/resolv.conf etc<br />
sudo chroot . /bin/bash<br />
<br />
And voilà, you have your working Gentoo chroot!<br><br />
<br />
You can now take a look at [https://wiki.gentoo.org/wiki/Handbook:Main_Page Gentoo's Handbook] to find out how you can configure and install your system, or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
Here is a wrapper script that is similar to <code>arch-chroot</code> when you frequently reuse this chroot:<br />
<br />
Also, create an account with the same user name as host current user to the chroot or make changes to the userspec option to chroot line.<br />
<br />
{{Cat|gentoo-chroot.sh|<nowiki>!/bin/bash<br />
CHROOT_PATH="/home/$USER/chroot"<br />
cd $CHROOT_PATH<br />
mount | grep $CHROOT_PATH/dev || sudo mount --bind /dev dev<br />
mount | grep $CHROOT_PATH/sys || sudo mount --bind /sys sys<br />
mount | grep $CHROOT_PATH/proc || sudo mount -t proc proc proc<br />
cp /etc/resolv.conf etc<br />
sudo chroot --userspec=$USER:users . /bin/bash<br />
echo "You must manually unmount $CHROOT_PATH/dev, $CHROOT_PATH/sys, $CHROOT_PATH/proc."<br />
</nowiki><br />
}}<br />
<br />
Do at <code>chmod +x gentoo-chroot.sh</code> to get it to work.<br />
<br />
=== Arch Linux ===<br />
<br />
Either use '''pacstrap''' (included with the arch-install-scripts package) or an Arch bootstrap image:<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2019.02.01-x86_64.tar.gz<br />
sudo tar xzf archlinux-bootstrap-2019.02.01-x86_64.tar.gz && rm archlinux-bootstrap-2019.02.01-x86_64.tar.gz<br />
sudo sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist<br />
sudo sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Once that is done, update the system and install the desired package(s) (denoted by ''"foo"'' in this example):<br />
<br />
[chroot]# pacman -Syu ''foo''<br />
<br />
=== Debian ===<br />
<br />
Use the provided debootstrap package to create the Debian chroot. <code>--arch</code> is optional, depending of your needs.<br />
<br />
On the '''linux-grsec''' kernel, you will need to relax chroot limitations:<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use <code>apt-get</code> to install needed packages.<br />
<br />
== Examples ==<br />
<br />
=== Source dedicated server ===<br />
<br />
Here is an easy example of how you can run [http://www.srcds.com srcds] in a simple BusyBox chroot.<br />
<br />
For this server, you will only need the basic chroot and an advanced tar version (the BusyBox version is not sufficient because of the missing -U command):<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
Now that you are in a working chroot, you can download the server and install it. You just have to execute the following self-explaining commands...<br />
<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy, soon to be fixed (no bug in BusyBox, but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
<br />
...and you should have a working chroot with '''srcds''' installed in it.<br />
<br />
If you think you are clever or elegant, you can use the server with a bash script:<br />
<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
<br />
Just save it (in your Alpine installation) under <code>/usr/bin/steam</code>, do a <code>chmod +x /usr/bin/steam</code> and have fun!<br />
<br />
{{Warning|This script would let '''Steam''' run with root priviliges. This is not recommended.}}<br />
<br />
=== MegaCli ===<br />
<br />
So let's run [https://wikitech.wikimedia.org/wiki/MegaCli MegaCli] in a chroot too, shall we? ;)<br />
<br />
First we set up a uclibc chroot :)<br />
<br />
'''MegaCli''' needs more than just glibc. It needs [https://www.gnu.org/software/ncurses/ ncurses] and the gcc-libs:<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this, we visit [http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip this] site and download '''8.02.16_MegaCLI.zip'''.<br />
<br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
<br />
Now we have a working '''MegaCli''' client in our chroot.<br />
<br />
As with '''srcds''', we do not want to operate from inside the chroot, so here is a little script that should ease you up (use at your own risk):<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
<br />
Save it under <code>/usr/bin/MegaCli</code>. Do a <code>chmod +x /usr/bin/MegaCli</code> and good luck.<br />
<br />
Note: This method takes around 50mb. If you need something smaller, then you can strip a few files from glibc (not recommended), or work on a squashfs.<br />
<br />
With the following, you can create a squashfs that is around 15mb small:<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
<br />
When you add a [https://en.wikipedia.org/wiki/UnionFS unionfs] layer, you can even use it with write access, or you can bind some directories to the writeable directories before you chroot into it.<br />
<br />
I will look into it later on.<br />
<br />
You can save the chroot in another directory than your home directory, and you can even install a chroot through an APKBUILD (after someone wrote it).<br />
<br />
With this, you could use many glibc-dependent programs through one chroot, but be aware that running programs like this should not be standard. This should only be used in extreme situations, as in _closed source_ tools linked against glibc.<br />
<br />
=== Skype on Debian chroot ===<br />
<br />
{{Draft|Not yet validated}}<br />
<br />
This is an example on how to run '''Skype''' from a Debian 32b chroot.<br />
<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
<br />
To fix missing dependencies, you will want to use:<br />
<br />
apt-get -f install<br />
<br />
Then, exit the chroot:<br />
<br />
exit<br />
<br />
Fix PAX flags on Skype binary - '''linux-grsec''' only.<br />
<br />
ELF marking with paxctl cannot be used because Skype binary refuses to run if modified.<br />
<br />
<code>CONFIG_PAX_XATTR_PAX_FLAGS</code> is NOT yet available in '''linux-grsec'''.<br />
<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br />
<br />
Give write access to <code>/dev/v4l</code> and to <code>/dev/snd</code> in order to let Skype use the webcam device: Skype is not compatible with Alsa anymore and requires Pulseaudio to be running.<br />
<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
<br />
Enter the chroot and create a user:<br />
<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
<br />
Then run Skype as your newly created user:<br />
<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
<br />
=== Dungeon Crawl (Stone Soup) on Arch ===<br />
<br />
Once the Arch system is laid down (to <code>~/chroot/root.x86_64</code> in this example), install the game:<br />
<br />
sudo arch-chroot ~/chroot/root.x86_64<br />
[chroot]# pacman -Syu crawl-tiles<br />
<br />
Then exit the chroot and run it with this command:<br />
<br />
sudo arch-chroot ~/chroot/root.x86_64 /bin/su -c 'DISPLAY=:0 crawl-tiles'<br />
<br />
A separate user can also be created to run the game, if preferred.<br />
<br />
<br />
=== Spotify ===<br />
<br />
==== Docker method ====<br />
<br />
Read the [[Docker]] page to install it. Then clone the repository, as shown below. It will automate the process of pulling all the dependencies, and '''PaX''' marks it for the hardened kernel. The advantage of this container is that it is ready-to-use and has stripped down many of the <code>/usr/bin</code> executables. The downside is that is unstable.<br />
<br />
git clone https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked<br />
<br />
Follow the instructions in the <code>README.md</code><br />
<br />
==== Chroot method ====<br />
<br />
The Chroot method the preferred method; it doesn't have the black screen bug and is more stable. Just translate the [https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked/blob/master/Dockerfile Dockerfile instructions] into native '''sh''' (Bourne shell). The trick again is to run Spotify as root with sudo inside the chroot – not as regular user. <br />
<br />
Use <code>sudo aplay -l</code> to verify that the soundcard is detected. When you use either this or the Docker method, which relies on ALSA, there could be a conflict depending on who grabs the sound card. Stop all browsers or programs using the sound device outside of the chroot or the docker image so that Spotify can use it.<br />
<br />
I did some translation. You may need to make changes.<br />
<br />
To update, just delete it and call <code>alpine-spotify-installer.sh</code> again. You will still need the Arch Linux bootstrap image. Extract the image. Next, copy and paste the code shown below into root.x86_64; <code>chmod +x alpine-spotify-installer.sh</code>. Then, run <code>sudo arch-chroot root.x86_64</code>. Then, run <code>./alpine-spotify-installer.sh</code>.<br />
<br />
{{Cat|alpine-spotify-installer.sh|<nowiki><br />
# Copyright (c) 2018 Orson Teodoro <orsonteodoro@hotmail.com><br />
#<br />
# Permission is hereby granted, free of charge, to any person obtaining a copy<br />
# of this software and associated documentation files (the "Software"), to deal<br />
# in the Software without restriction, including without limitation the rights<br />
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br />
# copies of the Software, and to permit persons to whom the Software is<br />
# furnished to do so, subject to the following conditions:<br />
#<br />
# The above copyright notice and this permission notice shall be included in all<br />
# copies or substantial portions of the Software.<br />
#<br />
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />
# SOFTWARE.<br />
<br />
pacman --noconfirm -Syu<br />
<br />
pacman --noconfirm -S base-devel<br />
pacman --noconfirm -S xorg-server<br />
pacman --noconfirm -S shadow<br />
pacman --noconfirm -S sudo<br />
pacman --noconfirm -S git<br />
<br />
chmod 0660 /etc/sudoers<br />
sed -i -e 's|# %wheel ALL=(ALL) NOPASSWD: ALL|%wheel ALL=(ALL) NOPASSWD: ALL\nspotify ALL=(ALL:ALL) NOPASSWD:ALL\n|g' /etc/sudoers || return 1<br />
chmod 0440 /etc/sudoers<br />
<br />
echo "Creating user spotify"<br />
useradd -m spotify<br />
echo "Deleting password for spotify"<br />
passwd -d spotify<br />
<br />
gpasswd -a spotify users<br />
gpasswd -a spotify audio<br />
gpasswd -a spotify video<br />
gpasswd -a spotify wheel<br />
<br />
echo "switching to spotify nix account"<br />
su spotify<br />
<br />
cd /home/spotify<br />
mkdir aur<br />
cd aur<br />
<br />
cd /home/spotify/aur<br />
git clone https://aur.archlinux.org/spotify.git<br />
cd /home/spotify/aur/spotify<br />
sudo -u spotify makepkg --noconfirm -si<br />
<br />
cd /home/spotify/aur/<br />
git clone https://aur.archlinux.org/paxctl.git<br />
cd /home/spotify/aur/paxctl<br />
sudo -u spotify makepkg --noconfirm -si<br />
<br />
#for grsecurity kernels like Alpine<br />
sudo paxctl -C /usr/share/spotify/spotify<br />
sudo paxctl -z /usr/share/spotify/spotify<br />
sudo paxctl -m /usr/share/spotify/spotify<br />
<br />
sudo pacman --noconfirm -S alsa-lib<br />
<br />
sudo pacman --noconfirm -S alsa-utils<br />
<br />
#confirm that the sound card(s) shows up<br />
sudo aplay -l<br />
<br />
sudo spotify<br />
</nowiki><br />
}}<br />
<br />
To make this easier, create a launcher script:<br />
<br />
{{Cat|run.sh|<nowiki>!/bin/bash<br />
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"<br />
cd $DIR<br />
sudo arch-chroot -u spotify root.x86_64 /bin/sh -c "sudo spotify"<br />
</nowiki><br />
}}<br />
<br />
If it shows <code>(spotify:4): Gtk-WARNING **: cannot open display: :0.0</code> Before running Spotify try:<br />
<br />
xhost +local:<br />
<br />
You could insert it at the very top in the above wrapper script.<br />
<br />
You may want to look at [https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked/blob/master/deflate.sh this script] to learn how to lock it down by removing the unnecessary cruft in your chroot collections that may be abused.<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=15731Running glibc programs2019-02-26T19:31:45Z<p>Head on a Stick: /* Arch Linux */ `pacstrap` now works for non-mountpoint directories so it can also be used</p>
<hr />
<div>{{Obsolete|Since 2014-04-09, Alpine has been shipping with {{Pkg|musl}} instead of [https://www.uclibc.org/ uclibc], as such, the instructions in this guide may be obsolete}}<br />
<br />
<br />
{{Draft}}<br />
<br />
If you want to run [https://www.gnu.org/software/libc/ glibc] programs in Alpine Linux, there are a few ways of doing so. You could install glibc as additional to [https://uclibc.org/about.html uclibc] (you would have to do this manually), or you could do it the easy way and use a chroot.<br><br />
<br />
Because there are different use cases, this is just a slight overview about what's possible and what's intelligent.<br><br />
<br />
<br />
= Your options =<br />
<br />
== Using BusyBox ==<br />
<br />
First, the simplest approach for setting up a chroot is by using a glibc build of [https://www.busybox.net/about.html BusyBox].<br />
<br />
This approach has just a few downsides:-<br />
* You have to link most <code>/bin/</code> and <code>/usr/bin</code> programs against <code>/bin/busybox</code>, and some BusyBox builds break if you don't configure them correctly.<br />
* You have to manually download every library you need for your program manually.<br />
<br />
However, if you want a small environment for one simple use case, then this is the solution you want.<br />
<br />
== Using a live CD ==<br />
<br />
If you prefer using any special distro, you can always download and extract a live CD and use it as a chroot enviroment.<br />
<br />
== Using an image ==<br />
<br />
For Gentoo, it is the slowest approach especially on slow machines since it is not binary distribution and can be indecisive, but you have the advantage of controlling the package version of whichever library you will install. A drawback would be a big build. You have to install a Portage tree, which uses up a lot of space. (It's not 100% necessary if you don't have to install any additional content that you won't need.) Sometimes the package will fail on compilation phase of emerge. You either end up patching it yourself or waiting for a fix to appear on their Bugzilla from an experienced user.<br />
<br />
For Arch or Debian, it is recommended since packages are precompiled and better at unattended package installation. This approach isn't as easily executed as the other alternatives, but this may be the cleanest and most recommended one for the every day user.<br />
<br />
= How to do it =<br />
<br />
This is just a quick draft, so here it comes.<br />
<br />
== Using BusyBox ==<br />
<br />
First, we need to download BusyBox. You can choose any of your favourite distros to download a prebuilt version. For instance, you could use Arch Linux [https://www.archlinux.org/packages/?q=busybox packages], as follows:<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment, which we will expand through all the commands included in BusyBox:<br />
<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
<br />
== Using a live CD ==<br />
{{Draft|Contributions welcome}}<br />
<br />
<br />
== Using an image ==<br />
<br />
=== Gentoo Linux ===<br />
<br />
Select a stage3 from [https://www.gentoo.org/downloads/ here] and portage latest from [https://www.gentoo.org/downloads/mirrors/ here] at gentoo/snapshots/portage-latest.tar.xz.<br />
<br />
First,<br />
<br />
sudo apk add xz<br />
<br />
You also may need the vanilla kernel. If any time Gentoo decides to update PAM, you need it for it to emerge successfully without problems.<br />
<br />
sudo apk add kernel-vanilla<br />
<br />
Add the kernel-vanilla to Grub and reboot with the vanilla kernel if you are going to pull in both git and layman which they use to download user community supported packages.<br />
<br />
Enter the chroot:<br />
mkdir ~/chroot<br />
cd ~/chroot<br />
tar -xvf stage3-*.tar.xz<br />
tar -xvf portage-latest.tar.xz<br />
mv portage usr<br />
sudo mount --bind /dev dev<br />
sudo mount --bind /sys sys<br />
sudo mount -t proc proc proc<br />
cp /etc/resolv.conf etc<br />
sudo chroot . /bin/bash<br />
<br />
And voilà, you have your working Gentoo chroot!<br><br />
<br />
You can now take a look at [https://wiki.gentoo.org/wiki/Handbook:Main_Page Gentoo's Handbook] to find out how you can configure and install your system, or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
Here is a wrapper script that is similar to <code>arch-chroot</code> when you frequently reuse this chroot:<br />
<br />
Also, create an account with the same user name as host current user to the chroot or make changes to the userspec option to chroot line.<br />
<br />
{{Cat|gentoo-chroot.sh|<nowiki>!/bin/bash<br />
CHROOT_PATH="/home/$USER/chroot"<br />
cd $CHROOT_PATH<br />
mount | grep $CHROOT_PATH/dev || sudo mount --bind /dev dev<br />
mount | grep $CHROOT_PATH/sys || sudo mount --bind /sys sys<br />
mount | grep $CHROOT_PATH/proc || sudo mount -t proc proc proc<br />
cp /etc/resolv.conf etc<br />
sudo chroot --userspec=$USER:users . /bin/bash<br />
echo "You must manually unmount $CHROOT_PATH/dev, $CHROOT_PATH/sys, $CHROOT_PATH/proc."<br />
</nowiki><br />
}}<br />
<br />
Do at <code>chmod +x gentoo-chroot.sh</code> to get it to work.<br />
<br />
=== Arch Linux ===<br />
<br />
Either use '''pacstrap''' (included with the arch-install-scripts package) or an Arch bootstrap image:<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2019.02.01-x86_64.tar.gz<br />
sudo tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
sudo sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist<br />
sudo sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Once that is done, update the system and install the desired package(s) (denoted by ''"foo"'' in this example):<br />
<br />
[chroot]# pacman -Syu ''foo''<br />
<br />
=== Debian ===<br />
<br />
Use the provided debootstrap package to create the Debian chroot. <code>--arch</code> is optional, depending of your needs.<br />
<br />
On the '''linux-grsec''' kernel, you will need to relax chroot limitations:<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use <code>apt-get</code> to install needed packages.<br />
<br />
== Examples ==<br />
<br />
=== Source dedicated server ===<br />
<br />
Here is an easy example of how you can run [http://www.srcds.com srcds] in a simple BusyBox chroot.<br />
<br />
For this server, you will only need the basic chroot and an advanced tar version (the BusyBox version is not sufficient because of the missing -U command):<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
Now that you are in a working chroot, you can download the server and install it. You just have to execute the following self-explaining commands...<br />
<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy, soon to be fixed (no bug in BusyBox, but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
<br />
...and you should have a working chroot with '''srcds''' installed in it.<br />
<br />
If you think you are clever or elegant, you can use the server with a bash script:<br />
<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
<br />
Just save it (in your Alpine installation) under <code>/usr/bin/steam</code>, do a <code>chmod +x /usr/bin/steam</code> and have fun!<br />
<br />
{{Warning|This script would let '''Steam''' run with root priviliges. This is not recommended.}}<br />
<br />
=== MegaCli ===<br />
<br />
So let's run [https://wikitech.wikimedia.org/wiki/MegaCli MegaCli] in a chroot too, shall we? ;)<br />
<br />
First we set up a uclibc chroot :)<br />
<br />
'''MegaCli''' needs more than just glibc. It needs [https://www.gnu.org/software/ncurses/ ncurses] and the gcc-libs:<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this, we visit [http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip this] site and download '''8.02.16_MegaCLI.zip'''.<br />
<br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
<br />
Now we have a working '''MegaCli''' client in our chroot.<br />
<br />
As with '''srcds''', we do not want to operate from inside the chroot, so here is a little script that should ease you up (use at your own risk):<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
<br />
Save it under <code>/usr/bin/MegaCli</code>. Do a <code>chmod +x /usr/bin/MegaCli</code> and good luck.<br />
<br />
Note: This method takes around 50mb. If you need something smaller, then you can strip a few files from glibc (not recommended), or work on a squashfs.<br />
<br />
With the following, you can create a squashfs that is around 15mb small:<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
<br />
When you add a [https://en.wikipedia.org/wiki/UnionFS unionfs] layer, you can even use it with write access, or you can bind some directories to the writeable directories before you chroot into it.<br />
<br />
I will look into it later on.<br />
<br />
You can save the chroot in another directory than your home directory, and you can even install a chroot through an APKBUILD (after someone wrote it).<br />
<br />
With this, you could use many glibc-dependent programs through one chroot, but be aware that running programs like this should not be standard. This should only be used in extreme situations, as in _closed source_ tools linked against glibc.<br />
<br />
=== Skype on Debian chroot ===<br />
<br />
{{Draft|Not yet validated}}<br />
<br />
This is an example on how to run '''Skype''' from a Debian 32b chroot.<br />
<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
<br />
To fix missing dependencies, you will want to use:<br />
<br />
apt-get -f install<br />
<br />
Then, exit the chroot:<br />
<br />
exit<br />
<br />
Fix PAX flags on Skype binary - '''linux-grsec''' only.<br />
<br />
ELF marking with paxctl cannot be used because Skype binary refuses to run if modified.<br />
<br />
<code>CONFIG_PAX_XATTR_PAX_FLAGS</code> is NOT yet available in '''linux-grsec'''.<br />
<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br />
<br />
Give write access to <code>/dev/v4l</code> and to <code>/dev/snd</code> in order to let Skype use the webcam device: Skype is not compatible with Alsa anymore and requires Pulseaudio to be running.<br />
<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
<br />
Enter the chroot and create a user:<br />
<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
<br />
Then run Skype as your newly created user:<br />
<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
<br />
=== Dungeon Crawl (Stone Soup) on Arch ===<br />
<br />
Once the Arch system is laid down (to <code>~/chroot/root.x86_64</code> in this example), install the game:<br />
<br />
sudo arch-chroot ~/chroot/root.x86_64<br />
[chroot]# pacman -Syu crawl-tiles<br />
<br />
Then exit the chroot and run it with this command:<br />
<br />
sudo arch-chroot ~/chroot/root.x86_64 /bin/su -c 'DISPLAY=:0 crawl-tiles'<br />
<br />
A separate user can also be created to run the game, if preferred.<br />
<br />
<br />
=== Spotify ===<br />
<br />
==== Docker method ====<br />
<br />
Read the [[Docker]] page to install it. Then clone the repository, as shown below. It will automate the process of pulling all the dependencies, and '''PaX''' marks it for the hardened kernel. The advantage of this container is that it is ready-to-use and has stripped down many of the <code>/usr/bin</code> executables. The downside is that is unstable.<br />
<br />
git clone https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked<br />
<br />
Follow the instructions in the <code>README.md</code><br />
<br />
==== Chroot method ====<br />
<br />
The Chroot method the preferred method; it doesn't have the black screen bug and is more stable. Just translate the [https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked/blob/master/Dockerfile Dockerfile instructions] into native '''sh''' (Bourne shell). The trick again is to run Spotify as root with sudo inside the chroot – not as regular user. <br />
<br />
Use <code>sudo aplay -l</code> to verify that the soundcard is detected. When you use either this or the Docker method, which relies on ALSA, there could be a conflict depending on who grabs the sound card. Stop all browsers or programs using the sound device outside of the chroot or the docker image so that Spotify can use it.<br />
<br />
I did some translation. You may need to make changes.<br />
<br />
To update, just delete it and call <code>alpine-spotify-installer.sh</code> again. You will still need the Arch Linux bootstrap image. Extract the image. Next, copy and paste the code shown below into root.x86_64; <code>chmod +x alpine-spotify-installer.sh</code>. Then, run <code>sudo arch-chroot root.x86_64</code>. Then, run <code>./alpine-spotify-installer.sh</code>.<br />
<br />
{{Cat|alpine-spotify-installer.sh|<nowiki><br />
# Copyright (c) 2018 Orson Teodoro <orsonteodoro@hotmail.com><br />
#<br />
# Permission is hereby granted, free of charge, to any person obtaining a copy<br />
# of this software and associated documentation files (the "Software"), to deal<br />
# in the Software without restriction, including without limitation the rights<br />
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br />
# copies of the Software, and to permit persons to whom the Software is<br />
# furnished to do so, subject to the following conditions:<br />
#<br />
# The above copyright notice and this permission notice shall be included in all<br />
# copies or substantial portions of the Software.<br />
#<br />
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />
# SOFTWARE.<br />
<br />
pacman --noconfirm -Syu<br />
<br />
pacman --noconfirm -S base-devel<br />
pacman --noconfirm -S xorg-server<br />
pacman --noconfirm -S shadow<br />
pacman --noconfirm -S sudo<br />
pacman --noconfirm -S git<br />
<br />
chmod 0660 /etc/sudoers<br />
sed -i -e 's|# %wheel ALL=(ALL) NOPASSWD: ALL|%wheel ALL=(ALL) NOPASSWD: ALL\nspotify ALL=(ALL:ALL) NOPASSWD:ALL\n|g' /etc/sudoers || return 1<br />
chmod 0440 /etc/sudoers<br />
<br />
echo "Creating user spotify"<br />
useradd -m spotify<br />
echo "Deleting password for spotify"<br />
passwd -d spotify<br />
<br />
gpasswd -a spotify users<br />
gpasswd -a spotify audio<br />
gpasswd -a spotify video<br />
gpasswd -a spotify wheel<br />
<br />
echo "switching to spotify nix account"<br />
su spotify<br />
<br />
cd /home/spotify<br />
mkdir aur<br />
cd aur<br />
<br />
cd /home/spotify/aur<br />
git clone https://aur.archlinux.org/spotify.git<br />
cd /home/spotify/aur/spotify<br />
sudo -u spotify makepkg --noconfirm -si<br />
<br />
cd /home/spotify/aur/<br />
git clone https://aur.archlinux.org/paxctl.git<br />
cd /home/spotify/aur/paxctl<br />
sudo -u spotify makepkg --noconfirm -si<br />
<br />
#for grsecurity kernels like Alpine<br />
sudo paxctl -C /usr/share/spotify/spotify<br />
sudo paxctl -z /usr/share/spotify/spotify<br />
sudo paxctl -m /usr/share/spotify/spotify<br />
<br />
sudo pacman --noconfirm -S alsa-lib<br />
<br />
sudo pacman --noconfirm -S alsa-utils<br />
<br />
#confirm that the sound card(s) shows up<br />
sudo aplay -l<br />
<br />
sudo spotify<br />
</nowiki><br />
}}<br />
<br />
To make this easier, create a launcher script:<br />
<br />
{{Cat|run.sh|<nowiki>!/bin/bash<br />
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"<br />
cd $DIR<br />
sudo arch-chroot -u spotify root.x86_64 /bin/sh -c "sudo spotify"<br />
</nowiki><br />
}}<br />
<br />
If it shows <code>(spotify:4): Gtk-WARNING **: cannot open display: :0.0</code> Before running Spotify try:<br />
<br />
xhost +local:<br />
<br />
You could insert it at the very top in the above wrapper script.<br />
<br />
You may want to look at [https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked/blob/master/deflate.sh this script] to learn how to lock it down by removing the unnecessary cruft in your chroot collections that may be abused.<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=15730Running glibc programs2019-02-26T19:19:34Z<p>Head on a Stick: /* Arch Linux */ updated for CheckSpace option & sudo</p>
<hr />
<div>{{Obsolete|Since 2014-04-09, Alpine has been shipping with {{Pkg|musl}} instead of [https://www.uclibc.org/ uclibc], as such, the instructions in this guide may be obsolete}}<br />
<br />
<br />
{{Draft}}<br />
<br />
If you want to run [https://www.gnu.org/software/libc/ glibc] programs in Alpine Linux, there are a few ways of doing so. You could install glibc as additional to [https://uclibc.org/about.html uclibc] (you would have to do this manually), or you could do it the easy way and use a chroot.<br><br />
<br />
Because there are different use cases, this is just a slight overview about what's possible and what's intelligent.<br><br />
<br />
<br />
= Your options =<br />
<br />
== Using BusyBox ==<br />
<br />
First, the simplest approach for setting up a chroot is by using a glibc build of [https://www.busybox.net/about.html BusyBox].<br />
<br />
This approach has just a few downsides:-<br />
* You have to link most <code>/bin/</code> and <code>/usr/bin</code> programs against <code>/bin/busybox</code>, and some BusyBox builds break if you don't configure them correctly.<br />
* You have to manually download every library you need for your program manually.<br />
<br />
However, if you want a small environment for one simple use case, then this is the solution you want.<br />
<br />
== Using a live CD ==<br />
<br />
If you prefer using any special distro, you can always download and extract a live CD and use it as a chroot enviroment.<br />
<br />
== Using an image ==<br />
<br />
For Gentoo, it is the slowest approach especially on slow machines since it is not binary distribution and can be indecisive, but you have the advantage of controlling the package version of whichever library you will install. A drawback would be a big build. You have to install a Portage tree, which uses up a lot of space. (It's not 100% necessary if you don't have to install any additional content that you won't need.) Sometimes the package will fail on compilation phase of emerge. You either end up patching it yourself or waiting for a fix to appear on their Bugzilla from an experienced user.<br />
<br />
For Arch or Debian, it is recommended since packages are precompiled and better at unattended package installation. This approach isn't as easily executed as the other alternatives, but this may be the cleanest and most recommended one for the every day user.<br />
<br />
= How to do it =<br />
<br />
This is just a quick draft, so here it comes.<br />
<br />
== Using BusyBox ==<br />
<br />
First, we need to download BusyBox. You can choose any of your favourite distros to download a prebuilt version. For instance, you could use Arch Linux [https://www.archlinux.org/packages/?q=busybox packages], as follows:<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment, which we will expand through all the commands included in BusyBox:<br />
<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
<br />
== Using a live CD ==<br />
{{Draft|Contributions welcome}}<br />
<br />
<br />
== Using an image ==<br />
<br />
=== Gentoo Linux ===<br />
<br />
Select a stage3 from [https://www.gentoo.org/downloads/ here] and portage latest from [https://www.gentoo.org/downloads/mirrors/ here] at gentoo/snapshots/portage-latest.tar.xz.<br />
<br />
First,<br />
<br />
sudo apk add xz<br />
<br />
You also may need the vanilla kernel. If any time Gentoo decides to update PAM, you need it for it to emerge successfully without problems.<br />
<br />
sudo apk add kernel-vanilla<br />
<br />
Add the kernel-vanilla to Grub and reboot with the vanilla kernel if you are going to pull in both git and layman which they use to download user community supported packages.<br />
<br />
Enter the chroot:<br />
mkdir ~/chroot<br />
cd ~/chroot<br />
tar -xvf stage3-*.tar.xz<br />
tar -xvf portage-latest.tar.xz<br />
mv portage usr<br />
sudo mount --bind /dev dev<br />
sudo mount --bind /sys sys<br />
sudo mount -t proc proc proc<br />
cp /etc/resolv.conf etc<br />
sudo chroot . /bin/bash<br />
<br />
And voilà, you have your working Gentoo chroot!<br><br />
<br />
You can now take a look at [https://wiki.gentoo.org/wiki/Handbook:Main_Page Gentoo's Handbook] to find out how you can configure and install your system, or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
Here is a wrapper script that is similar to <code>arch-chroot</code> when you frequently reuse this chroot:<br />
<br />
Also, create an account with the same user name as host current user to the chroot or make changes to the userspec option to chroot line.<br />
<br />
{{Cat|gentoo-chroot.sh|<nowiki>!/bin/bash<br />
CHROOT_PATH="/home/$USER/chroot"<br />
cd $CHROOT_PATH<br />
mount | grep $CHROOT_PATH/dev || sudo mount --bind /dev dev<br />
mount | grep $CHROOT_PATH/sys || sudo mount --bind /sys sys<br />
mount | grep $CHROOT_PATH/proc || sudo mount -t proc proc proc<br />
cp /etc/resolv.conf etc<br />
sudo chroot --userspec=$USER:users . /bin/bash<br />
echo "You must manually unmount $CHROOT_PATH/dev, $CHROOT_PATH/sys, $CHROOT_PATH/proc."<br />
</nowiki><br />
}}<br />
<br />
Do at <code>chmod +x gentoo-chroot.sh</code> to get it to work.<br />
<br />
=== Arch Linux ===<br />
<br />
Although '''pacstrap''' is included with the arch-install-scripts package, it will not work unless the target directory is a mountpoint, so the Arch bootstrap image must be used instead (the image is updated every month, so change the date in the link as required):<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2019.02.01-x86_64.tar.gz<br />
sudo tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
sudo sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist<br />
sudo sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Once that is done, update the system and install the desired package(s) (denoted by ''"foo"'' in this example):<br />
<br />
[chroot]# pacman -Syu ''foo''<br />
<br />
=== Debian ===<br />
<br />
Use the provided debootstrap package to create the Debian chroot. <code>--arch</code> is optional, depending of your needs.<br />
<br />
On the '''linux-grsec''' kernel, you will need to relax chroot limitations:<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use <code>apt-get</code> to install needed packages.<br />
<br />
== Examples ==<br />
<br />
=== Source dedicated server ===<br />
<br />
Here is an easy example of how you can run [http://www.srcds.com srcds] in a simple BusyBox chroot.<br />
<br />
For this server, you will only need the basic chroot and an advanced tar version (the BusyBox version is not sufficient because of the missing -U command):<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
Now that you are in a working chroot, you can download the server and install it. You just have to execute the following self-explaining commands...<br />
<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy, soon to be fixed (no bug in BusyBox, but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
<br />
...and you should have a working chroot with '''srcds''' installed in it.<br />
<br />
If you think you are clever or elegant, you can use the server with a bash script:<br />
<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
<br />
Just save it (in your Alpine installation) under <code>/usr/bin/steam</code>, do a <code>chmod +x /usr/bin/steam</code> and have fun!<br />
<br />
{{Warning|This script would let '''Steam''' run with root priviliges. This is not recommended.}}<br />
<br />
=== MegaCli ===<br />
<br />
So let's run [https://wikitech.wikimedia.org/wiki/MegaCli MegaCli] in a chroot too, shall we? ;)<br />
<br />
First we set up a uclibc chroot :)<br />
<br />
'''MegaCli''' needs more than just glibc. It needs [https://www.gnu.org/software/ncurses/ ncurses] and the gcc-libs:<br />
<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this, we visit [http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip this] site and download '''8.02.16_MegaCLI.zip'''.<br />
<br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
<br />
Now we have a working '''MegaCli''' client in our chroot.<br />
<br />
As with '''srcds''', we do not want to operate from inside the chroot, so here is a little script that should ease you up (use at your own risk):<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
<br />
Save it under <code>/usr/bin/MegaCli</code>. Do a <code>chmod +x /usr/bin/MegaCli</code> and good luck.<br />
<br />
Note: This method takes around 50mb. If you need something smaller, then you can strip a few files from glibc (not recommended), or work on a squashfs.<br />
<br />
With the following, you can create a squashfs that is around 15mb small:<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
<br />
When you add a [https://en.wikipedia.org/wiki/UnionFS unionfs] layer, you can even use it with write access, or you can bind some directories to the writeable directories before you chroot into it.<br />
<br />
I will look into it later on.<br />
<br />
You can save the chroot in another directory than your home directory, and you can even install a chroot through an APKBUILD (after someone wrote it).<br />
<br />
With this, you could use many glibc-dependent programs through one chroot, but be aware that running programs like this should not be standard. This should only be used in extreme situations, as in _closed source_ tools linked against glibc.<br />
<br />
=== Skype on Debian chroot ===<br />
<br />
{{Draft|Not yet validated}}<br />
<br />
This is an example on how to run '''Skype''' from a Debian 32b chroot.<br />
<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
<br />
To fix missing dependencies, you will want to use:<br />
<br />
apt-get -f install<br />
<br />
Then, exit the chroot:<br />
<br />
exit<br />
<br />
Fix PAX flags on Skype binary - '''linux-grsec''' only.<br />
<br />
ELF marking with paxctl cannot be used because Skype binary refuses to run if modified.<br />
<br />
<code>CONFIG_PAX_XATTR_PAX_FLAGS</code> is NOT yet available in '''linux-grsec'''.<br />
<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br />
<br />
Give write access to <code>/dev/v4l</code> and to <code>/dev/snd</code> in order to let Skype use the webcam device: Skype is not compatible with Alsa anymore and requires Pulseaudio to be running.<br />
<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
<br />
Enter the chroot and create a user:<br />
<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
<br />
Then run Skype as your newly created user:<br />
<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
<br />
=== Dungeon Crawl (Stone Soup) on Arch ===<br />
<br />
Once the Arch system is laid down (to <code>~/chroot/root.x86_64</code> in this example), install the game:<br />
<br />
sudo arch-chroot ~/chroot/root.x86_64<br />
[chroot]# pacman -Syu crawl-tiles<br />
<br />
Then exit the chroot and run it with this command:<br />
<br />
sudo arch-chroot ~/chroot/root.x86_64 /bin/su -c 'DISPLAY=:0 crawl-tiles'<br />
<br />
A separate user can also be created to run the game, if preferred.<br />
<br />
<br />
=== Spotify ===<br />
<br />
==== Docker method ====<br />
<br />
Read the [[Docker]] page to install it. Then clone the repository, as shown below. It will automate the process of pulling all the dependencies, and '''PaX''' marks it for the hardened kernel. The advantage of this container is that it is ready-to-use and has stripped down many of the <code>/usr/bin</code> executables. The downside is that is unstable.<br />
<br />
git clone https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked<br />
<br />
Follow the instructions in the <code>README.md</code><br />
<br />
==== Chroot method ====<br />
<br />
The Chroot method the preferred method; it doesn't have the black screen bug and is more stable. Just translate the [https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked/blob/master/Dockerfile Dockerfile instructions] into native '''sh''' (Bourne shell). The trick again is to run Spotify as root with sudo inside the chroot – not as regular user. <br />
<br />
Use <code>sudo aplay -l</code> to verify that the soundcard is detected. When you use either this or the Docker method, which relies on ALSA, there could be a conflict depending on who grabs the sound card. Stop all browsers or programs using the sound device outside of the chroot or the docker image so that Spotify can use it.<br />
<br />
I did some translation. You may need to make changes.<br />
<br />
To update, just delete it and call <code>alpine-spotify-installer.sh</code> again. You will still need the Arch Linux bootstrap image. Extract the image. Next, copy and paste the code shown below into root.x86_64; <code>chmod +x alpine-spotify-installer.sh</code>. Then, run <code>sudo arch-chroot root.x86_64</code>. Then, run <code>./alpine-spotify-installer.sh</code>.<br />
<br />
{{Cat|alpine-spotify-installer.sh|<nowiki><br />
# Copyright (c) 2018 Orson Teodoro <orsonteodoro@hotmail.com><br />
#<br />
# Permission is hereby granted, free of charge, to any person obtaining a copy<br />
# of this software and associated documentation files (the "Software"), to deal<br />
# in the Software without restriction, including without limitation the rights<br />
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br />
# copies of the Software, and to permit persons to whom the Software is<br />
# furnished to do so, subject to the following conditions:<br />
#<br />
# The above copyright notice and this permission notice shall be included in all<br />
# copies or substantial portions of the Software.<br />
#<br />
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />
# SOFTWARE.<br />
<br />
pacman --noconfirm -Syu<br />
<br />
pacman --noconfirm -S base-devel<br />
pacman --noconfirm -S xorg-server<br />
pacman --noconfirm -S shadow<br />
pacman --noconfirm -S sudo<br />
pacman --noconfirm -S git<br />
<br />
chmod 0660 /etc/sudoers<br />
sed -i -e 's|# %wheel ALL=(ALL) NOPASSWD: ALL|%wheel ALL=(ALL) NOPASSWD: ALL\nspotify ALL=(ALL:ALL) NOPASSWD:ALL\n|g' /etc/sudoers || return 1<br />
chmod 0440 /etc/sudoers<br />
<br />
echo "Creating user spotify"<br />
useradd -m spotify<br />
echo "Deleting password for spotify"<br />
passwd -d spotify<br />
<br />
gpasswd -a spotify users<br />
gpasswd -a spotify audio<br />
gpasswd -a spotify video<br />
gpasswd -a spotify wheel<br />
<br />
echo "switching to spotify nix account"<br />
su spotify<br />
<br />
cd /home/spotify<br />
mkdir aur<br />
cd aur<br />
<br />
cd /home/spotify/aur<br />
git clone https://aur.archlinux.org/spotify.git<br />
cd /home/spotify/aur/spotify<br />
sudo -u spotify makepkg --noconfirm -si<br />
<br />
cd /home/spotify/aur/<br />
git clone https://aur.archlinux.org/paxctl.git<br />
cd /home/spotify/aur/paxctl<br />
sudo -u spotify makepkg --noconfirm -si<br />
<br />
#for grsecurity kernels like Alpine<br />
sudo paxctl -C /usr/share/spotify/spotify<br />
sudo paxctl -z /usr/share/spotify/spotify<br />
sudo paxctl -m /usr/share/spotify/spotify<br />
<br />
sudo pacman --noconfirm -S alsa-lib<br />
<br />
sudo pacman --noconfirm -S alsa-utils<br />
<br />
#confirm that the sound card(s) shows up<br />
sudo aplay -l<br />
<br />
sudo spotify<br />
</nowiki><br />
}}<br />
<br />
To make this easier, create a launcher script:<br />
<br />
{{Cat|run.sh|<nowiki>!/bin/bash<br />
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"<br />
cd $DIR<br />
sudo arch-chroot -u spotify root.x86_64 /bin/sh -c "sudo spotify"<br />
</nowiki><br />
}}<br />
<br />
If it shows <code>(spotify:4): Gtk-WARNING **: cannot open display: :0.0</code> Before running Spotify try:<br />
<br />
xhost +local:<br />
<br />
You could insert it at the very top in the above wrapper script.<br />
<br />
You may want to look at [https://github.com/orsonteodoro/docker-arch-spotify-PaXmarked/blob/master/deflate.sh this script] to learn how to lock it down by removing the unnecessary cruft in your chroot collections that may be abused.<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=14252Running glibc programs2017-12-31T20:49:09Z<p>Head on a Stick: /* Archlinux */ tidy</p>
<hr />
<div>{{Draft}}<br />
<br />
If you want to run glibc programs under alpine there are a few ways to do so.You could install glibc additional to uclibc (you would have to do this manualy) or you could do the easy way and use a chroot.<br><br />
Because there are different usecases I want to give a slight overview about what's possible and what is intelligent.<br><br />
<br />
==Your options==<br />
===Using Busybox===<br />
First the most simple approach for setting up a chroot is using a glibc build of busybox.<br><br />
This approach has just a few downsides:<br><br />
- You have to link most /bin/ and /usr/bin program against /bin/busybox and some busybox builds break if you don't configure it right.<br><br />
- You have to manually download every library you need for your program manually.<br><br><br />
But if you want a small enviroment for one simple use case this is the solution you want.<br />
<br />
===Using a livecd===<br />
If you prefer any special distri you can always download and extract a livecd and use it as a chroot enviroment.<br />
<br />
===Using a stage3 gentoo archive===<br />
This is the fastest approach and you have the advantage of controlling which package version of which library you will install.<br><br />
Drawbacks are as follow:<br><br />
- Big build.You have to install a portage tree which uses up a lot of space.(It's not 100% necessary if you don't have to install any additional content you don't need it)<br><br />
- On slow mashines not recommended because you have to compile your packages.<br><br />
<br />
===Using Archlinux or Debian===<br />
If you want a nice running system you can install Arch or Debian in a chroot.This approach isn't as easily executed as the other alternatives, but are in my opinion the cleanest and most recommended for the every day user.<br />
<br />
==How to do it==<br />
Like I said this is just a quick draft so here it comes.<br />
===Using Busybox===<br />
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment which we will expand through all commands included in busybox.<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
===Using a livecd===<br />
WIP<br />
<br />
===Using a stage3 tar archive===<br />
Select a mirror from http://www.gentoo.org/main/en/mirrors2.xml , switch to /releases/x86/current-stage3/ and download the latest tar ball (for me stage3-i686-20120124.tar.bz2 ).<br />
wget http://de-mirror.org/gentoo/releases/x86/current-stage3/stage3-i686-20120124.tar.bz2<br />
mkdir ~/chroot<br />
tar xfj stage3-i686-*.tar.bz2 -C ~/chroot<br />
sudo chroot ~/chroot<br />
And voila you got your working gentoo chroot.<br><br />
You can now take a look at http://www.gentoo.org/doc/en/?catid=desktop to find out how you can configure and install your system or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
===Using Archlinux or Debian===<br />
====Arch Linux====<br />
Although pacstrap is included with the arch-install-scripts package it will not work unless the target directory is a mountpoint so the Arch bootstrap image must be used instead (the image is updated every month so change the date in the link as required):<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Once that is done, update the system and install the desired package(s) (denoted by "foo" in this example):<br />
<br />
[chroot]# pacman -Syu foo<br />
<br />
====Debian====<br />
Use the provided debootstrap package to create the Debian chroot. --arch is optional depending of your needs.<br><br />
On linux-grsec kernel you'll need to relax chroot limitations.<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use apt-get to install needed packages.<br />
<br />
==Example==<br />
===Source Dedicated Server===<br />
Here is an easy example of how you can run http://www.srcds.com in a simple busybox chroot.<br><br />
For this server you will only need the basic chroot and a advanced tar version (the busybox version is not sufficient because of the missing -U command).<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
Now that you are in a working chroot you can download the server and install it.You just have to execute the following self explaining commands.<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy soon to be fixed (no bug in busybox but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
And you should have a working chroot with srcds installed in it.<br><br />
If you think you are clever or elegant you can use the server with a bash script.<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
Just save it (in your alpine installation) under /usr/bin/steam do a chmod +x /usr/bin/steam and have phun.<br><br />
WARNING:<br><br />
This script would let steam run with root priviliges.This is not recommended.<br />
<br />
===MegaCli===<br />
So let's run MegaCli in a chroot to shall we? ;)<br><br />
First we set up a uclibc chroot :)<br><br />
MegaCli needs more than just glibc it needs ncurses and the gcc-libs.<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this we visit this site http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip and download 8.02.16_MegaCLI.zip.<br><br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
Now we got a working MegaCli client in our chroot.<br><br />
Like with srcds we don't want to operate from inside the chroot so here is a little script that should ease you up. (use at your own risk)<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
Save it under /usr/bin/MegaCli .Do a chmod +x /usr/bin/MegaCli and good luck.<br />
Hf<br />
PS<br />
This method takes around 50mb.If you need something smaller you can strip a few files from glibc (not recommended) or work on a squashfs.<br><br />
With<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
you can create a squashfs that is around 15mb small.When you add an unionfs layer you can even use it with write access or you can bind some dirs to the writeable dirs before you chroot into it.<br><br />
I will look into it later on.<br><br />
You can save the chroot in another dir than your home dir and you an even install a chroot through a APKBUILD (after someone wrote it).<br><br />
Through this you could use many glibc dependend programs through one chroot, but be aware that running programs like this should not be standard but only be used in extreme situations like for _closed source_ tools linked against glibc.<br />
<br />
===Skype on Debian chroot===<br />
WIP - Not yet validated<br><br />
This is an example on how to run Skype from a Debian 32b chroot.<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
To fix missings deps you'll want to use:<br />
apt-get -f install<br />
Then exit the chroot<br />
exit<br />
Fix PAX flags on Skype binary - linux-grsec only.<br><br />
ELF marking with paxctl cannot be used cause Skype binary refuses to run if modified<br><br />
CONFIG_PAX_XATTR_PAX_FLAGS is NOT yet available in linux-grsec<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br><br />
Give write access to /dev/v4l and /dev/snd to let Skype use webcam device - Skype is not compatible with Alsa anymore and requires Pulseaudio running.<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
Enter the chroot and create a user<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
Then run skype as your newly created user<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
===Dungeon Crawl (Stone Soup) on Arch===<br />
Once the Arch system is laid down (to ~/chroot/root.x86_64 in this example), install the game:<br />
sudo arch-chroot ~/chroot/root.x86_64<br />
[chroot]# pacman -Syu crawl-tiles<br />
Then exit the chroot and run it with this command:<br />
sudo arch-chroot ~/chroot/root.x86_64 /bin/su -c 'DISPLAY=:0 crawl-tiles'<br />
A separate user can also be created to run the game, if preferred.<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=14251Running glibc programs2017-12-31T20:40:56Z<p>Head on a Stick: /* Example */ added Arch example</p>
<hr />
<div>{{Draft}}<br />
<br />
If you want to run glibc programs under alpine there are a few ways to do so.You could install glibc additional to uclibc (you would have to do this manualy) or you could do the easy way and use a chroot.<br><br />
Because there are different usecases I want to give a slight overview about what's possible and what is intelligent.<br><br />
<br />
==Your options==<br />
===Using Busybox===<br />
First the most simple approach for setting up a chroot is using a glibc build of busybox.<br><br />
This approach has just a few downsides:<br><br />
- You have to link most /bin/ and /usr/bin program against /bin/busybox and some busybox builds break if you don't configure it right.<br><br />
- You have to manually download every library you need for your program manually.<br><br><br />
But if you want a small enviroment for one simple use case this is the solution you want.<br />
<br />
===Using a livecd===<br />
If you prefer any special distri you can always download and extract a livecd and use it as a chroot enviroment.<br />
<br />
===Using a stage3 gentoo archive===<br />
This is the fastest approach and you have the advantage of controlling which package version of which library you will install.<br><br />
Drawbacks are as follow:<br><br />
- Big build.You have to install a portage tree which uses up a lot of space.(It's not 100% necessary if you don't have to install any additional content you don't need it)<br><br />
- On slow mashines not recommended because you have to compile your packages.<br><br />
<br />
===Using Archlinux or Debian===<br />
If you want a nice running system you can install Arch or Debian in a chroot.This approach isn't as easily executed as the other alternatives, but are in my opinion the cleanest and most recommended for the every day user.<br />
<br />
==How to do it==<br />
Like I said this is just a quick draft so here it comes.<br />
===Using Busybox===<br />
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment which we will expand through all commands included in busybox.<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
===Using a livecd===<br />
WIP<br />
<br />
===Using a stage3 tar archive===<br />
Select a mirror from http://www.gentoo.org/main/en/mirrors2.xml , switch to /releases/x86/current-stage3/ and download the latest tar ball (for me stage3-i686-20120124.tar.bz2 ).<br />
wget http://de-mirror.org/gentoo/releases/x86/current-stage3/stage3-i686-20120124.tar.bz2<br />
mkdir ~/chroot<br />
tar xfj stage3-i686-*.tar.bz2 -C ~/chroot<br />
sudo chroot ~/chroot<br />
And voila you got your working gentoo chroot.<br><br />
You can now take a look at http://www.gentoo.org/doc/en/?catid=desktop to find out how you can configure and install your system or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
===Using Archlinux or Debian===<br />
====Archlinux====<br />
Although pacstrap is included with the arch-install-scripts package it will not work unless the target directory is a mountpoint so the Arch bootstrap image must be used instead (the image is updated every month so change the date in the link as required):<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Once that is done, update the system and install the desired package(s) (denoted by "foo" in this example):<br />
<br />
[chroot]# pacman -Syu foo<br />
<br />
====Debian====<br />
Use the provided debootstrap package to create the Debian chroot. --arch is optional depending of your needs.<br><br />
On linux-grsec kernel you'll need to relax chroot limitations.<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use apt-get to install needed packages.<br />
<br />
==Example==<br />
===Source Dedicated Server===<br />
Here is an easy example of how you can run http://www.srcds.com in a simple busybox chroot.<br><br />
For this server you will only need the basic chroot and a advanced tar version (the busybox version is not sufficient because of the missing -U command).<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
Now that you are in a working chroot you can download the server and install it.You just have to execute the following self explaining commands.<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy soon to be fixed (no bug in busybox but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
And you should have a working chroot with srcds installed in it.<br><br />
If you think you are clever or elegant you can use the server with a bash script.<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
Just save it (in your alpine installation) under /usr/bin/steam do a chmod +x /usr/bin/steam and have phun.<br><br />
WARNING:<br><br />
This script would let steam run with root priviliges.This is not recommended.<br />
<br />
===MegaCli===<br />
So let's run MegaCli in a chroot to shall we? ;)<br><br />
First we set up a uclibc chroot :)<br><br />
MegaCli needs more than just glibc it needs ncurses and the gcc-libs.<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this we visit this site http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip and download 8.02.16_MegaCLI.zip.<br><br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
Now we got a working MegaCli client in our chroot.<br><br />
Like with srcds we don't want to operate from inside the chroot so here is a little script that should ease you up. (use at your own risk)<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
Save it under /usr/bin/MegaCli .Do a chmod +x /usr/bin/MegaCli and good luck.<br />
Hf<br />
PS<br />
This method takes around 50mb.If you need something smaller you can strip a few files from glibc (not recommended) or work on a squashfs.<br><br />
With<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
you can create a squashfs that is around 15mb small.When you add an unionfs layer you can even use it with write access or you can bind some dirs to the writeable dirs before you chroot into it.<br><br />
I will look into it later on.<br><br />
You can save the chroot in another dir than your home dir and you an even install a chroot through a APKBUILD (after someone wrote it).<br><br />
Through this you could use many glibc dependend programs through one chroot, but be aware that running programs like this should not be standard but only be used in extreme situations like for _closed source_ tools linked against glibc.<br />
<br />
===Skype on Debian chroot===<br />
WIP - Not yet validated<br><br />
This is an example on how to run Skype from a Debian 32b chroot.<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
To fix missings deps you'll want to use:<br />
apt-get -f install<br />
Then exit the chroot<br />
exit<br />
Fix PAX flags on Skype binary - linux-grsec only.<br><br />
ELF marking with paxctl cannot be used cause Skype binary refuses to run if modified<br><br />
CONFIG_PAX_XATTR_PAX_FLAGS is NOT yet available in linux-grsec<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br><br />
Give write access to /dev/v4l and /dev/snd to let Skype use webcam device - Skype is not compatible with Alsa anymore and requires Pulseaudio running.<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
Enter the chroot and create a user<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
Then run skype as your newly created user<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
===Dungeon Crawl (Stone Soup) on Arch===<br />
Once the Arch system is laid down (to ~/chroot/root.x86_64 in this example), install the game:<br />
sudo arch-chroot ~/chroot/root.x86_64<br />
[chroot]# pacman -Syu crawl-tiles<br />
Then exit the chroot and run it with this command:<br />
sudo arch-chroot ~/chroot/root.x86_64 /bin/su -c 'DISPLAY=:0 crawl-tiles'<br />
A separate user can also be created to run the game, if preferred.<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=14250Running glibc programs2017-12-31T20:21:01Z<p>Head on a Stick: /* Archlinux */ corrections (I'll get there in the end, sorry about this)</p>
<hr />
<div>{{Draft}}<br />
<br />
If you want to run glibc programs under alpine there are a few ways to do so.You could install glibc additional to uclibc (you would have to do this manualy) or you could do the easy way and use a chroot.<br><br />
Because there are different usecases I want to give a slight overview about what's possible and what is intelligent.<br><br />
<br />
==Your options==<br />
===Using Busybox===<br />
First the most simple approach for setting up a chroot is using a glibc build of busybox.<br><br />
This approach has just a few downsides:<br><br />
- You have to link most /bin/ and /usr/bin program against /bin/busybox and some busybox builds break if you don't configure it right.<br><br />
- You have to manually download every library you need for your program manually.<br><br><br />
But if you want a small enviroment for one simple use case this is the solution you want.<br />
<br />
===Using a livecd===<br />
If you prefer any special distri you can always download and extract a livecd and use it as a chroot enviroment.<br />
<br />
===Using a stage3 gentoo archive===<br />
This is the fastest approach and you have the advantage of controlling which package version of which library you will install.<br><br />
Drawbacks are as follow:<br><br />
- Big build.You have to install a portage tree which uses up a lot of space.(It's not 100% necessary if you don't have to install any additional content you don't need it)<br><br />
- On slow mashines not recommended because you have to compile your packages.<br><br />
<br />
===Using Archlinux or Debian===<br />
If you want a nice running system you can install Arch or Debian in a chroot.This approach isn't as easily executed as the other alternatives, but are in my opinion the cleanest and most recommended for the every day user.<br />
<br />
==How to do it==<br />
Like I said this is just a quick draft so here it comes.<br />
===Using Busybox===<br />
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment which we will expand through all commands included in busybox.<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
===Using a livecd===<br />
WIP<br />
<br />
===Using a stage3 tar archive===<br />
Select a mirror from http://www.gentoo.org/main/en/mirrors2.xml , switch to /releases/x86/current-stage3/ and download the latest tar ball (for me stage3-i686-20120124.tar.bz2 ).<br />
wget http://de-mirror.org/gentoo/releases/x86/current-stage3/stage3-i686-20120124.tar.bz2<br />
mkdir ~/chroot<br />
tar xfj stage3-i686-*.tar.bz2 -C ~/chroot<br />
sudo chroot ~/chroot<br />
And voila you got your working gentoo chroot.<br><br />
You can now take a look at http://www.gentoo.org/doc/en/?catid=desktop to find out how you can configure and install your system or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
===Using Archlinux or Debian===<br />
====Archlinux====<br />
Although pacstrap is included with the arch-install-scripts package it will not work unless the target directory is a mountpoint so the Arch bootstrap image must be used instead (the image is updated every month so change the date in the link as required):<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Once that is done, update the system and install the desired package(s) (denoted by "foo" in this example):<br />
<br />
[chroot]# pacman -Syu foo<br />
<br />
====Debian====<br />
Use the provided debootstrap package to create the Debian chroot. --arch is optional depending of your needs.<br><br />
On linux-grsec kernel you'll need to relax chroot limitations.<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use apt-get to install needed packages.<br />
<br />
==Example==<br />
===Source Dedicated Server===<br />
Here is an easy example of how you can run http://www.srcds.com in a simple busybox chroot.<br><br />
For this server you will only need the basic chroot and a advanced tar version (the busybox version is not sufficient because of the missing -U command).<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
Now that you are in a working chroot you can download the server and install it.You just have to execute the following self explaining commands.<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy soon to be fixed (no bug in busybox but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
And you should have a working chroot with srcds installed in it.<br><br />
If you think you are clever or elegant you can use the server with a bash script.<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
Just save it (in your alpine installation) under /usr/bin/steam do a chmod +x /usr/bin/steam and have phun.<br><br />
WARNING:<br><br />
This script would let steam run with root priviliges.This is not recommended.<br />
<br />
===MegaCli===<br />
So let's run MegaCli in a chroot to shall we? ;)<br><br />
First we set up a uclibc chroot :)<br><br />
MegaCli needs more than just glibc it needs ncurses and the gcc-libs.<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this we visit this site http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip and download 8.02.16_MegaCLI.zip.<br><br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
Now we got a working MegaCli client in our chroot.<br><br />
Like with srcds we don't want to operate from inside the chroot so here is a little script that should ease you up. (use at your own risk)<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
Save it under /usr/bin/MegaCli .Do a chmod +x /usr/bin/MegaCli and good luck.<br />
Hf<br />
PS<br />
This method takes around 50mb.If you need something smaller you can strip a few files from glibc (not recommended) or work on a squashfs.<br><br />
With<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
you can create a squashfs that is around 15mb small.When you add an unionfs layer you can even use it with write access or you can bind some dirs to the writeable dirs before you chroot into it.<br><br />
I will look into it later on.<br><br />
You can save the chroot in another dir than your home dir and you an even install a chroot through a APKBUILD (after someone wrote it).<br><br />
Through this you could use many glibc dependend programs through one chroot, but be aware that running programs like this should not be standard but only be used in extreme situations like for _closed source_ tools linked against glibc.<br />
<br />
===Skype on Debian chroot===<br />
WIP - Not yet validated<br><br />
This is an example on how to run Skype from a Debian 32b chroot.<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
To fix missings deps you'll want to use:<br />
apt-get -f install<br />
Then exit the chroot<br />
exit<br />
Fix PAX flags on Skype binary - linux-grsec only.<br><br />
ELF marking with paxctl cannot be used cause Skype binary refuses to run if modified<br><br />
CONFIG_PAX_XATTR_PAX_FLAGS is NOT yet available in linux-grsec<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br><br />
Give write access to /dev/v4l and /dev/snd to let Skype use webcam device - Skype is not compatible with Alsa anymore and requires Pulseaudio running.<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
Enter the chroot and create a user<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
Then run skype as your newly created user<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=14249Running glibc programs2017-12-31T20:18:07Z<p>Head on a Stick: /* Archlinux */ improved method.</p>
<hr />
<div>{{Draft}}<br />
<br />
If you want to run glibc programs under alpine there are a few ways to do so.You could install glibc additional to uclibc (you would have to do this manualy) or you could do the easy way and use a chroot.<br><br />
Because there are different usecases I want to give a slight overview about what's possible and what is intelligent.<br><br />
<br />
==Your options==<br />
===Using Busybox===<br />
First the most simple approach for setting up a chroot is using a glibc build of busybox.<br><br />
This approach has just a few downsides:<br><br />
- You have to link most /bin/ and /usr/bin program against /bin/busybox and some busybox builds break if you don't configure it right.<br><br />
- You have to manually download every library you need for your program manually.<br><br><br />
But if you want a small enviroment for one simple use case this is the solution you want.<br />
<br />
===Using a livecd===<br />
If you prefer any special distri you can always download and extract a livecd and use it as a chroot enviroment.<br />
<br />
===Using a stage3 gentoo archive===<br />
This is the fastest approach and you have the advantage of controlling which package version of which library you will install.<br><br />
Drawbacks are as follow:<br><br />
- Big build.You have to install a portage tree which uses up a lot of space.(It's not 100% necessary if you don't have to install any additional content you don't need it)<br><br />
- On slow mashines not recommended because you have to compile your packages.<br><br />
<br />
===Using Archlinux or Debian===<br />
If you want a nice running system you can install Arch or Debian in a chroot.This approach isn't as easily executed as the other alternatives, but are in my opinion the cleanest and most recommended for the every day user.<br />
<br />
==How to do it==<br />
Like I said this is just a quick draft so here it comes.<br />
===Using Busybox===<br />
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment which we will expand through all commands included in busybox.<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
===Using a livecd===<br />
WIP<br />
<br />
===Using a stage3 tar archive===<br />
Select a mirror from http://www.gentoo.org/main/en/mirrors2.xml , switch to /releases/x86/current-stage3/ and download the latest tar ball (for me stage3-i686-20120124.tar.bz2 ).<br />
wget http://de-mirror.org/gentoo/releases/x86/current-stage3/stage3-i686-20120124.tar.bz2<br />
mkdir ~/chroot<br />
tar xfj stage3-i686-*.tar.bz2 -C ~/chroot<br />
sudo chroot ~/chroot<br />
And voila you got your working gentoo chroot.<br><br />
You can now take a look at http://www.gentoo.org/doc/en/?catid=desktop to find out how you can configure and install your system or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
===Using Archlinux or Debian===<br />
====Archlinux====<br />
Although pacstrap is included with the arch-install-scripts package it will not work unless the target directory is a mountpoint so the Arch bootstrap image must be used instead (the image is updated every month so change the date in the link as required):<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Once that is done, update the system and install the desired package(s) (denoted by "foo" in this example):<br />
<br />
[chroot]# pacman -Syu foo<br />
<br />
====Debian====<br />
Use the provided debootstrap package to create the Debian chroot. --arch is optional depending of your needs.<br><br />
On linux-grsec kernel you'll need to relax chroot limitations.<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use apt-get to install needed packages.<br />
<br />
==Example==<br />
===Source Dedicated Server===<br />
Here is an easy example of how you can run http://www.srcds.com in a simple busybox chroot.<br><br />
For this server you will only need the basic chroot and a advanced tar version (the busybox version is not sufficient because of the missing -U command).<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
Now that you are in a working chroot you can download the server and install it.You just have to execute the following self explaining commands.<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy soon to be fixed (no bug in busybox but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
And you should have a working chroot with srcds installed in it.<br><br />
If you think you are clever or elegant you can use the server with a bash script.<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
Just save it (in your alpine installation) under /usr/bin/steam do a chmod +x /usr/bin/steam and have phun.<br><br />
WARNING:<br><br />
This script would let steam run with root priviliges.This is not recommended.<br />
<br />
===MegaCli===<br />
So let's run MegaCli in a chroot to shall we? ;)<br><br />
First we set up a uclibc chroot :)<br><br />
MegaCli needs more than just glibc it needs ncurses and the gcc-libs.<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this we visit this site http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip and download 8.02.16_MegaCLI.zip.<br><br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
Now we got a working MegaCli client in our chroot.<br><br />
Like with srcds we don't want to operate from inside the chroot so here is a little script that should ease you up. (use at your own risk)<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
Save it under /usr/bin/MegaCli .Do a chmod +x /usr/bin/MegaCli and good luck.<br />
Hf<br />
PS<br />
This method takes around 50mb.If you need something smaller you can strip a few files from glibc (not recommended) or work on a squashfs.<br><br />
With<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
you can create a squashfs that is around 15mb small.When you add an unionfs layer you can even use it with write access or you can bind some dirs to the writeable dirs before you chroot into it.<br><br />
I will look into it later on.<br><br />
You can save the chroot in another dir than your home dir and you an even install a chroot through a APKBUILD (after someone wrote it).<br><br />
Through this you could use many glibc dependend programs through one chroot, but be aware that running programs like this should not be standard but only be used in extreme situations like for _closed source_ tools linked against glibc.<br />
<br />
===Skype on Debian chroot===<br />
WIP - Not yet validated<br><br />
This is an example on how to run Skype from a Debian 32b chroot.<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
To fix missings deps you'll want to use:<br />
apt-get -f install<br />
Then exit the chroot<br />
exit<br />
Fix PAX flags on Skype binary - linux-grsec only.<br><br />
ELF marking with paxctl cannot be used cause Skype binary refuses to run if modified<br><br />
CONFIG_PAX_XATTR_PAX_FLAGS is NOT yet available in linux-grsec<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br><br />
Give write access to /dev/v4l and /dev/snd to let Skype use webcam device - Skype is not compatible with Alsa anymore and requires Pulseaudio running.<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
Enter the chroot and create a user<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
Then run skype as your newly created user<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=14248Running glibc programs2017-12-31T20:16:06Z<p>Head on a Stick: /* Using Archlinux or Debian */ typo</p>
<hr />
<div>{{Draft}}<br />
<br />
If you want to run glibc programs under alpine there are a few ways to do so.You could install glibc additional to uclibc (you would have to do this manualy) or you could do the easy way and use a chroot.<br><br />
Because there are different usecases I want to give a slight overview about what's possible and what is intelligent.<br><br />
<br />
==Your options==<br />
===Using Busybox===<br />
First the most simple approach for setting up a chroot is using a glibc build of busybox.<br><br />
This approach has just a few downsides:<br><br />
- You have to link most /bin/ and /usr/bin program against /bin/busybox and some busybox builds break if you don't configure it right.<br><br />
- You have to manually download every library you need for your program manually.<br><br><br />
But if you want a small enviroment for one simple use case this is the solution you want.<br />
<br />
===Using a livecd===<br />
If you prefer any special distri you can always download and extract a livecd and use it as a chroot enviroment.<br />
<br />
===Using a stage3 gentoo archive===<br />
This is the fastest approach and you have the advantage of controlling which package version of which library you will install.<br><br />
Drawbacks are as follow:<br><br />
- Big build.You have to install a portage tree which uses up a lot of space.(It's not 100% necessary if you don't have to install any additional content you don't need it)<br><br />
- On slow mashines not recommended because you have to compile your packages.<br><br />
<br />
===Using Archlinux or Debian===<br />
If you want a nice running system you can install Arch or Debian in a chroot.This approach isn't as easily executed as the other alternatives, but are in my opinion the cleanest and most recommended for the every day user.<br />
<br />
==How to do it==<br />
Like I said this is just a quick draft so here it comes.<br />
===Using Busybox===<br />
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment which we will expand through all commands included in busybox.<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
===Using a livecd===<br />
WIP<br />
<br />
===Using a stage3 tar archive===<br />
Select a mirror from http://www.gentoo.org/main/en/mirrors2.xml , switch to /releases/x86/current-stage3/ and download the latest tar ball (for me stage3-i686-20120124.tar.bz2 ).<br />
wget http://de-mirror.org/gentoo/releases/x86/current-stage3/stage3-i686-20120124.tar.bz2<br />
mkdir ~/chroot<br />
tar xfj stage3-i686-*.tar.bz2 -C ~/chroot<br />
sudo chroot ~/chroot<br />
And voila you got your working gentoo chroot.<br><br />
You can now take a look at http://www.gentoo.org/doc/en/?catid=desktop to find out how you can configure and install your system or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
===Using Archlinux or Debian===<br />
====Archlinux====<br />
Although pacstrap is included with the arch-install-scripts package it will not work unless the target directory is a mountpoint so the Arch bootstrap image must be used instead (the image is updated every month so change the date in the link as required):<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Then run this command from a separate terminal (''ie'', not from the chroot) to un-comment a mirror for pacman:<br />
<br />
sed -i '/evowise/s/^#//' ~/chroot/root.x86_64/etc/pacman.d/mirrorlist<br />
<br />
Once that is done, return to the chroot then update the system and install the desired package(s) (denoted by "foo" in this example):<br />
<br />
[chroot]# pacman -Syu foo<br />
<br />
====Debian====<br />
Use the provided debootstrap package to create the Debian chroot. --arch is optional depending of your needs.<br><br />
On linux-grsec kernel you'll need to relax chroot limitations.<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use apt-get to install needed packages.<br />
<br />
==Example==<br />
===Source Dedicated Server===<br />
Here is an easy example of how you can run http://www.srcds.com in a simple busybox chroot.<br><br />
For this server you will only need the basic chroot and a advanced tar version (the busybox version is not sufficient because of the missing -U command).<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
Now that you are in a working chroot you can download the server and install it.You just have to execute the following self explaining commands.<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy soon to be fixed (no bug in busybox but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
And you should have a working chroot with srcds installed in it.<br><br />
If you think you are clever or elegant you can use the server with a bash script.<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
Just save it (in your alpine installation) under /usr/bin/steam do a chmod +x /usr/bin/steam and have phun.<br><br />
WARNING:<br><br />
This script would let steam run with root priviliges.This is not recommended.<br />
<br />
===MegaCli===<br />
So let's run MegaCli in a chroot to shall we? ;)<br><br />
First we set up a uclibc chroot :)<br><br />
MegaCli needs more than just glibc it needs ncurses and the gcc-libs.<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this we visit this site http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip and download 8.02.16_MegaCLI.zip.<br><br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
Now we got a working MegaCli client in our chroot.<br><br />
Like with srcds we don't want to operate from inside the chroot so here is a little script that should ease you up. (use at your own risk)<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
Save it under /usr/bin/MegaCli .Do a chmod +x /usr/bin/MegaCli and good luck.<br />
Hf<br />
PS<br />
This method takes around 50mb.If you need something smaller you can strip a few files from glibc (not recommended) or work on a squashfs.<br><br />
With<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
you can create a squashfs that is around 15mb small.When you add an unionfs layer you can even use it with write access or you can bind some dirs to the writeable dirs before you chroot into it.<br><br />
I will look into it later on.<br><br />
You can save the chroot in another dir than your home dir and you an even install a chroot through a APKBUILD (after someone wrote it).<br><br />
Through this you could use many glibc dependend programs through one chroot, but be aware that running programs like this should not be standard but only be used in extreme situations like for _closed source_ tools linked against glibc.<br />
<br />
===Skype on Debian chroot===<br />
WIP - Not yet validated<br><br />
This is an example on how to run Skype from a Debian 32b chroot.<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
To fix missings deps you'll want to use:<br />
apt-get -f install<br />
Then exit the chroot<br />
exit<br />
Fix PAX flags on Skype binary - linux-grsec only.<br><br />
ELF marking with paxctl cannot be used cause Skype binary refuses to run if modified<br><br />
CONFIG_PAX_XATTR_PAX_FLAGS is NOT yet available in linux-grsec<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br><br />
Give write access to /dev/v4l and /dev/snd to let Skype use webcam device - Skype is not compatible with Alsa anymore and requires Pulseaudio running.<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
Enter the chroot and create a user<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
Then run skype as your newly created user<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Running_glibc_programs&diff=14247Running glibc programs2017-12-31T20:14:29Z<p>Head on a Stick: /* Archlinux */ filled out "WIP" section, just tried this method myself :</p>
<hr />
<div>{{Draft}}<br />
<br />
If you want to run glibc programs under alpine there are a few ways to do so.You could install glibc additional to uclibc (you would have to do this manualy) or you could do the easy way and use a chroot.<br><br />
Because there are different usecases I want to give a slight overview about what's possible and what is intelligent.<br><br />
<br />
==Your options==<br />
===Using Busybox===<br />
First the most simple approach for setting up a chroot is using a glibc build of busybox.<br><br />
This approach has just a few downsides:<br><br />
- You have to link most /bin/ and /usr/bin program against /bin/busybox and some busybox builds break if you don't configure it right.<br><br />
- You have to manually download every library you need for your program manually.<br><br><br />
But if you want a small enviroment for one simple use case this is the solution you want.<br />
<br />
===Using a livecd===<br />
If you prefer any special distri you can always download and extract a livecd and use it as a chroot enviroment.<br />
<br />
===Using a stage3 gentoo archive===<br />
This is the fastest approach and you have the advantage of controlling which package version of which library you will install.<br><br />
Drawbacks are as follow:<br><br />
- Big build.You have to install a portage tree which uses up a lot of space.(It's not 100% necessary if you don't have to install any additional content you don't need it)<br><br />
- On slow mashines not recommended because you have to compile your packages.<br><br />
<br />
===Using Archlinux or Debian===<br />
If you want a nice running system you can install Arch or Debian in a chroot.This approach isn't as easily executed as the other alternatives, but are in my opinion the cleanest and most recommended for the every day user.<br />
<br />
==How to do it==<br />
Like I said this is just a quick draft so here it comes.<br />
===Using Busybox===<br />
First we need to download busybox.You can choose any of your favourit distros to download a prebuild version.I for instance would use Archlinux packages from http://www.archlinux.org/packages/community/i686/busybox/.<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
<br />
This creates a simple chroot enviroment which we will expand through all commands included in busybox.<br />
for i in $(busybox --list);do ln -s /bin/busybox /usr/bin/$i;done<br />
<br />
===Using a livecd===<br />
WIP<br />
<br />
===Using a stage3 tar archive===<br />
Select a mirror from http://www.gentoo.org/main/en/mirrors2.xml , switch to /releases/x86/current-stage3/ and download the latest tar ball (for me stage3-i686-20120124.tar.bz2 ).<br />
wget http://de-mirror.org/gentoo/releases/x86/current-stage3/stage3-i686-20120124.tar.bz2<br />
mkdir ~/chroot<br />
tar xfj stage3-i686-*.tar.bz2 -C ~/chroot<br />
sudo chroot ~/chroot<br />
And voila you got your working gentoo chroot.<br><br />
You can now take a look at http://www.gentoo.org/doc/en/?catid=desktop to find out how you can configure and install your system or simply extract/copy the program you need to run in your chroot enviroment and execute it.<br />
<br />
===Using Archlinux or Debian===<br />
====Archlinux====<br />
Although pacstrap is included with the arch-install scripts package it will not work unless the target directory is a mountpoint so the Arch bootstrap image must be used instead (the image is updated every month so change the date in the link as required):<br />
<br />
sudo apk add arch-install-scripts<br />
mkdir ~/chroot && cd ~/chroot<br />
curl -O https://mirrors.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
tar xzf archlinux-bootstrap-2018.01.01-x86_64.tar.gz && rm archlinux-bootstrap-2018.01.01-x86_64.tar.gz<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
sudo arch-chroot root.x86_64<br />
[chroot]# pacman-key --init<br />
[chroot]# pacman-key --populate archlinux<br />
<br />
Then run this command from a separate terminal (''ie'', not from the chroot) to un-comment a mirror for pacman:<br />
<br />
sed -i '/evowise/s/^#//' ~/chroot/root.x86_64/etc/pacman.d/mirrorlist<br />
<br />
Once that is done, return to the chroot then update the system and install the desired package(s) (denoted by "foo" in this example):<br />
<br />
[chroot]# pacman -Syu foo<br />
<br />
====Debian====<br />
Use the provided debootstrap package to create the Debian chroot. --arch is optional depending of your needs.<br><br />
On linux-grsec kernel you'll need to relax chroot limitations.<br />
<br />
sudo apk add debootstrap<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done<br />
mkdir ~/chroot<br />
sudo debootstrap --arch=i386 wheezy ~/chroot http://http.debian.net/debian/<br />
for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done<br />
sudo chroot ~/chroot /bin/bash<br />
<br />
You can now use apt-get to install needed packages.<br />
<br />
==Example==<br />
===Source Dedicated Server===<br />
Here is an easy example of how you can run http://www.srcds.com in a simple busybox chroot.<br><br />
For this server you will only need the basic chroot and a advanced tar version (the busybox version is not sufficient because of the missing -U command).<br><br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/tar/download/ -O tar.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc}<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
sudo chroot ~/chroot/ /bin/sh<br />
Now that you are in a working chroot you can download the server and install it.You just have to execute the following self explaining commands.<br />
mkdir ~/work<br />
cd ~/work<br />
busybox wget http://www.steampowered.com/download/hldsupdatetool.bin<br />
chmod +x hldsupdatetool.bin<br />
ln -s /bin/busybox ./uncompress<br />
cp /bin/tar . #right now executing programs from $PATH is buggy soon to be fixed (no bug in busybox but in my script)<br />
./hdsupdatetool.bin #you can accept it or not ;)<br />
./steam<br />
./steam<br />
And you should have a working chroot with srcds installed in it.<br><br />
If you think you are clever or elegant you can use the server with a bash script.<br />
#!/bin/bash<br />
chroot ~/chroot /root/work/steam $@<br />
Just save it (in your alpine installation) under /usr/bin/steam do a chmod +x /usr/bin/steam and have phun.<br><br />
WARNING:<br><br />
This script would let steam run with root priviliges.This is not recommended.<br />
<br />
===MegaCli===<br />
So let's run MegaCli in a chroot to shall we? ;)<br><br />
First we set up a uclibc chroot :)<br><br />
MegaCli needs more than just glibc it needs ncurses and the gcc-libs.<br />
wget http://www.archlinux.org/packages/community/i686/busybox/download/ -O busybox.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/glibc/download/ -O glibc.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/ncurses/download/ -O ncurses.pkg.tar.xz<br />
wget http://www.archlinux.org/packages/core/i686/gcc-libs/download/ -O gcc-libs.pkg.tar.xz<br />
mkdir -p ~/chroot/usr/bin/ ~/chroot/{dev,proc,root,etc,sys}<br />
cp /etc/resolv.conf ~/chroot/etc/<br />
for i in *.pkg.tar.xz;do<br />
bsdtar xfJ $i -C ~/chroot<br />
done<br />
ln -s /bin/busybox ~/chroot/bin/sh<br />
ln -s /bin/busybox ~/chroot/bin/ln<br />
<br />
After this we visit this site http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip and download 8.02.16_MegaCLI.zip.<br><br />
mkdir tmp<br />
cd tmp<br />
unzip ../8.02.16_MegaCLI.zip<br />
cd LINUX<br />
unzip MegaCliLin.zip<br />
#Now comes code stolen from rpm2cpio<br />
o=`expr 96 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
sigsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`<br />
set `od -j $o -N 8 -t u1 MegaCli-8.02.16-1.i386.rpm`<br />
il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`<br />
dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`<br />
hdrsize=`expr 8 + 16 \* $il + $dl`<br />
o=`expr $o + $hdrsize`<br />
dd if=MegaCli-8.02.16-1.i386.rpm ibs=$o skip=1 2>/dev/null |bsdtar -xf -<br />
#wow ...<br />
rm opt/MegaRAID/MegaCli/MegaCli64 # who needs 64bit?<br />
cp -r opt/ ~/chroot/<br />
Now we got a working MegaCli client in our chroot.<br><br />
Like with srcds we don't want to operate from inside the chroot so here is a little script that should ease you up. (use at your own risk)<br />
<br />
#!/bin/bash<br />
user=$(whoami)<br />
if [ "$user" != "root" ];then<br />
echo "This script needs root access"<br />
exit<br />
fi<br />
mount -t proc proc ~/chroot/proc/<br />
mount --bind /dev/ ~/chroot/dev/<br />
mount --bind /sys/ ~/chroot/sys/<br />
#we may need dev and maybe proc too to use this program<br />
chroot ~/chroot /opt/MegaRAID/MegaCli/MegaCli $@<br />
umount ~/chroot/proc<br />
umount ~/chroot/dev<br />
umount ~/chroot/sys<br />
Save it under /usr/bin/MegaCli .Do a chmod +x /usr/bin/MegaCli and good luck.<br />
Hf<br />
PS<br />
This method takes around 50mb.If you need something smaller you can strip a few files from glibc (not recommended) or work on a squashfs.<br><br />
With<br />
mksquashfs ~/chroot/ /chroot.sfs -b 65536<br />
you can create a squashfs that is around 15mb small.When you add an unionfs layer you can even use it with write access or you can bind some dirs to the writeable dirs before you chroot into it.<br><br />
I will look into it later on.<br><br />
You can save the chroot in another dir than your home dir and you an even install a chroot through a APKBUILD (after someone wrote it).<br><br />
Through this you could use many glibc dependend programs through one chroot, but be aware that running programs like this should not be standard but only be used in extreme situations like for _closed source_ tools linked against glibc.<br />
<br />
===Skype on Debian chroot===<br />
WIP - Not yet validated<br><br />
This is an example on how to run Skype from a Debian 32b chroot.<br />
sudo chroot ~/chroot<br />
wget http://www.skype.com/go/getskype-linux-deb<br />
dpkg -i getskype-linux-deb<br />
To fix missings deps you'll want to use:<br />
apt-get -f install<br />
Then exit the chroot<br />
exit<br />
Fix PAX flags on Skype binary - linux-grsec only.<br><br />
ELF marking with paxctl cannot be used cause Skype binary refuses to run if modified<br><br />
CONFIG_PAX_XATTR_PAX_FLAGS is NOT yet available in linux-grsec<br />
sudo apk add attr<br />
sudo setfattr -n user.pax.flags -v "em" ~/chroot/usr/bin/skype<br />
Mount needed directories in the chroot read-only to limit access to the system devices.<br><br />
Give write access to /dev/v4l and /dev/snd to let Skype use webcam device - Skype is not compatible with Alsa anymore and requires Pulseaudio running.<br />
sudo mount -o bind /proc ~/chroot/proc<br />
sudo mount -o bind,ro,remount /proc ~/chroot/proc<br />
sudo mount -o bind /sys ~/chroot/sys<br />
sudo mount -o bind,ro,remount /sys ~/chroot/sys<br />
sudo mount -o bind /dev ~/chroot/dev<br />
sudo mount -o bind,ro,remount /dev ~/chroot/dev<br />
sudo mount -o bind /dev/v4l ~/chroot/dev/v4l<br />
sudo mount -t tmpfs -o nodev,nosuid,noexec shm $CHROOT_PATH/dev/shm<br />
Enter the chroot and create a user<br />
sudo chroot ~/chroot<br />
useradd -G audio,video <username><br />
exit<br />
Then run skype as your newly created user<br />
sudo chroot ~/chroot /bin/su - <username> -c /usr/bin/skype<br />
<br />
[[Category:Development]]<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Raspberry_Pi&diff=14112Raspberry Pi2017-11-03T06:59:14Z<p>Head on a Stick: /* Traditional disk-based (sys) installation */</p>
<hr />
<div>[[Category:Installation]]<br />
This tutorial will help you install Alpine Linux on your Raspberry Pi.<br />
<br />
== Preparation ==<br />
<br />
This section will help you format and partition your SD card:<br />
<br />
# [http://alpinelinux.org/downloads/ Download] Alpine for Raspberry Pi tarball which is named as <code>alpine-rpi-<version>-armhf.rpi.tar.gz</code>. You will need version 3.2.0 or greater if you have a Raspberry Pi 2.<br />
# Mount your SD card to your workstation<br />
# Use [https://en.wikipedia.org/wiki/GNOME_Disks gnome-disks] or [http://linux.die.net/man/8/fdisk fdisk] to create a FAT32 partition. If you are using fdisk, the FAT32 partition type is called ''W95 FAT32 (LBA)'' and its ID is 0xC.<br />
# Mark the newly created partition as bootable and save<br />
# Mount the previously created partition<br />
# Extract the tarball contents to your FAT32 partition<br />
# Unmount the SD Card.<br />
{{note| Due to a bug (#7024), you might want to add a "usercfg.txt" file (which is included by config.txt) with <code>enable_uart&#61;1</code> written in it. Otherwise, the error message "Can't open /dev/ttyS0" will repeatedly be written to the console.}}<br />
<br />
== Installation ==<br />
<br />
Alpine Linux will be installed as [[Installation#Installation_Handbook|diskless mode]], hence you need to use [[Alpine local backup|Alpine Local Backup (lbu)]] to save your modifications between reboots. Follow these steps to install Alpine Linux:<br />
<br />
# Insert the SD Card into the Raspberry Pi and turn it on<br />
# Login into the Alpine system as root. Leave the password empty.<br />
# Type <code>setup-alpine</code><br />
# Once the installation is complete, commit the changes by typing <code>lbu commit -d</code><br />
<br />
Type <code>reboot</code> to verify that the installation was indeed successful.<br />
<br />
== Post Installation ==<br />
<br />
=== Update the System ===<br />
<br />
Upon installation, make sure that your system is up-to-date:<br />
<br />
{{cmd|apk update<br />
apk upgrade}}<br />
<br />
Don't forget to save the changes:<br />
<br />
{{cmd|lbu commit -d}}<br />
<br />
=== Clock-related error messages ===<br />
<br />
During the booting time, you might notice errors related to the hardware clock. The Raspberry Pi does not have<br />
a hardware clock and therefore you need to disable the hwclock daemon and enable swclock:<br />
<br />
{{cmd|rc-update add swclock boot # enable the software clock<br />
rc-update del hwclock boot # disable the hardware clock}}<br />
<br />
Since Raspberry Pi does not have a clock, the Alpine Linux needs to know what the time is by using a<br />
[https://en.wikipedia.org/wiki/Network_Time_Protocol Network Time Protocol (NTP)] daemon. Make sure that you a<br />
NTP daemon installed and running. If you are not sure, then you can install NTP client by running the following<br />
command:<br />
<br />
{{cmd|setup-ntp}}<br />
<br />
Busybox NTP client might be the most lightweight solution. Save the changes and reboot, once the NTP software is<br />
installed and running:<br />
<br />
{{cmd|lbu commit -d<br />
reboot}}<br />
<br />
After reboot, make sure that the <code>date</code> command outputs the correct date and time.<br />
<br />
=== X11 Setup ===<br />
Here are what you need if you want to try and run a single X11 application like a browser kiosk or maybe even a desktop: {{cmd|setup-xorg-base <br />
apk add xf86-video-fbdev xf86-input-mouse xf86-input-keyboard dbus setxkbmap<br />
rc-update add dbus}}<br />
<br />
Also edit the default X11 module config: /etc/X11/xorg.conf.d/20-modules.conf<br />
{{cmd|Section "Module"<br />
Load "fbdevhw"<br />
Load "fb"<br />
Load "shadow"<br />
Load "shadowfb"<br />
Load "dbe"<br />
Load "glx"<br />
Disable "dri"<br />
EndSection}}<br />
<br />
Commit your changes:<br />
{{cmd|lbu_commit -d}}<br />
<br />
Now you should be able to run a browser or desktop. (Guides may follow)<br />
<br />
If setup-xorg-base gives you an error regarding rc-update that fails to add mdev to sysinit just run:<br />
{{cmd|rc-update mdev sysinit}}<br />
to add it manually. If you skip this the next time you reboot your Raspberry Pi the screen maybe will not display anything on screen.<br />
<br />
== Persistent storage ==<br />
<br />
=== Loopback image with overlayfs ===<br />
<br />
The install is in disk-less mode and forces everything into memory, if you want additional storage we need to create loop-back storage onto the SD mounted with overlayfs.<br />
<br />
First make the sd-card writable again and change fstab to always do so:<br />
{{cmd|mount /media/mmcblk0p1 -o rw,remount<br />
sed -i 's/vfat\ ro,/vfat\ rw,' /etc/fstab}}<br />
<br />
Create the loop-back file, this example is 1 GB:<br />
<br />
{{cmd|dd if&#61;/dev/zero of&#61;/media/mmcblk0p1/persist.img bs&#61;1024 count&#61;0 seek&#61;1048576}}<br />
<br />
Install the ext utilities:<br />
<br />
{{cmd|apk add e2fsprogs}}<br />
<br />
Format the loop-back file:<br />
<br />
{{cmd|mkfs.ext4 /media/mmcblk0p1/persist.img}}<br />
<br />
Mount the storage: <br />
<br />
{{cmd|echo "/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0" >> /etc/fstab<br />
mkdir /media/persist <br />
mount -a}}<br />
<br />
Make the overlay folders, we are doing /usr here, but you can do /home or anything else:<br />
<br />
{{cmd|mkdir /media/persist/usr <br />
mkdir /media/persist/.work <br />
echo "overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0" >> /etc/fstab <br />
mount -a}}<br />
<br />
Your /etc/fstab should look something like this:<br />
{{Cmd|/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0<br />
/dev/usbdisk /media/usb vfat noauto,ro 0 0<br />
/dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask&#61;0022,dmask&#61;0022,errors&#61;remount-ro 0 0<br />
/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0<br />
overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0}}<br />
<br />
Now commit the changes: (optionally remove the e2fsprogs, but it does contain repair tools)<br />
{{cmd|lbu_commit -d}}<br />
<br />
Remember with this setup, if you install things and you have done this overlay for /usr, you must not commit the 'apk add', otherwise while it boots it will try and install it to memory and not to the persist storage.<br />
<br />
If you do want to install something small at boot you can use `apk add` and `lbu commit -d`.<br />
<br />
If it is something a bit bigger then you can use `apk add` but then not commit it, it will be persistent (in /user), but do check everything you need is in that directory and not in folders you have not made persistent.<br />
<br />
=== Traditional disk-based (sys) installation ===<br />
<br />
{{Warning|This isn't yet supported by the Alpine setup scripts for Raspberry Pi. It requires manual intervention, and might break.}}<br />
<br />
It is also possible to switch to a fully disk-based installation: this is not yet formally supported, but can be done somewhat manually. This frees all the memory otherwise needed for the root filesystem, allowing more installed packages.<br />
<br />
Split your SD card into two partitions: the FAT32 boot partition described above (in this example it'll be <code>mmcblk0p1</code>) , and a second partition to hold the root filesystem (here it'll be <code>mmcblk0p2</code>). Boot and configure your diskless system as above, then create a root filesystem:<br />
<br />
{{cmd|apk add e2fsprogs<br />
mkfs.ext4 /dev/mmcblk0p2}}<br />
<br />
Now do a disk install via a mountpoint. The <code>setup-disk</code> script will give some errors about syslinux/extlinux, but you can ignore these: the Raspberry Pi doesn't need this to boot anyway.<br />
<br />
{{cmd|<nowiki>mkdir /stage<br />
mount /dev/mmcblk0p2 /stage<br />
setup-disk -o /media/mmcblk0p1/MYHOSTNAME.apkovl.tar.gz /stage<br />
# (ignore errors about syslinux/extlinux)</nowiki>}}<br />
<br />
Add a line to <code>/stage/etc/fstab</code> to mount the Pi's boot partition again:<br />
<br />
{{cmd|/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0}}<br />
<br />
Now add a <code>root=/dev/mmcblk0p2</code> parameter to the Pi's boot command line, either <code>cmdline-rpi2.txt</code> or <code>cmdline-rpi.txt</code> depending on model:<br />
<br />
{{cmd|<nowiki>mount -o remount,rw /media/mmcblk0p1<br />
sed -i '$ s/$/ root=\/dev\/mmcblk0p2/' /media/mmcblk0p1/cmdline-rpi2.txt</nowiki>}}<br />
<br />
You might also consider <code>overlaytmpfs=yes</code> here, which will cause the underlying SD card root filesystem to be mounted read-only, with an overlayed tmpfs for modifications which will be discarded on shutdown.<br />
<br />
Beware, though, that <b>the contents of /boot will be ignored when the Pi boots</b>: it will use the kernel, initramfs, and modloop images from the FAT32 boot partition. To update the kernel, initfs or modules, you will need to manually (generate and) copy these to the boot partition or you could use bind mount so that manually copy the files to boot partition is not needed.<br />
<br />
{{cmd|<nowiki>echo /media/mmcblk0p1/boot /boot none defaults,bind 0 0 > /etc/fstab</nowiki>}}<br />
<br />
=== Persistent Installation on RPi3 ===<br />
<br />
See https://forum.alpinelinux.org/comment/1084#comment-1084<br />
<br />
== See Also ==<br />
<br />
* [[Create a bootable SDHC from a Mac]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Kernel_Modesetting&diff=14062Kernel Modesetting2017-10-08T20:34:49Z<p>Head on a Stick: Added Radeon video section :)</p>
<hr />
<div>{{Expand|Needs nVidia driver information}}<br />
<br />
; Intel<br />
: See [[Intel_Video#Kernel_Modesetting_(KMS)]]<br />
; Radeon<br />
: See [[Radeon_Video#Kernel_Modesetting_(KMS)]]<br />
; nVidia<br />
: {{Todo|Find out how KMS works with nVidia drivers}}<br />
<br />
[[Category:Kernel]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=User:Head_on_a_Stick/Radeon_Video&diff=14061User:Head on a Stick/Radeon Video2017-10-08T20:33:01Z<p>Head on a Stick: Head on a Stick moved page User:Head on a Stick/Radeon Video to Radeon Video: New addition.</p>
<hr />
<div>#REDIRECT [[Radeon Video]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Radeon_Video&diff=14060Radeon Video2017-10-08T20:33:01Z<p>Head on a Stick: Head on a Stick moved page User:Head on a Stick/Radeon Video to Radeon Video: New addition.</p>
<hr />
<div>The following instructions are for modern AMD GPU chipsets covered by the radeon driver.<br />
<br />
== Setup Xorg/udev ==<br />
<br />
# Run the [[Alpine setup scripts#setup-xorg-base|setup-xorg-base]] script.<br />
# Install the Xorg AMD video drivers: {{Cmd|# apk add xf86-video-ati}}<br />
# For newer devices, use: {{Cmd|# apk add xf86-video-amdgpu}}<br />
# Enable [[#Kernel Modesetting (KMS)]]. Specifically, the <code>fbcon</code> module is necessary, or leaving Xorg (via <code>Ctrl+Alt+F1</code> or quitting) will result in a black screen until the machine is power cycled. If you have already launch Xorg and don't want to experience this effect, you can <code>modprobe fbcon</code> while Xorg is running.<br />
<br />
== Kernel Modesetting (KMS) ==<br />
<br />
To enable KMS at boot:<br />
# Add the <code>radeon</code> and <code>fbcon</code> modules to {{Path|/etc/modules}}: {{Cmd|$ echo radeon >> /etc/modules<br />$ echo fbcon >> /etc/modules}}<br />
# Install <code>mkinitfs</code>: {{Cmd|apk add mkinitfs}}<br />
# Enable the <code>kms</code> feature in the <code>mkinitfs</code> configuration by adding it to the <var>features</var> variable, e.g., {{cat|/etc/mkinitfs/mkinitfs.conf|features{{=}}"keymap cryptsetup kms ata base ide scsi usb virtio ext4"}}<br />
# Run <code>mkinitfs</code>.<br />
# Reboot to test the configuration.<br />
<br />
== Fixing MESA-LOADER errors ==<br />
<br />
The ''linux-hardened'' kernel package places restrictions on sysfs and will prevent the MESA-LOADER from working as a normal user even if added to the video group.<br />
<br />
See https://bugs.alpinelinux.org/issues/7265<br />
<br />
Either switch to the ''linux-vanilla'' package or apply the '''grsec_sysfs_restrict=0''' kernel parameter to allow normal users to access hardware acceleration on the desktop.<br />
<br />
<br />
[[Category:Drivers]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Radeon_Video&diff=14059Radeon Video2017-10-08T20:30:14Z<p>Head on a Stick: Created page with "The following instructions are for modern AMD GPU chipsets covered by the radeon driver. == Setup Xorg/udev == # Run the Alpine setup scripts#setup-xorg-base|setup-xorg-ba..."</p>
<hr />
<div>The following instructions are for modern AMD GPU chipsets covered by the radeon driver.<br />
<br />
== Setup Xorg/udev ==<br />
<br />
# Run the [[Alpine setup scripts#setup-xorg-base|setup-xorg-base]] script.<br />
# Install the Xorg AMD video drivers: {{Cmd|# apk add xf86-video-ati}}<br />
# For newer devices, use: {{Cmd|# apk add xf86-video-amdgpu}}<br />
# Enable [[#Kernel Modesetting (KMS)]]. Specifically, the <code>fbcon</code> module is necessary, or leaving Xorg (via <code>Ctrl+Alt+F1</code> or quitting) will result in a black screen until the machine is power cycled. If you have already launch Xorg and don't want to experience this effect, you can <code>modprobe fbcon</code> while Xorg is running.<br />
<br />
== Kernel Modesetting (KMS) ==<br />
<br />
To enable KMS at boot:<br />
# Add the <code>radeon</code> and <code>fbcon</code> modules to {{Path|/etc/modules}}: {{Cmd|$ echo radeon >> /etc/modules<br />$ echo fbcon >> /etc/modules}}<br />
# Install <code>mkinitfs</code>: {{Cmd|apk add mkinitfs}}<br />
# Enable the <code>kms</code> feature in the <code>mkinitfs</code> configuration by adding it to the <var>features</var> variable, e.g., {{cat|/etc/mkinitfs/mkinitfs.conf|features{{=}}"keymap cryptsetup kms ata base ide scsi usb virtio ext4"}}<br />
# Run <code>mkinitfs</code>.<br />
# Reboot to test the configuration.<br />
<br />
== Fixing MESA-LOADER errors ==<br />
<br />
The ''linux-hardened'' kernel package places restrictions on sysfs and will prevent the MESA-LOADER from working as a normal user even if added to the video group.<br />
<br />
See https://bugs.alpinelinux.org/issues/7265<br />
<br />
Either switch to the ''linux-vanilla'' package or apply the '''grsec_sysfs_restrict=0''' kernel parameter to allow normal users to access hardware acceleration on the desktop.<br />
<br />
<br />
[[Category:Drivers]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=User:Head_on_a_Stick&diff=14058User:Head on a Stick2017-10-08T20:18:38Z<p>Head on a Stick: Created page with "Hello!"</p>
<hr />
<div>Hello!</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=How_to_get_regular_stuff_working&diff=13952How to get regular stuff working2017-09-24T00:17:59Z<p>Head on a Stick: /* Shell @ commandline */ added shadow package installation instructions.</p>
<hr />
<div>== Man pages ==<br />
<br />
Not all man-pages are in Alpine, but this will get you most of the way there:<br />
<br />
'''apk add man man-pages mdocml-apropos less less-doc'''<br />
'''export PAGER=less'''<br />
<br />
The above only provides ''core'' man pages. Other packages typically don't include their own man pages (nor other documentation). Rather, they provide an associated package that carries such stuff. For example:<br />
<br />
$ '''apk add curl'''<br />
$ '''man curl'''<br />
man: No entry for curl in the manual.<br />
$ '''apropos curl | wc -l'''<br />
0 <span style="color: green;">''After adding curl, there are no man pages''</span><br />
$ '''apk add curl-doc'''<br />
(1/1) Installing curl-doc (7.52.1-r2)<br />
Executing mdocml-apropos-1.13.3-r6.trigger<br />
OK: 60 MiB in 31 packages<br />
$ '''apropos curl | wc -l'''<br />
366 <span style="color: green;">''Now, with curl-doc installed, there's a boatload of pages!''</span><br />
<br />
'''NOTE:''' Not all packages separate out their documentation, but it is the ''Alpine Way'' (e.g. small footprint). Some packages don't provide any installable documentation at all, neither within themselves nor an associated doc packages. Further, appending "-doc" is merely a convention. In fact, the core man documentations are in man-pages (as in the ''apk add ...'' command, above). To find the right documentation package, try something like:<br />
<br />
$ '''apk search gcc | grep ^gcc'''<br />
gcc-objc-5.3.0-r0<br />
gcc-gnat-5.3.0-r0<br />
gcc-5.3.0-r0<br />
gcc-java-5.3.0-r0<br />
gcc-doc-5.3.0-r0 <span style="color: green;">''Here it is!''</span><br />
<br />
'''FINALLY:''' If you're wondering why I've added ''less'' (and ''less-doc''), it's because ''man'' doesn't work correctly with ''more'' (the default pager). Don't fret too much about bloating up Alpine, though - adding man pages has a bigger footprint than less (''"less is more than man"???'')<br />
<br />
== Operational hints ==<br />
<br />
==== Shell @ commandline ====<br />
<br />
Alpine comes with busybox by default. Busybox is an endpoint for numerous symlinks for various utilities. Though busybox is not that bad, the commands are impaired in functionality.<br />
<br />
* Funny characters at the console<br />
Edit the file at {{Path|/etc/rc.conf}} and change line 92 to:<br />
unicode="YES"<br />
<br />
* Bash<br />
It is easy enough to have bash installed, but this does not mean the symlinks to busybox are gone.<br />
<br />
Install bash with: <br />
apk add bash bash-doc bash-completion<br />
<br />
* Shell utilities (things like grep, [[awk]], ls are all busybox symlinks)<br />
apk add util-linux pciutils usbutils coreutils binutils findutils grep<br />
<br />
* /etc/{shadow,group} manipulation requires<br />
apk add shadow<br />
<br />
==== Disk Management ==== <br />
<br />
Disk management is soo much easier with udisks or udisks2<br />
<br />
Installation <br />
<br />
apk add udisks2 udisks2-doc<br />
<br />
See the mounted disks<br />
<br />
udisksctl status<br />
<br />
== Compiling : a few notes and a reminder ==<br />
<br />
Compiling in Alpine may be more challenging because it uses [http://www.musl-libc.org/ musl-libc] instead of glibc. Please review [http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc 'The functional differences with glibc' ] if you think of porting packages or just for the sake of knowing, of course.<br />
<br />
Alpine offers the regular compiler stuff like gcc and cmake ... possible others<br />
<br />
==== (unvalidated) apk packages to install so one can start building software ====<br />
apk add build-base gcc abuild binutils binutils-doc gcc-doc<br />
<br />
==== a complete install for cmake looks like ====<br />
<br />
apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc<br />
<br />
==== ccache is also available ====<br />
<br />
apk add ccache ccache-doc<br />
<br />
[[Category:Installation]]</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=Intel_Video&diff=13806Intel Video2017-09-16T16:31:50Z<p>Head on a Stick: Added MESA-LOADER section</p>
<hr />
<div>The following instructions are for modern Intel GPU chipsets covered by the i915 driver.<br />
See [[#Known working configurations]].<br />
<br />
== Setup Xorg/udev ==<br />
<br />
# Run the [[Alpine setup scripts#setup-xorg-base|setup-xorg-base]] script.<br />
# Install the Xorg Intel video drivers: {{Cmd|apk add xf86-video-intel}}<br />
# Enable [[#Kernel Modesetting (KMS)]]. Specifically, the <code>fbcon</code> module is necessary, or leaving Xorg (via <code>Ctrl+Alt+F1</code> or quitting) will result in a black screen until the machine is power cycled. If you have already launch Xorg and don't want to experience this effect, you can <code>modprobe fbcon</code> while Xorg is running.<br />
<br />
<br />
== Kernel Modesetting (KMS) ==<br />
<br />
To enable KMS at boot:<br />
# Add the <code>i915</code> and <code>fbcon</code> modules to {{Path|/etc/modules}}: {{Cmd|$ echo i915 >> /etc/modules<br />$ echo fbcon >> /etc/modules}}<br />
# Install <code>mkinitfs</code>: {{Cmd|apk add mkinitfs}}<br />
# Enable the <code>kms</code> feature in the <code>mkinitfs</code> configuration by adding it to the <var>features</var> variable, e.g., {{cat|/etc/mkinitfs/mkinitfs.conf|features{{=}}"keymap cryptsetup kms ata base ide scsi usb virtio ext4"}}<br />
# Run <code>mkinitfs</code>.<br />
# Reboot to test the configuration.<br />
<br />
<br />
== Fixing MESA-LOADER errors ==<br />
<br />
The ''linux-hardened'' kernel package places restrictions on sysfs and will prevent the MESA-LOADER from working as a normal user even if added to the video group.<br />
<br />
See https://bugs.alpinelinux.org/issues/7265<br />
<br />
Either switch to the ''linux-vanilla'' package or apply the '''grsec_sysfs_restrict=0''' kernel parameter to allow normal users to access hardware acceleration on the desktop.<br />
<br />
<br />
== Known working configurations ==<br />
<br />
; Lenovo X1 Carbon (1st gen), <code>sys</code> installation<br />
<pre style="white-space: pre-wrap; word-wrap: break-word;"># lspci -s 02 -v<br />
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) (prog-if 00 [VGA controller])<br />
Subsystem: Lenovo Device 21f9<br />
Flags: bus master, fast devsel, latency 0, IRQ 28<br />
Memory at f0000000 (64-bit, non-prefetchable) [size=4M]<br />
Memory at e0000000 (64-bit, prefetchable) [size=256M]<br />
I/O ports at 4000 [size=64]<br />
Expansion ROM at <unassigned> [disabled]<br />
Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-<br />
Capabilities: [d0] Power Management version 2<br />
Capabilities: [a4] PCI Advanced Features<br />
Kernel driver in use: i915<br />
</pre></div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=How_to_get_regular_stuff_working&diff=12733How to get regular stuff working2016-05-02T00:38:28Z<p>Head on a Stick: /* Man pages */ there is no "mdocml-pages" package ~~~~</p>
<hr />
<div>== Man pages ==<br />
<br />
Not all man-pages are in Alpine, those who are are not readily available after installing man and man-pages. Below is the quick and easy commandline:<br />
<br />
apk add man man-pages<br />
<br />
== Operational hints ==<br />
<br />
==== Shell @ commandline ====<br />
<br />
Alpine comes with busybox by default, busybox is and endpoint for numerous symlinks for various utilities. Though busybox is not that bad the commands are impaired in functionality.<br />
<br />
* funny characters at the console<br />
<br />
Edit the file at {{Path|/etc/rc.conf}} and change line 92 to:<br />
unicode="YES"<br />
<br />
* Bash<br />
It is easy enough to have bash installed but this does not mean the symlinks to busybox are gone<br />
<br />
install bash like <br />
apk add bash bash-doc bash-completion<br />
<br />
<br />
* shell utils ( things like grep, awk, ls are all busybox symlinks )<br />
<br />
apk add util-linux pciutils usbutils coreutils binutils findutils grep<br />
<br />
==== Disk Management ==== <br />
<br />
Disk management is soo much easier with udisks or udisks2<br />
<br />
Installation <br />
<br />
apk add udisks2 udisks2-doc<br />
<br />
See the mounted disks<br />
<br />
udisksctl status<br />
<br />
== Compiling : a few notes and a reminder ==<br />
<br />
Compiling in Alpine may be more challenging because it uses [http://www.musl-libc.org/ musl-libc] instead of glibc. Please review [http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc 'The functional differences with glibc' ] if you think of porting packages or just for the sake of knowing, of course.<br />
<br />
Alpine offers the regular compiler stuff like gcc and cmake ... possible others<br />
<br />
==== (unvalidated) apk packages to install so one can start building software ====<br />
apk add build-base gcc abuild binutils binutils-doc gcc-doc<br />
<br />
==== a complete install for cmake looks like ====<br />
<br />
apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc<br />
<br />
==== ccache is also available ====<br />
<br />
apk add ccache ccache-doc</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=How_to_get_regular_stuff_working&diff=12732How to get regular stuff working2016-05-02T00:37:53Z<p>Head on a Stick: /* Man pages */ there is no "mdocml-pages" package ~~~~</p>
<hr />
<div>== Man pages ==<br />
<br />
Not all man-pages are in Alpine, those who are are not readily available after installing man and man-pages, <br />
you also need to install mdocml-pages to have man pages built at install time. Below is the quick and easy commandline:<br />
<br />
apk add man man-pages<br />
<br />
== Operational hints ==<br />
<br />
==== Shell @ commandline ====<br />
<br />
Alpine comes with busybox by default, busybox is and endpoint for numerous symlinks for various utilities. Though busybox is not that bad the commands are impaired in functionality.<br />
<br />
* funny characters at the console<br />
<br />
Edit the file at {{Path|/etc/rc.conf}} and change line 92 to:<br />
unicode="YES"<br />
<br />
* Bash<br />
It is easy enough to have bash installed but this does not mean the symlinks to busybox are gone<br />
<br />
install bash like <br />
apk add bash bash-doc bash-completion<br />
<br />
<br />
* shell utils ( things like grep, awk, ls are all busybox symlinks )<br />
<br />
apk add util-linux pciutils usbutils coreutils binutils findutils grep<br />
<br />
==== Disk Management ==== <br />
<br />
Disk management is soo much easier with udisks or udisks2<br />
<br />
Installation <br />
<br />
apk add udisks2 udisks2-doc<br />
<br />
See the mounted disks<br />
<br />
udisksctl status<br />
<br />
== Compiling : a few notes and a reminder ==<br />
<br />
Compiling in Alpine may be more challenging because it uses [http://www.musl-libc.org/ musl-libc] instead of glibc. Please review [http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc 'The functional differences with glibc' ] if you think of porting packages or just for the sake of knowing, of course.<br />
<br />
Alpine offers the regular compiler stuff like gcc and cmake ... possible others<br />
<br />
==== (unvalidated) apk packages to install so one can start building software ====<br />
apk add build-base gcc abuild binutils binutils-doc gcc-doc<br />
<br />
==== a complete install for cmake looks like ====<br />
<br />
apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc<br />
<br />
==== ccache is also available ====<br />
<br />
apk add ccache ccache-doc</div>Head on a Stickhttps://wiki.alpinelinux.org/w/index.php?title=How_to_get_regular_stuff_working&diff=12731How to get regular stuff working2016-05-02T00:36:24Z<p>Head on a Stick: /* Shell @ commandline */ hopefully fixed the funny characters issue and added utils packages ~~~~</p>
<hr />
<div>== Man pages ==<br />
<br />
Not all man-pages are in Alpine, those who are are not readily available after installing man and man-pages, <br />
you also need to install mdocml-pages to have man pages built at install time. Below is the quick and easy commandline:<br />
<br />
apk add man man-pages mdocml-pages<br />
<br />
== Operational hints ==<br />
<br />
==== Shell @ commandline ====<br />
<br />
Alpine comes with busybox by default, busybox is and endpoint for numerous symlinks for various utilities. Though busybox is not that bad the commands are impaired in functionality.<br />
<br />
* funny characters at the console<br />
<br />
Edit the file at {{Path|/etc/rc.conf}} and change line 92 to:<br />
unicode="YES"<br />
<br />
* Bash<br />
It is easy enough to have bash installed but this does not mean the symlinks to busybox are gone<br />
<br />
install bash like <br />
apk add bash bash-doc bash-completion<br />
<br />
<br />
* shell utils ( things like grep, awk, ls are all busybox symlinks )<br />
<br />
apk add util-linux pciutils usbutils coreutils binutils findutils grep<br />
<br />
==== Disk Management ==== <br />
<br />
Disk management is soo much easier with udisks or udisks2<br />
<br />
Installation <br />
<br />
apk add udisks2 udisks2-doc<br />
<br />
See the mounted disks<br />
<br />
udisksctl status<br />
<br />
== Compiling : a few notes and a reminder ==<br />
<br />
Compiling in Alpine may be more challenging because it uses [http://www.musl-libc.org/ musl-libc] instead of glibc. Please review [http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc 'The functional differences with glibc' ] if you think of porting packages or just for the sake of knowing, of course.<br />
<br />
Alpine offers the regular compiler stuff like gcc and cmake ... possible others<br />
<br />
==== (unvalidated) apk packages to install so one can start building software ====<br />
apk add build-base gcc abuild binutils binutils-doc gcc-doc<br />
<br />
==== a complete install for cmake looks like ====<br />
<br />
apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc<br />
<br />
==== ccache is also available ====<br />
<br />
apk add ccache ccache-doc</div>Head on a Stick