Skip to content

Instantly share code, notes, and snippets.

@obfusk obfusk/shell
Last active Sep 7, 2016

Embed
What would you like to do?
debian chroot on android (asus tf300t w/ cyanogenmod 10)
#!/system/xbin/bash
CHROOT=/data/__felix__/__chroot__
if [ -z "$1" -o "$1" == root ]; then
CMD='/bin/bash -l'
else
CMD="/bin/su - $1"
fi
if [ ! -d "$CHROOT"/mnt/etc ]; then
mount -o loop -t ext4 "$CHROOT"/{img,mnt}
mount -t proc proc "$CHROOT"/mnt/proc
mount -t sysfs sysfs "$CHROOT"/mnt/sys
mount -t devpts devpts "$CHROOT"/mnt/dev/pts
fi
chroot "$CHROOT"/mnt /usr/bin/env -i \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
USER=root HOME=/root TERM=linux $CMD
# --
mkdir -p __chroot__/mnt
dd if=/dev/zero of=__chroot__/img bs=8K count=1048576 # 8GiB
sudo mkfs.ext4 -v __chroot__/img
sudo mount -o loop __chroot__/{img,mnt}
sudo debootstrap --arch=armhf --variant=minbase --foreign \
--verbose sid __chroot__/mnt http://ftp.nl.debian.org/debian
sudo umount __chroot__/mnt
wget -O __chroot__/shell \
https://gist.github.com/obfusk/4980445/raw/6a5f645041c2ed8dd05cc9d1a690ee0d89354221/shell
chmod 700 __chroot__/shell
# ... copy __chroot__/ to android, continue with stage2 ...
su
# mount -o ro -t ext4 /dev/block/sda1 /storage/usbdisk0
# mkdir /data/__felix__
# cp -av /storage/usbdisk0/felix/__chroot__/ \
# /data/__felix__/__chroot__/
# umount /storage/usbdisk0
# chown -R root:root /data/__felix__
# chmod 600 /data/__felix__/__chroot__/img
# mount -o loop -t ext4 /data/__felix__/__chroot__/{img,mnt}
# chroot /data/__felix__/__chroot__/mnt /usr/bin/env -i \
# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
# USER=root HOME=/root TERM=linux /bin/bash -l
/data/__felix__/__chroot__/shell # instead of the above 2 commands
/debootstrap/debootstrap --second-stage
# ... continue w/ stage3 ...
cat > /etc/apt/sources.list <<END
deb http://ftp.nl.debian.org/debian/ sid main
deb-src http://ftp.nl.debian.org/debian/ sid main
END
cat > /etc/resolv.conf <<END
nameserver 8.8.8.8
END
echo locahost > /etc/hostname
ln -s /proc/mounts /etc/mtab
apt-get update
apt-get install aptitude
aptitude install ~p{standard,required,important}
aptitude purge cron exim4{,-base,-config,-daemon-light} anacron+
aptitude purge nfs-common
aptitude purge ~c
aptitude install byobu git grc htop sudo tree vim
aptitude clean
update-alternatives --config editor # vim
addgroup --system --gid 3003 aid_inet # internet access
adduser felix
adduser felix sudo
adduser felix aid_inet
dpkg-reconfigure locales # en_GB*; utf8!
dpkg-reconfigure tzdata
# now you can enter the chroot (as felix) w/
# android$ su -c '/data/__felix__/__chroot__/shell felix'
byobu-select-backend screen
byobu-ctrl-a # screen
git config --global user.name "Felix C. Stegerman"
git config --global user.email flx@obfusk.net
git config --global color.ui true
cd ~/dev/gist
git clone https://gist.github.com/4639443.git sodium
cd ~/opt/src
git clone https://gist.github.com/4260039.git sh-config
git clone https://github.com/obfusk/dev-misc.git
git clone https://github.com/obfusk/mgit.git
ln -s opt/src/dev-misc/screenrc ~/.screenrc_
ln -s opt/src/dev-misc/vimrc ~/.vimrc
ln -s ../src/mgit/mgit ~/opt/bin/mgit
vim -p ~/.{bashrc,profile}
cp -i ~/dev/gist/sodium/dot_gemrc ~/.gemrc
cp -i ~/dev/gist/sodium/dot_npmrc ~/.npmrc
cp -i ~/dev/gist/sodium/bin_s ~/bin/s
chmod +x ~/bin/s
cat > ~/bin/sss <<END
#!/bin/bash
script -c "ssh-agent s" /dev/null
END
cat > ~/bin/ssb <<END
#!/bin/bash
script -c "ssh-agent byobu bash" /dev/null
END
chmod +x ~/bin/ss[sb]
wget -O ~/opt/bin/lein2 \
https://raw.github.com/technomancy/leiningen/stable/bin/lein
chmod +x ~/opt/bin/lein2
ln -s /usr/bin/lein ~/opt/bin/lein1
ln -s lein2 ~/opt/bin/lein
gem install pry bundler
# ...
* passwd; lock ?!
* mount --bind sdcard/storage ?! -> test!
* cyanogenmod update ?!
* aptitude install cups{,-bsd} # ???
* aptitude purge at rpcbind ... # ???
* fsck ?!
* memory ?!
* cyanogenmod wiki -> -jb recovery ?!
* android/debian users/groups ?!
* debian wiki; ld.so ?!
* barrier=1; data=ordered ?!
* verified image md5
* free + df OK
* 1.3 GiB used
* use utf8 locale and set terminal emulator to use utf8, otherwise
ncurses (e.g. aptitude) will be f*cked up !!!
* ls/rsync "overflow"? on __chroot__/img WTF ?!
* mkfs.ext4 -c ... # ???
* tune2fs -c 0 ... # ???
build-essential
curl
haskell-platform
leiningen
npm
openssh-server
ruby1.9.1-full
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.