<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>inportb &#187; Hacks</title>
	<atom:link href="http://inportb.com/category/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://inportb.com</link>
	<description>salty nothings are yummier</description>
	<lastBuildDate>Sun, 08 Jan 2012 06:31:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>agcc.bash: Make Native Android C Programs Using the NDK</title>
		<link>http://inportb.com/2012/01/08/agcc-bash-make-native-android-c-programs-using-the-ndk/</link>
		<comments>http://inportb.com/2012/01/08/agcc-bash-make-native-android-c-programs-using-the-ndk/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 06:28:50 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=893</guid>
		<description><![CDATA[I return to school at noon, but before then, I&#8217;d like to share my evening project: agcc.bash, a rewrite of agcc and agcc2.pl that works with revisions 6 and 7 of the Android NDK. The NDK is a GCC-based cross-compiler that lets you embed object code in a traditional Android app. It also works as...<a href="http://inportb.com/2012/01/08/agcc-bash-make-native-android-c-programs-using-the-ndk/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I return to school at noon, but before then, I&#8217;d like to share my evening project: <a href="http://dl.dropbox.com/u/1213413/htdocs/agcc/agcc.bash">agcc.bash</a>, a rewrite of <a href="http://plausible.org/andy/agcc">agcc</a> and <a href="http://credentiality2.blogspot.com/2011/07/native-android-c-program-using-ndk.html">agcc2.pl</a> that works with revisions 6 and 7 of the Android NDK.</p>
<p>The NDK is a GCC-based cross-compiler that lets you embed object code in a traditional Android app. It also works as a standalone cross-compiler, though it is not advertised as such. It is quite rough when used by itself, and agcc wraps the complexity in a little script. While agcc and agcc2.pl are written in Perl, agcc.bash is a Bash script. It also supports the latest revisions of the NDK, though r7 is slightly buggy.</p>
<p>With agcc.bash, building native Android software feels almost like working with GCC. As a quick example, let&#8217;s try the classic <a href="http://dl.dropbox.com/u/1213413/htdocs/agcc/hello.c">hello world</a>:</p>
<blockquote><p>AGCC_NDK=~/android-ndk-r6 ./agcc.bash hello.c -o hello</p></blockquote>
<p>That wasn&#8217;t too exciting&#8230; but what happened there? I have the NDK installed at ~/android-ndk-r6 and I told agcc.bash where to look for it, using the AGCC_NDK environment variable. I then invoked agcc.bash as if it were GCC. Let&#8217;s see what agcc.bash did behind the scenes:</p>
<blockquote><p>AGCC_NDK=~/android-ndk-r6 AGCC_ECHO=yes ./agcc.bash hello.c -o hello</p>
<p>=&gt; ./agcc.bash hello.c -o hello<br />
&lt;= /home/jyio/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -o hello -I/home/jyio/android-ndk-r6/platforms/android-8/arch-arm/usr/include -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 hello.c -Bdynamic -Wl,-T,/home/jyio/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-dynamic-linker,/system/bin/linker -Wl,&#8211;gc-sections -Wl,-z,nocopyreloc -Wl,&#8211;no-undefined -Wl,-rpath-link=/home/jyio/android-ndk-r6/platforms/android-8/arch-arm -L/home/jyio/android-ndk-r6/platforms/android-8/arch-arm/usr/lib -nostdlib /home/jyio/android-ndk-r6/platforms/android-8/arch-arm/usr/lib/crtend_android.o /home/jyio/android-ndk-r6/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o -lc /home/jyio/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a -lm -ldl</p></blockquote>
<p>See how it transformed our innocent little command into a monster! This might be overkill for a hello world program, but it provides pretty good support for more complex software such as OpenSSL, cURL, and Python. It would be a good idea to add the NDK toolchain and agcc.bash to $PATH before trying to build a big program. In my case, the toolchain resides in <em>~/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin</em>. If you want to build some software that come with configure scripts, you might start with:</p>
<blockquote><p><strong>CC=agcc.bash</strong> ./configure</p></blockquote>
<p>Do try this at home! Relevant links:</p>
<ul>
<li><a href="http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2">Android NDK r6</a> (or, <a href="http://developer.android.com/sdk/ndk/">the latest version</a>)</li>
<li><a href="http://dl.dropbox.com/u/1213413/htdocs/agcc/agcc.bash">agcc.bash</a></li>
<li><a href="http://dl.dropbox.com/u/1213413/htdocs/agcc/hello.c">hello.c</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2012/01/08/agcc-bash-make-native-android-c-programs-using-the-ndk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Kindle2-Turned-Kindle3 Does IRC</title>
		<link>http://inportb.com/2011/06/03/kindle2-turned-kindle3-does-irc/</link>
		<comments>http://inportb.com/2011/06/03/kindle2-turned-kindle3-does-irc/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 16:29:53 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=849</guid>
		<description><![CDATA[One of the improvements in the Amazon Kindle3 OS is the WebKit-based browser. Based on a tip, I tried communicating on Freenode using the Webchat interface. How do you get this particular OS update on a second-generation Kindle? Well, let&#8217;s just say it&#8217;s not officially supported.]]></description>
			<content:encoded><![CDATA[<p>One of the improvements in the Amazon Kindle3 OS is the WebKit-based browser. Based on a tip, I tried communicating on Freenode using the Webchat interface.</p>
<p><a href="http://inportb.com/wp-content/uploads/2011/06/freenode.gif"><img class="aligncenter size-medium wp-image-850" title="freenode" src="http://inportb.com/wp-content/uploads/2011/06/freenode-225x300.gif" alt="" width="225" height="300" /></a></p>
<p>How do you get this particular OS update on a second-generation Kindle? Well, let&#8217;s just say <a href="http://www.reddit.com/r/kindle/comments/hmyo5/hack_to_install_kindle_3x_on_kindle_2_and_dx/">it&#8217;s not officially supported</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2011/06/03/kindle2-turned-kindle3-does-irc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reblox Build Process</title>
		<link>http://inportb.com/2011/05/26/reblox-build-process/</link>
		<comments>http://inportb.com/2011/05/26/reblox-build-process/#comments</comments>
		<pubDate>Fri, 27 May 2011 01:14:22 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=837</guid>
		<description><![CDATA[Since I&#8217;ve been asked several times to demonstrate how to make a reblox, I decided to put together a little photo tutorial. Enjoy! The Bloxes website features construction images as well, and the process is similar.]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve been asked several times to demonstrate how to make a <a title="Bloxes" href="/2011/05/21/bloxes/">reblox</a>, I decided to put together a little photo tutorial. Enjoy!</p>
<div id="attachment_839" class="wp-caption aligncenter" style="width: 285px"><a href="http://inportb.com/wp-content/uploads/2011/05/instruction.jpg"><img class="size-medium wp-image-839" title="instruction" src="http://inportb.com/wp-content/uploads/2011/05/instruction-275x300.jpg" alt="" width="275" height="300" /></a><p class="wp-caption-text">Look at the pretty pictures.</p></div>
<p>The Bloxes website features construction images as well, and the process is similar.</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2011/05/26/reblox-build-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bloxes</title>
		<link>http://inportb.com/2011/05/21/bloxes/</link>
		<comments>http://inportb.com/2011/05/21/bloxes/#comments</comments>
		<pubDate>Sun, 22 May 2011 03:16:11 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=824</guid>
		<description><![CDATA[Bloxes are nifty &#8220;modular adult-sized building blocks.&#8221; They are actually interlocking cardboard boxes that can be used to build things such as furniture. They&#8217;re not exactly inexpensive, and shipping takes a while. Instead of ordering bloxes, I decided to prototype my own on paper just for fun. This design might require some modification for use...<a href="http://inportb.com/2011/05/21/bloxes/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://bloxes.com/">Bloxes</a> are nifty &#8220;modular adult-sized building blocks.&#8221; They are actually interlocking cardboard boxes that can be used to build things such as furniture.</p>
<p>They&#8217;re not exactly inexpensive, and shipping takes a while. Instead of ordering bloxes, I decided to <a title="Reblox Build Process" href="/2011/05/26/reblox-build-process/">prototype my own on paper</a> just for fun. This design might require some modification for use with cardboard (in particular, I&#8217;m sure you could figure out how the original design works and apply it to your project).</p>
<p><a href="http://dl.dropbox.com/u/1213413/reblox/reblox.svg"><img class="aligncenter" title="inportbloxes design" src="http://dl.dropbox.com/u/1213413/reblox/reblox.png" alt="" width="256" /></a></p>
<p>If you have the resources, go ahead and roll your own cardboard modules. As usual, it&#8217;s easier said than done&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2011/05/21/bloxes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Twisted and gevent, Sitting in a Tree</title>
		<link>http://inportb.com/2011/02/27/twisted-and-gevent-sitting-in-a-tree/</link>
		<comments>http://inportb.com/2011/02/27/twisted-and-gevent-sitting-in-a-tree/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 04:25:38 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=790</guid>
		<description><![CDATA[I got a bit closer to integrating Twisted with gevent. So far, I’m liking gevent’s speed and blocking style, but it does lack Twisted’s extensive library. Well, this new Twisted reactor runs on gevent and makes it a bit painful to use both frameworks together. Here is where the magic happens. Note that this code...<a href="http://inportb.com/2011/02/27/twisted-and-gevent-sitting-in-a-tree/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I got a bit closer to integrating Twisted with gevent. So far, I’m liking gevent’s speed and blocking style, but it does lack Twisted’s extensive library. Well, this new Twisted reactor runs on gevent and makes it a bit painful to use both frameworks  together.</p>
<p><a href="http://wiki.inportb.com/wiki/Projects:Python:Geventreactor">Here is where the magic happens.</a></p>
<p>Note that this code is for using Twisted with gevent (i.e. libevent  and greenlet). For using Twisted with greenlet alone, there is  corotwine. Twisted can also be used with Eventlet.</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2011/02/27/twisted-and-gevent-sitting-in-a-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Twisted Play With gevent and greenlet</title>
		<link>http://inportb.com/2011/02/20/making-twisted-play-with-gevent-and-greenlet/</link>
		<comments>http://inportb.com/2011/02/20/making-twisted-play-with-gevent-and-greenlet/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 04:22:12 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=786</guid>
		<description><![CDATA[Now, Twisted is a pretty awesome framework. It’s not only a networking library, but it’s a framework that provides all sorts of functionality. There’s also plenty of example code, and many things are already implemented. It is somewhat slow, however, and it likes to take control of the whole program. Keeping track of all the...<a href="http://inportb.com/2011/02/20/making-twisted-play-with-gevent-and-greenlet/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Now, Twisted is a pretty awesome framework.  It’s not only a networking library, but it’s a framework that provides  all sorts of functionality. There’s also plenty of example code, and  many things are already implemented. It is somewhat slow, however, and  it likes to take control of the whole program. Keeping track of all the  deferreds is not really a problem for me, but greenlet’s blocking syntax  is quite nice.</p>
<p>If you haven’t seen corotwine yet, I’d urge you to have a look. It  lets you use Twisted with a blocking syntax. It’s not quite what I  wanted, but it does what it says on the tin. I wanted to use Twisted with Twisted syntax, greenlet with greenlet syntax, and maybe even let  the Twisted bits talk with the greenlet bits. It is apparently quite  easy with gevent.</p>
<p>The first thing you want to do is monkey-patch select.select. This is  the method that Twisted uses to wait for file descriptors, and we can  let gevent handle that with libevent and greenlet. Next, you run  reactor.run either in the main greenlet or in a new greenlet.</p>
<p>As long as Twisted and greenlet code stay separate, everything is  peachy. There are some problems when they start mixing. Because the  Twisted reactor runs in a single greenlet, calling gevent.sleep (or  doing anything else that involves a greenlet switch) actually blocks all  of Twisted. Long-running jobs could be done in new greenlets, though.  And if another greenlet wants to work with a Twisted transport (i.e. to  send or receive data), it’s not going to happen until gevent sees some  network activity destined for Twisted and switches to its reactor. These  are the same problems you’d see with corotwine, and I suspect they might be alleviated with a greenlet-aware reactor.</p>
<p><strong>Update:</strong> gTwist, the original code for gevent-Twisted integration, has been replaced with a more robust system called <a href="http://wiki.inportb.com/wiki/Projects:Python:Geventreactor">geventreactor</a>. As its name implies, geventreactor is a gevent-powered Twisted reactor.</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2011/02/20/making-twisted-play-with-gevent-and-greenlet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Package Management with Opkg</title>
		<link>http://inportb.com/2010/10/19/package-management-with-opkg/</link>
		<comments>http://inportb.com/2010/10/19/package-management-with-opkg/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 15:57:58 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=751</guid>
		<description><![CDATA[Opkg is not limited to using packages from files; it is also capable of using apt-get style repositories, vastly simplifying the job of fetching dependencies and updating packages. I already have a repository set up, and it could be added as such echo "src/gz inportb-android-froyo http://repo.inportb.com/android/froyo" &#62; /cache/etc/opkg/inportb.conf After doing that, we could refresh the...<a href="http://inportb.com/2010/10/19/package-management-with-opkg/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Opkg is not limited to using packages from files; it is also capable of using apt-get style repositories, vastly simplifying the job of fetching dependencies and updating packages. I already have a repository set up, and it could be added as such</p>
<blockquote><p><code>echo "src/gz inportb-android-froyo http://repo.inportb.com/android/froyo" &gt; /cache/etc/opkg/inportb.conf</code></p></blockquote>
<p>After doing that, we could refresh the package list</p>
<blockquote><p><code>opkg update</code></p></blockquote>
<p>Installing a package then becomes as easy as</p>
<blockquote><p><code>opkg install name-of-package</code></p></blockquote>
<p>And we could keep all our packages up-to-date using</p>
<blockquote><p><code>opkg update; opkg upgrade</code></p></blockquote>
<p>It&#8217;s also quite simple to set up a repository for distributing packages.</p>
<p><span id="more-751"></span>First, we fetch the latest <em>opkg-utils</em> off SVN at &lt;<a href="http://svn.openmoko.org/trunk/src/host/opkg-utils/">http://svn.openmoko.org/trunk/src/host/opkg-utils/</a>&gt; and <em>make</em> it. Then, we designate a directory (the repository) to dump all our packages in. Finally, every time we update the repository, we generate a new package feed</p>
<blockquote><p><code>cd path/to/repository; opkg-make-index . &gt; Packages</code></p></blockquote>
<p>Now all we have to do is make sure the directory is visible on the Web, and share its URL. The end user would add a line to a file within <em>/cache/etc/opkg</em></p>
<blockquote><p><code>src name-of-repository http://host/path/to/repository</code></p></blockquote>
<p>We could also gzip the feed to reduce bandwidth usage</p>
<blockquote><p><code>gzip -c9 Packages &gt; Packages.gz</code></p></blockquote>
<p>The repository line would be changed accordingly to</p>
<blockquote><p><code>src/gz name-of-repository http://host/path/to/repository</code></p></blockquote>
<p>We could have multiple files in <em>/cache/etc/opkg</em>, and each one of those could have multiple lines. The idea is that each vendor could have multiple repositories, and keep them in the same file for ease of management.</p>
<p>&lt;ShamelessAdvertisement&gt; Incidentally, it is almost trivial for Dropbox users to set up a repository. If you need 2.25GB of premium Web-accessible storage to host your repository or anything else for free, simply <a href="http://www.dropbox.com/referrals/NTEyMTM0MTM5">sign up through my referral link</a>. You could also <a href="http://www.dropbox.com/">skip the referral</a> and get 2GB.&lt;/ShamelessAdvertisement&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2010/10/19/package-management-with-opkg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making an Opkg Package</title>
		<link>http://inportb.com/2010/10/19/making-an-opkg-package/</link>
		<comments>http://inportb.com/2010/10/19/making-an-opkg-package/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 15:30:29 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=744</guid>
		<description><![CDATA[Now that we have Opkg for Android, we could use it to install packages from local files or off Web servers. Installing a package is as simple as opkg install path/to/package.opk or, if it&#8217;s on the Web opkg install http://host/path/to/package.opk And to remove the package, we would go opkg remove name-of-package But what if we...<a href="http://inportb.com/2010/10/19/making-an-opkg-package/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Now that we have Opkg for Android, we could use it to install packages from local files or off Web servers. Installing a package is as simple as</p>
<blockquote><p><code>opkg install path/to/package.opk</code></p></blockquote>
<p>or, if it&#8217;s on the Web</p>
<blockquote><p><code>opkg install http://host/path/to/package.opk</code></p></blockquote>
<p>And to remove the package, we would go</p>
<blockquote><p><code>opkg remove name-of-package</code></p></blockquote>
<p>But what if we wanted to share our own software with others? In this case, we would create our own packages. An Opkg package is essentially a Debian package with fewer control fields. If you know how to make a Debian package, you should be well on your way. In general, a package is an <em>ar</em> archive containing a control tarball, a data tarball, and a debian-binary file. For example let&#8217;s have a look at the opkg-hello package:</p>
<p><span id="more-744"></span><br />
<blockquote><code>package.opk	(ar)<br />
+- debian-binary	(text)<br />
+- control.tar.gz	(tarball)<br />
...+- control	(text)<br />
...+- preinst	(script)<br />
...+- postinst	(script)<br />
...+- prerm		(script)<br />
...+- postrm	(script)<br />
+- data.tar.gz	(tarball)<br />
...+- system<br />
......+- bin<br />
.........+- opkg-hello	(example program)</code></p></blockquote>
<p>Now, <em>debian-binary</em> simply contains the string <em>2.0</em>; it signifies that the archive is indeed a Debian[esque] package. The files within <em>control.tar.gz</em> are cached when the package is installed, and contain information about the package itself, how the package is to be installed, and how the package is to be removed. The contents of <em>control</em> describe the package and are used to build the repository feed, which we will cover later. There are also scripts that govern the installation and removal processes and require execution permission: <em>preinst</em> runs before the package is extracted, <em>postinst</em> performs any configuration after the main files are in place, <em>prerm</em> prepares the system before the package is removed, and <em>postrm</em> cleans up after the main files are gone. Let&#8217;s have a look inside these files:</p>
<blockquote><p><em>control</em><br />
<code>Package: opkg-hello<br />
Version: 0.0.1<br />
Description: Sample OPKG package<br />
Section: cyanogenmod/applications<br />
Priority: optional<br />
Maintainer: Jiang Yio<br />
Architecture: all<br />
Homepage: http://inportb.com/<br />
Source:<br />
Depends:</code></p></blockquote>
<blockquote><p><em>preinst</em><br />
<code>#!/system/bin/sh<br />
echo "preinst: preparing to install package"<br />
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system</code></p></blockquote>
<blockquote><p><em>postinst</em><br />
<code>#!/system/bin/sh<br />
mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system<br />
echo "postinst: installed package"</code></p></blockquote>
<blockquote><p><em>prerm</em><br />
<code>#!/system/bin/sh<br />
echo "prerm: preparing to remove package"<br />
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system</code></p></blockquote>
<blockquote><p><em>postrm</em><br />
<code>#!/system/bin/sh<br />
mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system<br />
echo "postrm: removed package"</code></p></blockquote>
<p>Other than emitting some debugging information, the scripts also make the <em>/system</em> tree writable while the package is installed or removed.</p>
<p>Now that we have the anatomy of an Opkg package, we could create more like it with ease. Here are a couple of helpful commands:</p>
<blockquote><p><em>make a tarball</em><br />
<code>tar zcvf name-of-tarball.tar.gz list of files and directories</code></p></blockquote>
<blockquote><p><em>make an archive</em><br />
<code>ar -r name-of-archive.opk list of files and directories</code></p></blockquote>
<p>Other than that, just be sure all the files have the right owner, group, and permission. It would also help to know something about the Android directory tree &#8212; for example, we dropped the example program in <em>/system/bin</em>, which we know is part of the search path.</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2010/10/19/making-an-opkg-package/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Debian Packages on Android Phones</title>
		<link>http://inportb.com/2010/10/17/debian-packages-on-android-phones/</link>
		<comments>http://inportb.com/2010/10/17/debian-packages-on-android-phones/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 00:26:21 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=737</guid>
		<description><![CDATA[Well, almost. While one could theoretically install Debian packages on Android phones, it is generally a bad idea to install software designed for one system onto a different system. However, the Debian package manager is excellent for keeping track of software, and it would be nice if it could be used on Android as well....<a href="http://inportb.com/2010/10/17/debian-packages-on-android-phones/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p>Well, almost. While one could theoretically install Debian packages on Android phones, it is generally a bad idea to install software designed for one system onto a different system. However, the Debian package manager is excellent for keeping track of software, and it would be nice if it could be used on Android as well. iPhone users already have access to this mechanism in the form of Cydia, so why not put it on Android too?</p>
<p><strong><span id="more-737"></span>For user applications, we already have APK&#8217;s.</strong></p>
<p>These are self-contained blocks that may be easily installed and removed. The APK system is great for running untrusted software that needs to be sandboxed, but it is not flexible or efficient enough to manage the operating system itself. Android users typically do not update their systems very often, and when they do so, they update the whole setup at once. This presents two problems: firstly, users don&#8217;t receive updated software as it becomes available and secondly, each update is a resource-intensive and time-consuming task. It would be great if system software could be updated piecemeal, just like a <em>real</em> Linux setup.</p>
<p>The Debian packaging system solves this problem very well, but its size makes it unsuitable for mobile devices. Nevermind that Cydia users use Debian packages &#8212; it&#8217;s still good to be frugal. Since we&#8217;re not going to install Debian software onto our phones (which would probably break many things), we don&#8217;t have to stick strictly to the Debian format; on the other hand, Debian provides a very nice model for us to emulate.</p>
<p><strong>Enter Opkg.</strong></p>
<p>Here is a package manager and format that very closely resemble the Debian package manager and format. In fact, <a href="http://code.google.com/p/opkg/">Opkg</a> is capable of working with Debian packages. The difference is that it&#8217;s tiny and it&#8217;s designed for mobile devices.</p>
<p>For starters, I have compiled a statically-linked build of Opkg. It is able to install local (and http-hosted) packages as dpkg does. It can also maintain a list of software sources <em>a la</em> apt-get. Its small size (745KB) makes it easily-integrable into almost any Android system.</p>
<p>If you&#8217;re feeling adventurous and would like to try this on your rooted Android phone, the files are currently hosted <a href="http://dl.dropbox.com/u/1213413/android-opkg/index.htm">on my Dropbox account</a>. You do need root access, so if you use a cooked ROM such as CyanogenMod, you should be good to go. Please keep in mind that there is only one package at the moment (the example), but it&#8217;s not difficult to make more.</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2010/10/17/debian-packages-on-android-phones/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Install Windows 7 from USB Pen Drive Using Grub2 and Grub4Dos</title>
		<link>http://inportb.com/2010/07/19/install-windows-7-from-usb-pen-drive-using-grub2-and-grub4dos/</link>
		<comments>http://inportb.com/2010/07/19/install-windows-7-from-usb-pen-drive-using-grub2-and-grub4dos/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 07:48:02 +0000</pubDate>
		<dc:creator>Jiang Yio</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://inportb.com/?p=709</guid>
		<description><![CDATA[I wanted to install Windows 7 on my netbook, but I didn&#8217;t have access to a Windows environment from which I could run bootsect.exe or install Grub4Dos; so I figured I&#8217;d install Grub2 on my USB disk using Ubuntu, have Grub2 chainload Grub4Dos, and finally let Grub4Dos chainload the Windows installer. This worked for me:...<a href="http://inportb.com/2010/07/19/install-windows-7-from-usb-pen-drive-using-grub2-and-grub4dos/">&#187;</a>]]></description>
			<content:encoded><![CDATA[<p>I wanted to install Windows 7 on my netbook, but I didn&#8217;t have access to a Windows environment from which I could <a href="http://www.intowindows.com/how-to-install-windows-7vista-from-usb-drive-detailed-100-working-guide/">run bootsect.exe</a> or <a href="http://www.sevenforums.com/tutorials/91798-install-windows-7-usb-pen-drive-using-grub4dos.html">install Grub4Dos</a>; so I figured I&#8217;d install Grub2 on my USB disk using Ubuntu, have Grub2 chainload Grub4Dos, and finally let Grub4Dos chainload the Windows installer. This worked for me:</p>
<ol>
<li>Prepare a fresh NTFS partition on the USB disk <strong>/dev/sdX</strong> and mount it at <strong>/mntX1</strong>, then copy all files from the Windows installer disc or image into <strong>/mntX1</strong></li>
<li>Install Grub2:<br />
cd <strong>/mntX1</strong>; sudo grub-install -<em></em>-no-floppy -<em></em>-root-directory=<strong>/mntX1</strong> <strong>/dev/sdX</strong>; sync</li>
<li>Download the latest <a href="http://download.gna.org/grub4dos/">Grub4Dos</a>, and unpack grub.exe into /mntX1</li>
<li>Create <strong>/mntX1</strong>/boot/grub/grub.cfg:<br />
set timeout=0<br />
set default=0<br />
menuentry &#8220;Install Windows&#8221; {<br />
&nbsp; &nbsp; &nbsp;linux16 /grub.exe -<em></em>-config-file=&#8221;root (hd0,<strong>0</strong>); chainloader (hd0,<strong>0</strong>)/bootmgr&#8221;<br />
}</li>
</ol>
<p>I was surprised that such a complicated setup actually worked. Be sure to substitute your own values for <strong>/mntX1</strong> and <strong>/dev/sdX</strong>. In the Grub4Dos config, (hd0,<strong>0</strong>) refers to the first partition on the boot disk; you&#8217;d need to change that if you want to boot the installer from a different partition.</p>
]]></content:encoded>
			<wfw:commentRss>http://inportb.com/2010/07/19/install-windows-7-from-usb-pen-drive-using-grub2-and-grub4dos/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

