Skip to content

Commit

Permalink
anise: migrate from /system to /botbrew, from agcc.bash to NDK standa…
Browse files Browse the repository at this point in the history
…lone toolchain
  • Loading branch information
jyio committed Apr 2, 2012
1 parent 9c1c8f0 commit 9aa978f
Show file tree
Hide file tree
Showing 391 changed files with 3,536 additions and 13,062 deletions.
21 changes: 16 additions & 5 deletions README.md
Expand Up @@ -6,13 +6,13 @@ This project compiles various *nix tools and makes Opkg packages suitable for in

If you just want to use prebuilt binaries, get a shell on your rooted Android device and run:

wget http://botbrew.inportb.com/opkg/install.sh -O- | su
wget http://repo.botbrew.com/anise/install.sh -O- | su

Otherwise, keep reading to roll your own.

## Prerequisites

The following Debian packages are required for using BotBrew.
The following Debian packages are required for using BotBrew. Actually, there may be more or fewer requirements depending on the software is to be built, but this is a reasonable starting point. If the build process halts for some reason, it might be calling for additional packages.

- bash
- make
Expand Down Expand Up @@ -54,7 +54,7 @@ BotBrew knows how to make
- weechat
- ... and more (have a look at the cookbook)

Many projects do not generate packages at all; instead, they provide libraries that allow other projects to be built. These may eventually be packaged as well, to facilitate on-board software development.
Some projects do not generate packages at all; instead, they provide libraries that allow other projects to be built. These may eventually be packaged as well, to facilitate on-board software development.

## Configuration

Expand All @@ -67,7 +67,11 @@ Create a new file `config.sh` to define a couple of variables

## Usage

First, navigate to the project directory of interest, within the cookbook.
First, navigate to BotBrew's top-most directory and extract a standalone toolchain from the NDK.

./botbrew toolchain

Then, navigate to the project directory of interest, within the cookbook.

../../botbrew recipe # just shows basic information
../../botbrew recipe build # builds the project, satisfying dependencies in the process
Expand All @@ -89,10 +93,17 @@ BotBrew could also generate a makefile. First, navigate to BotBrew's top-most di

With a makefile, it is possible to specify multiple targets at once and avoid manually changing directories. Since the makefile is basically an index of the BotBrew cookbook, it should be re-generated when projects are added to or removed from BotBrew. Makefile usage is optional.

## Graphs

BotBrew is able to generate graphviz-formatted dependency graphs.

./botbrew graphbuild > graph.dot # generates a graph of build-time dependencies
./botbrew graphinstall > graph.dot # generates a graph of install-time dependencies

## Packaging

BotBrew takes cues from Arch Linux. Just as Arch's PKGBUILD scripts direct the assembly of its packages, BotBrew's recipes (`cookbook/*/recipe`) control how its projects are built, cleaned, and packaged. Each method is handled by a shell function. In most cases, the maintainer only needs to override the build function. Defaults are used whenever there is no override. BotBrew provides functions that assist in downloading/unpacking/patching source code, and functions that apply various fixes and make cross-compilation easier. The Opkg packages themselves are controlled by YAML files (`cookbook/*/package/*`). Please have a look at some of the projects for packaging hints.

## agcc.bash

