write moar
authorSteven McDonald <steven@steven-mcdonald.id.au>
Fri, 25 Nov 2011 10:34:54 +0000 (21:34 +1100)
committerSteven McDonald <steven@steven-mcdonald.id.au>
Fri, 25 Nov 2011 10:34:54 +0000 (21:34 +1100)
tutorials/debian_on_samsung_galaxy.shtml

index 746530c44aeff7b10666ef6fdd85ce74c210c1f5..8cf176c72be542ae80d279b39deb0bee09d2c09c 100644 (file)
@@ -43,6 +43,12 @@ You have an Android smartphone with access to a root shell via SSH. I run
 II, but any Android system with root SSH access will do.
 </li>
 <li>
+You have a reasonably fast and high-capacity Internet connection
+available on your Android phone. I will not be held responsible for any
+excess usage charges you incur on your mobile Internet package while
+downloading Debian onto your phone. ;)
+</li>
+<li>
 You have a basic understanding of Debian and its packaging system. This
 procedure does require manual invocation of <tt>dpkg</tt> if you run into
 problems -- if you don't know what <tt>dpkg</tt> is or how to use it,
@@ -90,10 +96,19 @@ extract it on the phone. I'm going to put it into
 <code>
 $ mkdir /tmp/cdebootstrap && cd /tmp/cdebootstrap<br>
 $ ar x /path/to/cdebootstrap-static_0.5.8+b1_armhf.deb data.tar.gz<br>
-$ tar xzOf data.tar.gz ./usr/lib/cdebootstrap/cdebootstrap_0.5.8+b1_armhf.tar.gz | ssh root@$PHONE 'tar xz -C /data/local/bin/'
+$ tar xzOf data.tar.gz ./usr/lib/cdebootstrap/cdebootstrap_0.5.8+b1_armhf.tar.gz | ssh root@$PHONE 'tar xzC /data/local/bin/'
 </code>
 Obviously, replace <tt>$PHONE</tt> with the hostname of your phone.
 </li>
+<li>
+Unfortunately, the version of <tt>cdebootstrap</tt> included in the
+tarball appears to segfault on Android systems. I don't know why this
+happens, but replacing it with the binary provided in the package seems
+to fix this issue:
+<code>
+$ tar xzOf data.tar.gz ./usr/bin/cdebootstrap-static | ssh root@$PHONE 'cat >/data/local/bin/cdebootstrap'
+</code>
+</li>
 </ul>
 
 <h2>Bootstrapping the Debian system</h2>
@@ -133,7 +148,102 @@ So, ssh to your phone, and run the following commands:
 </code>
 
 <p>
+One last thing you need to do before setting up Debian:
+<tt>cdebootstrap</tt> expects the system shell to be at <tt>/bin/sh</tt>
+and fails without telling you why if it isn't. Since Android's system
+shell is <tt>/system/bin/sh</tt>, you have to appease
+<tt>cdebootstrap</tt> like so:
+</p>
+
+<code>
+# mkdir /bin && ln -s /system/bin/sh /bin/sh
+</code>
+
+<p>
+Now comes the fun bit, where we actually set up a Debian system. Still on
+your phone, run <tt>cdebootstrap</tt> to set up a file system tree in
+<tt>/debian</tt>. You may want to tweak the options below; I'm using
+<tt>ftp.debian-ports.org</tt> as my mirror because (at the time of
+writing) the armhf architecture is not yet fully integrated into the
+official archive. If you're using armel, or if you happen to live in the
+future, you can use your normal Debian mirror for this. Obviously, feel
+free to replace <tt>unstable</tt> with whichever suite you want to
+install.
+</p>
+
+<code>
+# cdebootstrap --allow-unauthenticated -c/data/local/bin/cdebootstrap-support/ unstable /debian http://ftp.debian-ports.org/debian/
+</code>
+
+<p>
+We have to use <tt>--allow-unauthenticated</tt> because <tt>gpgv</tt>
+isn't available to authenticate signatures on Android. This command can
+take a while to complete, so go and have a coffee or something while you
+wait for Debian to download and install.
+</p>
+
+<h2>Fixing broken packages</h2>
+
+<p>
+It was the case for me that some packages failed to install from
+<tt>cdebootstrap</tt>. Fortunately, it had at least progressed to the
+point where a shell and <tt>dpkg</tt> were installed and usable in the
+chroot, so now we can leave <tt>cdebootstrap</tt> behind and work in
+Debian:
+</p>
+
+<code>
+# chroot /debian /bin/bash<br>
+# cd /var/cache/bootstrap<br>
+# dpkg -i *.deb
+</code>
+
+<p>
+At this point, <tt>dpkg</tt> may run into some problems. As the package
+archive changes over time and different people install different suites,
+your problems will very likely not be the same as mine, so here's where
+your familiarity with the Debian package tools comes in. ;)
+</p>
+
+<p>
+The main issue I ran into here was circular dependencies. These can be
+fixed by the use of the <tt>--force-depends</tt> option to <tt>dpkg</tt>,
+to allow it to install and configure one of the packages in the
+dependency loop, so that you can then install the others normally. For
+example, I found that <tt>libc6</tt> depends on <tt>libgcc1</tt>, which
+pre-depends on <tt>multiarch-support</tt>, which depends on
+<tt>libc6</tt>. After running:
+</p>
+
+<code>
+# dpkg --force-depends --configure multiarch-support
+</code>
 
+<p>
+this circular dependency was no longer a problem, although there were
+other remaining circular dependencies that could be fixed in a similar
+way.
+</p>
+
+<h2>Installing a standard Debian package set</h2>
+
+<p>
+<tt>cdebootstrap</tt> will only install packages with a priority of
+<tt>required</tt> or <tt>important</tt>. While this will give you a
+powerful Unix-like base system, it doesn't include many utilities that
+you would get with a standard Debian system. Once all of your package
+dependency issues have been resolved, and everything in
+<tt>/var/cache/bootstrap/</tt> is installed, you can use
+<tt>aptitude</tt> to install a standard Debian system:
+</p>
+
+<code>
+# aptitude install '~prequired|~pimportant|~pstandard'
+</code>
+
+<p>
+What you choose to install beyond this depends on your wants and needs,
+and how you like your Debian. ;)
 </p>
 
 </div>