├── README ├── build-android-data-local.sh ├── build-android-package-o.e.sh ├── build-kindle-mnt-us.sh ├── build.sh ├── download.sh ├── install-android.sh ├── install-kindle.sh ├── oe ├── recipes ├── c-ares-1.9.1 │ ├── build.sh │ └── c-ares-1.9.1-use-sysconfdir.patch ├── curl-7.28.1 │ └── build.sh └── opkg │ └── build.sh ├── setup-toolchain.sh └── skel └── etc ├── group ├── opkg ├── arch.conf ├── oe-android.conf └── options.conf ├── passwd └── resolv.conf /README: -------------------------------------------------------------------------------- 1 | Static self-contained opkg binary for adhoc vendor devices 2 | ========================================================== 3 | 4 | Opkg is a package manager for embedded systems, 5 | http://code.google.com/p/opkg/ , http://en.wikipedia.org/wiki/Opkg 6 | There are quite a few devices on the market which use Embedded Linux, 7 | but don't follow POSIX/Linux best practices and instead use adhoc 8 | vendor system structure. Oftentimes, file system layout doesn't match 9 | (or conflicts with) FHS (http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard) 10 | and user may not have write access to the entire file system, or 11 | important. Examples of such systems are Android, Kindle, etc. 12 | Users may still want to use package management for "sideloaded" 13 | Linux software, and this project is intended to make this possible. 14 | 15 | These are build scripts to build a fully static, dependency-less 16 | opkg binary for Android. 17 | 18 | The idea of this project is to provide an opkg build independent 19 | of the vendor system. Full independence of underlying system means 20 | it can be used without root permissions, or could be used even to 21 | manage vendor installation itself (for example, "Packaged Android"). 22 | To these ends, opkg is built statically, against libcurl (to not 23 | depend on a standalone wget), which in turn is built against c-ares, 24 | to not rely on /etc/resolv.conf being available (you can't 25 | create/edit that on a non-rooted device). Filesystem paths for 26 | configuration files (including network resolver ones) and package 27 | data storage is fully configurable. 28 | 29 | Usage: 30 | 31 | To build opkg, ARM cross-toolchain is needed. CodeSourcery 32 | arm-2011.09-70-arm-none-linux-gnueabi is used as the reference. If you 33 | want to download (~80MB) and setup it automatically, run: 34 | 35 | source ./setup-toolchain.sh 36 | 37 | Otherwise, you should have arm-none-linux-gnueabi-gcc and other toolchain 38 | executables in your PATH. 39 | 40 | ./download.sh 41 | 42 | To download required source packages. You need to run this once. 43 | 44 | ./build-*.sh 45 | 46 | Run build file for a particular device and configuration. Binary 47 | will be available as opkg/install/bin/opkg-static . 48 | 49 | ./install-android.sh 50 | 51 | This script will install opkg-static and require files to a 52 | connected Android device via ADB. (Works only for 53 | build-android-data-local.sh) 54 | -------------------------------------------------------------------------------- /build-android-data-local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Main prefix, opkg-static will be installed into $PREFIX/bin 4 | export PREFIX=/data/local 5 | # Where config files will be kept, "/opkg" will be appended automatically for opkg config files 6 | export SYSCONFDIR=$PREFIX/etc 7 | # Where package info files, etc. will be kept, "/opkg" will be appended 8 | # automatically 9 | export OPKG_LIB_DIR=$PREFIX/var/lib 10 | 11 | . ./build.sh 12 | -------------------------------------------------------------------------------- /build-android-package-o.e.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Main prefix, opkg-static will be installed into $PREFIX/bin 4 | export PREFIX=/data/data/o.e/r 5 | # Where config files will be kept, "/opkg" will be appended automatically for opkg config files 6 | export SYSCONFDIR=$PREFIX/etc 7 | # Where package info files, etc. will be kept, "/opkg" will be appended 8 | # automatically 9 | export OPKG_LIB_DIR=$PREFIX/var/lib 10 | 11 | . ./build.sh 12 | -------------------------------------------------------------------------------- /build-kindle-mnt-us.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Main prefix, opkg-static will be installed into $PREFIX/bin 4 | export PREFIX=/mnt/us 5 | # Where config files will be kept, "/opkg" will be appended automatically for opkg config files 6 | export SYSCONFDIR=$PREFIX/etc 7 | # Where package info files, etc. will be kept, "/opkg" will be appended 8 | # automatically 9 | export OPKG_LIB_DIR=$PREFIX/var/lib 10 | 11 | . ./build.sh 12 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | function expand() { 5 | tarball=$1 6 | basename=$(basename ${tarball%.*} .tar) 7 | echo $basename 8 | rm -rf basename 9 | tar xaf $tarball 10 | } 11 | 12 | function build() { 13 | dir=$1 14 | (cd $dir; ../recipes/$dir/build.sh) 15 | } 16 | 17 | if [ -z "$PREFIX" -o -z "$SYSCONFDIR" -o -z "$OPKG_LIB_DIR" ]; then 18 | echo "OPKG_PREFIX and friends are not defined." 19 | echo "You should not run this file directly, instead run build-* for specific target." 20 | exit 1 21 | fi 22 | 23 | if ! which arm-none-linux-gnueabi-gcc; then 24 | echo "arm-none-linux-gnueabi-gcc is required to compile software" 25 | echo "make sure you have it in PATH" 26 | exit 1 27 | fi 28 | 29 | set -x 30 | 31 | dir=$(expand c-ares*.tar.*) 32 | build $dir 33 | 34 | dir=$(expand curl*.tar.*) 35 | build $dir 36 | 37 | build opkg 38 | -------------------------------------------------------------------------------- /download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | OPKG_SVN_REV=649 5 | 6 | function download() { 7 | url="$1" 8 | file=$(basename "$url") 9 | if [ ! -f "$file" ]; then 10 | wget "$url" 11 | fi 12 | } 13 | 14 | download http://curl.haxx.se/download/curl-7.28.1.tar.bz2 15 | download http://c-ares.haxx.se/download/c-ares-1.9.1.tar.gz 16 | if [ ! -d opkg ]; then 17 | svn co -r$OPKG_SVN_REV http://opkg.googlecode.com/svn/trunk/ opkg 18 | else 19 | (cd opkg; svn update -r$OPKG_SVN_REV) 20 | fi 21 | -------------------------------------------------------------------------------- /install-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BASE=/data/local 4 | 5 | adb shell mkdir $BASE/bin 6 | adb shell mkdir $BASE/etc 7 | adb shell mkdir $BASE/etc/opkg 8 | adb shell mkdir $BASE/var/ 9 | adb shell mkdir $BASE/var/lib 10 | adb shell mkdir $BASE/var/lib/opkg 11 | 12 | adb push skel/etc/passwd $BASE/etc 13 | adb push skel/etc/group $BASE/etc 14 | adb push skel/etc/resolv.conf $BASE/etc 15 | 16 | adb push opkg/install/bin/opkg-static $BASE/bin 17 | adb push skel/etc/opkg/options.conf $BASE/etc/opkg 18 | adb push skel/etc/opkg/arch.conf $BASE/etc/opkg 19 | adb push skel/etc/opkg/oe-android.conf $BASE/etc/opkg 20 | adb push oe $BASE 21 | 22 | echo "Run:" 23 | echo "adb shell" 24 | echo ". /data/local/oe" 25 | echo "opkg-static --help" 26 | -------------------------------------------------------------------------------- /install-kindle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | KINDLE=root@192.168.1.38 4 | 5 | BASE=/mnt/us 6 | 7 | ssh $KINDLE mkdir -p $BASE/bin 8 | ssh $KINDLE mkdir -p $BASE/var/lib/opkg 9 | scp opkg/install/bin/opkg-static $KINDLE:$BASE/bin/ 10 | 11 | # TODO: Install config files here 12 | 13 | ssh $KINDLE $BASE/bin/opkg-static print-architecture 14 | ssh $KINDLE $BASE/bin/opkg-static list 15 | -------------------------------------------------------------------------------- /oe: -------------------------------------------------------------------------------- 1 | export PATH=/data/local/sbin:/data/local/bin:$PATH 2 | -------------------------------------------------------------------------------- /recipes/c-ares-1.9.1/build.sh: -------------------------------------------------------------------------------- 1 | for patch in $(dirname $0)/*.patch; do 2 | patch --forward -p1 < $patch 3 | done 4 | 5 | ./configure --host=arm-none-linux-gnueabi \ 6 | --disable-shared CFLAGS="--static -DSYSCONFDIR=\\\"$SYSCONFDIR\\\"" LDFLAGS='--static' \ 7 | --prefix=$PWD/install 8 | make 9 | make install 10 | -------------------------------------------------------------------------------- /recipes/c-ares-1.9.1/c-ares-1.9.1-use-sysconfdir.patch: -------------------------------------------------------------------------------- 1 | diff -ur c-ares-1.9.1.org/ares_private.h c-ares-1.9.1/ares_private.h 2 | --- c-ares-1.9.1.org/ares_private.h 2011-12-19 23:58:22.000000000 +0200 3 | +++ c-ares-1.9.1/ares_private.h 2013-01-26 01:12:06.268079847 +0200 4 | @@ -74,11 +74,15 @@ 5 | 6 | #else 7 | 8 | -#define PATH_RESOLV_CONF "/etc/resolv.conf" 9 | +#ifndef SYSCONFDIR 10 | +#define SYSCONFDIR "/etc" 11 | +#endif 12 | + 13 | +#define PATH_RESOLV_CONF SYSCONFDIR "/resolv.conf" 14 | #ifdef ETC_INET 15 | -#define PATH_HOSTS "/etc/inet/hosts" 16 | +#define PATH_HOSTS SYSCONFDIR "/inet/hosts" 17 | #else 18 | -#define PATH_HOSTS "/etc/hosts" 19 | +#define PATH_HOSTS SYSCONFDIR "/hosts" 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /recipes/curl-7.28.1/build.sh: -------------------------------------------------------------------------------- 1 | ./configure --host=arm-none-linux-gnueabi --disable-shared \ 2 | --enable-ares=$PWD/../c-ares-1.9.1/install \ 3 | --prefix=$PWD/install 4 | make 5 | make install 6 | -------------------------------------------------------------------------------- /recipes/opkg/build.sh: -------------------------------------------------------------------------------- 1 | if [ -z "$PREFIX" ]; then 2 | echo "PREFIX not defined" 3 | exit 1 4 | fi 5 | 6 | autoreconf -v --install || exit 1 7 | glib-gettextize --force --copy || exit 1 8 | make clean || true 9 | ./configure CFLAGS='--static -Os' LDFLAGS='--static' \ 10 | CURL_CFLAGS="-I$PWD/../curl-7.28.1/install/include" \ 11 | CURL_LIBS="-L$PWD/../curl-7.28.1/install/lib -lcurl" \ 12 | --host=arm-none-linux-gnueabi \ 13 | --disable-shared \ 14 | --disable-gpg \ 15 | --enable-curl \ 16 | --disable-ssl-curl \ 17 | --prefix="$PREFIX" \ 18 | --with-opkglibdir="$OPKG_LIB_DIR" \ 19 | --with-opkgetcdir="$SYSCONFDIR" 20 | make 21 | make install-strip prefix=$PWD/install transform='s/-cl/-static/' 22 | 23 | echo 24 | echo "****************" 25 | echo "opkg build finished, binaries are in $PWD/install/bin" 26 | echo "****************" 27 | -------------------------------------------------------------------------------- /setup-toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | file="arm-2011.09-70-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2" 5 | dir="arm-2011.09" 6 | 7 | 8 | if [ "$0" == "./setup-toolchain.sh" ]; then 9 | 10 | echo "You rather should source this file: \". $0\"" 11 | 12 | else 13 | if [ ! -d $dir ]; then 14 | 15 | if [ ! -f $file ]; then 16 | wget https://sourcery.mentor.com/GNUToolchain/package9728/public/arm-none-linux-gnueabi/$file 17 | fi 18 | 19 | tar xfj $file 20 | fi 21 | 22 | export PATH=$PWD/arm-2011.09/bin:$PATH 23 | fi 24 | -------------------------------------------------------------------------------- /skel/etc/group: -------------------------------------------------------------------------------- 1 | root:x:0:root 2 | system:x:1000:system 3 | radio:x:1001: 4 | bluetooth:x:1002: 5 | graphics:x:1003:shell 6 | input:x:1004:shell 7 | audio:x:1005: 8 | camera:x:1006: 9 | log:x:1007:shell 10 | compass:x:1008: 11 | mount:x:1009:shell 12 | wifi:x:1010: 13 | adb:x:1011:shell 14 | install:x:1012: 15 | media:x:1013: 16 | dhcp:x:1014: 17 | sdcard_rw:x:1015:shell 18 | vpn:x:1016: 19 | keystore:x:1017: 20 | usb:x:1018: 21 | gps:x:1019: 22 | nfc:x:1025: 23 | shell:x:2000:shell 24 | cache:x:2001:cache 25 | diag:x:2002:diag 26 | net_bt_admin:x:3001: 27 | net_bt:x:3002: 28 | inet:x:3003:shell 29 | net_raw:x:3004: 30 | net_admin:x:3005: 31 | misc:x:9998: 32 | nobody:x:9999: 33 | -------------------------------------------------------------------------------- /skel/etc/opkg/arch.conf: -------------------------------------------------------------------------------- 1 | arch all 1 2 | arch any 6 3 | arch noarch 11 4 | arch arm 16 5 | arch armv4 21 6 | arch armv4t 26 7 | arch armv5 31 8 | arch armv5t 36 9 | arch armv5e 41 10 | arch armv5te 46 11 | arch qemuarm 51 12 | -------------------------------------------------------------------------------- /skel/etc/opkg/oe-android.conf: -------------------------------------------------------------------------------- 1 | src/gz oe-armv5te http://master.dl.sourceforge.net/project/oe-android/armv5te 2 | src/gz oe-all http://master.dl.sourceforge.net/project/oe-android/all 3 | src/gz oe-qemuarm http://master.dl.sourceforge.net/project/oe-android/qemuarm 4 | -------------------------------------------------------------------------------- /skel/etc/opkg/options.conf: -------------------------------------------------------------------------------- 1 | option tmp_dir /data/data/o.e/r/tmp 2 | -------------------------------------------------------------------------------- /skel/etc/passwd: -------------------------------------------------------------------------------- 1 | root:x:0:0:root:/data/data/o.e/r/home/root:/data/data/o.e/r/bin/sh 2 | system:x:1000:1000:system:/data/data/o.e/r/home/root:/data/data/o.e/r/bin/sh 3 | graphics:x:1003:1003:graphics:/data/data/o.e/r/home/root:/data/data/o.e/r/bin/sh 4 | shell:x:2000:2000:shell:/data/data/o.e/r/home/shell:/data/data/o.e/r/bin/sh 5 | nobody:x:9999:9999:nobody:/dev/null:/dev/null 6 | -------------------------------------------------------------------------------- /skel/etc/resolv.conf: -------------------------------------------------------------------------------- 1 | nameserver 8.8.8.8 2 | --------------------------------------------------------------------------------