agcc.bash is a wrapper around the NDK that behaves as gcc when invoked as agcc.bash or g++ when invoked as agcc-bash-g++. In the future, this wrapper may be removed in favor of the standalone toolchain generated by the NDK.
agcc.bash is a wrapper around the NDK that behaves as gcc when invoked as agcc.bash or g++ when invoked as agcc-bash-g++. It is deprecated in favor of the standalone toolchain generated by the NDK.
4 changes: 4 additions & 0 deletions bin/agcc.bash
Expand Up @@ -126,6 +126,10 @@ while true; do
# MODE=$1
#fi
;;
'-r')
ARGS[${#ARGS[@]}]="-Wl,-r"
ARGS[${#ARGS[@]}]="-Wl,-arch,arm"
;;
'-o')
if [ $# -gt 1 ]; then
if [ "$OUT" != "" ]; then
Expand Down
21 changes: 12 additions & 9 deletions bin/opkg-buildyaml
Expand Up @@ -19,14 +19,23 @@ except KeyError:
package = tempfile.mkdtemp(prefix='tmp-opkg-')
print 'staging package in',package

env = {
'PATH': os.environ.get('PATH',''),
'PROJECT': project,
'EXPORT': os.path.join(project,'export'),
'BUILD': os.path.join(project,'export'),
'PACKAGE': package,
'PREFIX': os.environ.get('G_INSTALLPREFIX','')
}

for k,v in data.iteritems():
k = os.path.join(package,k.lstrip(os.sep))
k = os.path.join(package,k.lstrip(os.sep))%env
try:
os.makedirs(os.path.dirname(k),0755)
except OSError:
pass
with open(k,'w+') as f:
f.write(v.encode('utf-8'))
f.write((v%env).encode('utf-8'))
try:
os.chmod(os.path.join(package,'CONTROL','preinst'),0755)
except OSError:
Expand Down Expand Up @@ -54,13 +63,7 @@ with open(os.path.join(package,'CONTROL','control'),'w+') as f:
initfile = os.path.join(package,'CONTROL','init')
if os.path.isfile(initfile):
os.chmod(initfile,0755)
code = subprocess.call((os.path.abspath(initfile),),env={
'PATH': os.environ.get('PATH',''),
'PROJECT': project,
'EXPORT': os.path.join(project,'export'),
'BUILD': os.path.join(project,'export'),
'PACKAGE': package
})
code = subprocess.call((os.path.abspath(initfile),),env=env)
if code != 0:
print >>sys.stderr,initfile,' failed'
exit(code)
Expand Down
122 changes: 94 additions & 28 deletions botbrew
Expand Up @@ -46,16 +46,20 @@ G_PACKAGE=package

G_NCPU=$(grep -c ^processor /proc/cpuinfo)

export G_INSTALLPREFIX=/botbrew
G_SYSTEMPREFIX=(
--prefix=/system
--sbindir=/system/bin
--sharedstatedir=/data
--localstatedir=/data
--oldincludedir=/system/include
--infodir=/system/share/info
--mandir=/system/share/man
--prefix="${G_INSTALLPREFIX}"
--sbindir="${G_INSTALLPREFIX}/bin"
--sharedstatedir="${G_INSTALLPREFIX}/var"
--localstatedir="${G_INSTALLPREFIX}/var"
--oldincludedir="${G_INSTALLPREFIX}/include"
--infodir="${G_INSTALLPREFIX}/share/info"
--mandir="${G_INSTALLPREFIX}/share/man"
)

G_IMPORT_PREFIX="${G_IMPORT}${G_INSTALLPREFIX}"
G_EXPORT_PREFIX="${G_EXPORT}${G_INSTALLPREFIX}"

if [ "${G_PATH}" = "" ]; then
G_PATH=${PATH}
fi
Expand Down Expand Up @@ -217,10 +221,14 @@ botbrew_recipe() {
shift
(
G_WORKDIR=$(pwd)
G_SYSDIR=${G_WORKDIR}/${G_IMPORT}/system
G_BINDIR=${G_SYSDIR}/bin
G_LIBDIR=${G_SYSDIR}/lib
G_INCDIR=${G_SYSDIR}/include
G_SYSDIR="${G_WORKDIR}/${G_IMPORT_PREFIX}"
G_BINDIR="${G_SYSDIR}/bin"
G_LIBDIR="${G_SYSDIR}/lib"
G_INCDIR="${G_SYSDIR}/include"
G_EXP_SYSDIR="${G_WORKDIR}/${G_EXPORT_PREFIX}"
G_EXP_BINDIR="${G_EXP_SYSDIR}/bin"
G_EXP_LIBDIR="${G_EXP_SYSDIR}/lib"
G_EXP_INCDIR="${G_EXP_SYSDIR}/include"
PACKAGE_NAME=
PACKAGE_VERSION=
PACKAGE_DEPEND=()
Expand Down Expand Up @@ -322,7 +330,8 @@ botbrew_make_repo_index() {
}

botbrew_toolchain() {
${G_NDKPATH}/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-8 --install-dir=${G_ROOT}/${G_TOOLCHAIN}
${G_NDKPATH}/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-${G_NDKAPI} --install-dir=${G_ROOT}/${G_TOOLCHAIN}
touch ${G_ROOT}/${G_TOOLCHAIN}/.d
}

botbrew_makefile() {
Expand Down Expand Up @@ -360,6 +369,58 @@ botbrew_makefile() {
)
}

botbrew_graphbuild() {
(
echo "digraph build {"
for item in ${G_COOKBOOK}/*/${G_RECIPE} ${G_COOKBOOK}/*/*/${G_RECIPE}; do
if [ -f "${item}" ]; then
G_BOTBREW=1
. "${item}"
local DIR=$(dirname ${item})
local NAME=$(basename ${DIR})
local NAME_=${NAME//-/_}
local NAME_=${NAME_//./_}
if [ "${PACKAGE_VERSION}" != "0" ]; then
echo " ${NAME_} [label=\"${NAME}-${PACKAGE_VERSION}\"];"
else
echo " ${NAME_} [label=\"${NAME}\"];"
fi
for dep in "${PACKAGE_DEPEND[@]}"; do
local dep_=${dep//-/_}
local dep_=${dep_//./_}
echo " ${NAME_} -> ${dep_};"
done
fi
done
echo "}"
)
}

botbrew_graphinstall() {
(
echo "digraph install {"
for item in ${G_COOKBOOK}/*/${G_PACKAGE}/*.yml ${G_COOKBOOK}/*/*/${G_PACKAGE}/*.yml; do
if [ -f "${item}" ]; then
export PKG="${item}"
python <<EOF
import sys, os, yaml
pkg = yaml.safe_load(open(os.environ['PKG']))
if pkg['Section'] in ('libdevel','doc'):
exit()
name = pkg['Package']
name_ = name.replace('-','_').replace('.','_')
print('\t%s [label="%s-%s"];'%(name_,name,pkg['Version']))
for dep in pkg.get('Depends','').replace(',',' ').split():
dep = dep.strip()
if len(dep) > 0:
print('\t%s -> %s;'%(name_,dep.replace('-','_').replace('.','_')))
EOF
fi
done
echo "}"
)
}

# Common fixes

botbrew_fix_config() {
Expand Down Expand Up @@ -407,7 +468,7 @@ botbrew_fix_crosslibconfig() {
local NAME=$(basename ${FILE})
if ! [ -e ${DIR}/.crosslibconfig.${NAME} ]; then
case "${DIR}" in
*/system/bin)
*/bin)
echo "#!/bin/sh" > temp
echo "prefix=$(dirname ${DIR})" >> temp
sed -e 's/^prefix=.*//g' ${FILE} >> temp
Expand Down Expand Up @@ -442,8 +503,9 @@ botbrew_fix_interpreter_path() {
fi
if [ "$query" = "" ]; then
botbrew_fix_interpreter_path "$target" '/bin/sh' 's/\/bin\/sh/\/system\/bin\/sh/g'
botbrew_fix_interpreter_path "$target" '/usr/bin/python' 's/\/usr\/bin\/python/\/system\/bin\/python/g'
botbrew_fix_interpreter_path "$target" '/usr/bin/perl' 's/\/usr\/bin\/perl/\/system\/bin\/perl/g'
botbrew_fix_interpreter_path "$target" '/usr/bin/python' 's/\/usr\/bin\/python/\/botbrew\/bin\/python/g'
botbrew_fix_interpreter_path "$target" '/usr/local/bin/python' 's/\/usr\/local\/bin\/python/\/botbrew\/bin\/python/g'
botbrew_fix_interpreter_path "$target" '/usr/bin/perl' 's/\/usr\/bin\/perl/\/botbrew\/bin\/perl/g'
elif [ "$operation" = "" ]; then
echo 1>&2 "No operation specified."
return 1
Expand Down Expand Up @@ -488,34 +550,38 @@ G_OBJDUMP=${G_OBJDUMP:-${G_TRIPLET}-objdump}
G_MAKE=${G_MAKE:-"make -j$((${G_NCPU}+1))"}

G_SYSROOT="${G_ROOT}/${G_TOOLCHAIN}/sysroot"
G_INCCXX="-I$AGCC_NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -I$AGCC_NDK/sources/cxx-stl/gnu-libstdc++/include"
G_LIBCXX="$AGCC_NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libgnustl_static.a"
G_INCCXX="-I${G_NDKPATH}/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -I${G_NDKPATH}/sources/cxx-stl/gnu-libstdc++/include"
G_LIBCXX="${G_NDKPATH}/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libgnustl_static.a"

G_CPPFLAGS=(
G_CPPFLAGS_A=(
-D_XOPEN_SOURCE=700 -D_GNU_SOURCE
-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__
-D__ARM_ARCH_5TE__ -DSK_RELEASE -DNDEBUG -UDEBUG
)
export G_CPPFLAGS="${G_CPPFLAGS[@]}"
G_WFLAGS=(
export G_CPPFLAGS="${G_CPPFLAGS_A[@]}"
G_WFLAGS_A=(
-Wall -Wno-unused -Wno-multichar -Wstrict-aliasing=2
)
export G_WFLAGS="${G_WFLAGS[@]}"
G_CFLAGS=(
export G_WFLAGS="${G_WFLAGS_A[@]}"
G_CFLAGS_A=(
-march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic
-fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0
)
export G_CFLAGS="${G_CFLAGS[@]}"
G_CXXFLAGS=(
export G_CFLAGS="${G_CFLAGS_A[@]}"
G_CXXFLAGS_A=(
-march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic
-frtti -fexceptions -ffunction-sections -funwind-tables -fmessage-length=0
)
export G_CXXFLAGS="${G_CXXFLAGS[@]}"
G_OFLAGS=(
export G_CXXFLAGS="${G_CXXFLAGS_A[@]}"
G_OFLAGS_A=(
-O2 -finline-functions -finline-limit=300 -fno-inline-functions-called-once
-fgcse-after-reload -frerun-cse-after-loop -frename-registers
-fomit-frame-pointer -fstrict-aliasing -funswitch-loops
)
export G_OFLAGS="${G_OFLAGS[@]}"
export G_OFLAGS="${G_OFLAGS_A[@]}"
export G_ALL_CFLAGS="${G_CFLAGS_A[@]} ${G_OFLAGS_A[@]}"
#export G_ALL_CXXFLAGS="${G_CXXFLAGS_A[@]} ${G_OFLAGS_A[@]} -I${G_INCCXX}"
export G_ALL_CXXFLAGS="${G_CXXFLAGS_A[@]} ${G_OFLAGS_A[@]}"

#export PATH=${G_ROOT}/bin:${G_ROOT}/bin/opkg-utils:${G_NDKPREBUILT}/bin:${G_NDKPATH}:${G_PATH}
export PATH=${G_ROOT}/bin:${G_ROOT}/bin/opkg-utils:${G_ROOT}/${G_TOOLCHAIN}/bin:${G_NDKPATH}:${G_PATH}
Expand All @@ -527,7 +593,7 @@ export AGCC_GCC=${G_NDKGCC}
export OPKG_MAINTAINER=${G_MAINTAINER}

if [ $# -gt 0 ]; then case "$1" in
download|unpack|svn|git|hg|copytree|recipe|toolchain|makefile)
download|unpack|svn|git|hg|copytree|recipe|toolchain|makefile|graphbuild|graphinstall)
CMD="$1"
shift
botbrew_${CMD} "$@"
Expand Down
18 changes: 18 additions & 0 deletions cookbook/adduser/package/adduser.yml
@@ -0,0 +1,18 @@
Package: adduser
Version: 0.0.1-0
Architecture: all
Section: admin
Priority: optional
Source: http://inportb.com/
Description: |
(busybox) add and remove users and groups
This package includes the 'adduser' and 'deluser' commands for creating and removing users.
Depends: busybox
Data:
/CONTROL/init: |
#!/bin/sh
mkdir -p ${PACKAGE}${PREFIX}/bin
ln -s busybox ${PACKAGE}${PREFIX}/bin/addgroup
ln -s busybox ${PACKAGE}${PREFIX}/bin/adduser
ln -s busybox ${PACKAGE}${PREFIX}/bin/delgroup
ln -s busybox ${PACKAGE}${PREFIX}/bin/deluser
File renamed without changes.
24 changes: 0 additions & 24 deletions cookbook/atk/patch/atk-2.3.3-android.patch

This file was deleted.

31 changes: 0 additions & 31 deletions cookbook/atk/recipe

This file was deleted.

14 changes: 0 additions & 14 deletions cookbook/autoconf/package/autoconf-doc.yml

This file was deleted.

0 comments on commit 9aa978f

Please sign in to comment.