summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKibum Kim <kb0929.kim@samsung.com>2012-02-25 21:02:54 +0900
committerKibum Kim <kb0929.kim@samsung.com>2012-02-25 21:02:54 +0900
commitce5990287932e444d19ec4edcc555da069341664 (patch)
tree449a5aba3dd22da45c1fd160c3a3629ab2df918f
downloadsbs-ce5990287932e444d19ec4edcc555da069341664.tar.gz
sbs-ce5990287932e444d19ec4edcc555da069341664.tar.bz2
sbs-ce5990287932e444d19ec4edcc555da069341664.zip
git init
-rw-r--r--Makefile11
-rw-r--r--README60
-rw-r--r--README.quickstart96
-rwxr-xr-xbin/make-ext462
-rwxr-xr-xbin/sbs1957
-rw-r--r--debian/changelog348
-rw-r--r--debian/compat1
-rw-r--r--debian/control11
-rwxr-xr-xdebian/rules65
-rwxr-xr-xinstall-sbs285
-rwxr-xr-xmake-offline-mirror.sh125
-rwxr-xr-xsbs-make-devkit85
-rw-r--r--share/sbs/boards/generic.conf11
-rw-r--r--share/sbs/boards/slp.conf4
-rw-r--r--share/sbs/boards/slp.preseed-debconf1
-rw-r--r--share/sbs/boards/tizen.conf4
-rw-r--r--share/sbs/data/new_part_plan.xml8
-rw-r--r--share/sbs/default_env/AS0
-rw-r--r--share/sbs/default_env/ASFLAGS0
-rw-r--r--share/sbs/default_env/CC0
-rw-r--r--share/sbs/default_env/CCACHE_COMPRESS1
-rw-r--r--share/sbs/default_env/CFLAGS1
-rw-r--r--share/sbs/default_env/CPP0
-rw-r--r--share/sbs/default_env/CPPFLAGS0
-rw-r--r--share/sbs/default_env/CXX0
-rw-r--r--share/sbs/default_env/CXXFLAGS0
-rw-r--r--share/sbs/default_env/LD0
-rw-r--r--share/sbs/default_env/LDFLAGS0
-rw-r--r--share/sbs/default_env/MAKE0
-rw-r--r--share/sbs/default_env/MAKEFLAGS0
-rwxr-xr-xshare/sbs/scripts/010.makeimage-hook.checktools.native12
-rwxr-xr-xshare/sbs/scripts/099.makeimage-hook.set-hostname.native4
-rwxr-xr-xshare/sbs/scripts/105.makeimage-hook.apt-fixup.sb27
-rwxr-xr-xshare/sbs/scripts/110.makeimage-hook.download-all.sb212
-rwxr-xr-xshare/sbs/scripts/112.makeimage-hook.preseed-debconf.sb212
-rwxr-xr-xshare/sbs/scripts/114.makeimage-hook.pre-default-files.fakeroot25
-rwxr-xr-xshare/sbs/scripts/115.makeimage-hook.install-default-files.sb210
-rwxr-xr-xshare/sbs/scripts/119.makeimage-hook.repace-bin-sh-with-bash.fakeroot11
-rwxr-xr-xshare/sbs/scripts/120.makeimage-hook.install-pkgs.sb212
-rwxr-xr-xshare/sbs/scripts/121.makeimage-hook.revert-bin-bash-workaround.fakeroot9
-rwxr-xr-xshare/sbs/scripts/122.makeimage-hook.prune-metapkgs.sb27
-rwxr-xr-xshare/sbs/scripts/123.makeimage-hook.add_systemd.fakeroot21
-rwxr-xr-xshare/sbs/scripts/123.makeimage-hook.add_systemd.sb213
-rwxr-xr-xshare/sbs/scripts/123.makeimage-hook.prelink.sb213
-rwxr-xr-xshare/sbs/scripts/125.makeimage-hook.pkglist-create.sb29
-rwxr-xr-xshare/sbs/scripts/126.makeimage-hook.pkglist-move.fakeroot11
-rwxr-xr-xshare/sbs/scripts/129.makeimage-hook.clean-apt-cache.sb28
-rwxr-xr-xshare/sbs/scripts/130.makeimage-hook.apply-default-files.fakeroot15
-rwxr-xr-xshare/sbs/scripts/190.makeimage-hook.write-install-ini.fakeroot37
-rwxr-xr-xshare/sbs/scripts/200.makeimage-hook.mangle.fakeroot62
-rwxr-xr-xshare/sbs/scripts/310.makeimage-hook.create-ubifs.fakeroot12
-rwxr-xr-xshare/sbs/scripts/320.makeimage-hook.create-rfs.fakeroot12
-rwxr-xr-xshare/sbs/scripts/330.makeimage-hook.create-ext4-tgz.fakeroot15
-rwxr-xr-xshare/sbs/scripts/420.makeimage-hook.create-ext4-parts.native54
-rwxr-xr-xshare/sbs/scripts/430.makeimage-hook.shrink-ext4-parts.native36
-rwxr-xr-xshare/sbs/scripts/440.makeimage-hook.mangle-ext4-parts.native12
-rwxr-xr-xshare/sbs/scripts/500.makeimage-hook.create-final-tars.native13
-rwxr-xr-xshare/sbs/scripts/find-missingpkgs92
-rwxr-xr-xshare/sbs/scripts/make-ignorepkg58
-rwxr-xr-xshare/sbs/scripts/pre-debootstrap7
-rwxr-xr-xshare/sbs/scripts/sbs-offline-install62
-rw-r--r--share/sbs/t/map/all-notmapped.tmpl5
-rw-r--r--share/sbs/t/map/emulate-bin.t55
-rw-r--r--share/sbs/t/map/emulate-dirs.t191
l---------share/sbs/t/map/emulate-notmapped.t1
-rw-r--r--share/sbs/t/map/slp2-basic.t78
l---------share/sbs/t/map/slp2-notmapped.t1
-rw-r--r--share/sbs/t/script/Makefile26
-rwxr-xr-xshare/sbs/t/script/run-test.sh32
-rw-r--r--share/sbs/t/script/t-testsystem-fail.part2
-rw-r--r--share/sbs/t/script/t-testsystem-pass.part2
-rw-r--r--share/sbs/t/script/template.t-start27
-rwxr-xr-xshare/sbs/wrappers/scp14
-rwxr-xr-xshare/sbs/wrappers/wget3
74 files changed, 4256 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..fc3f074
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+prefix ?= /usr/local
+
+all: build
+
+build:
+
+install: build
+ @mkdir -p "$(DESTDIR)/$(prefix)"
+ @tar c --exclude='*~' bin share/sbs | tar xvC "$(DESTDIR)/$(prefix)"
+
+clean:
diff --git a/README b/README
new file mode 100644
index 0000000..cf5797c
--- /dev/null
+++ b/README
@@ -0,0 +1,60 @@
+
+Procedure for installing and running SBS
+----------------------------------------
+
+This procedure installs both Scratchbox2 and SBS
+
+You will end up with a directory structure like this:
+
+# clones of sbs and scratchbox2 repositories
+# scratchbox2 repo is cloned automatically by the install script
+git/
+ qemu
+ sbs
+ scratchbox2
+
+# exectuables (created by install script)
+sbs-install/bin
+
+# sbs data directories (created by sbs script)
+~/.scratchbox2
+sbs/
+
+Make sure that http://127.0.0.1/apt is not behind a proxy.
+Proxies can cause the sbs script to fail.
+
+
+Setup SBS (takes about 5 minutes):
+
+1. git config --global user.email "your_id@your_company.com"
+2. mkdir git ; cd git
+3. sudo aptitude install debootstrap
+4. git clone git://112.106.1.251/tools/sbs
+5. cd sbs ; ./install-sbs
+
+
+Setting up SBS environment (takes about 20 minutes):
+
+1. ~/sbs-install/bin/sbs -A i386 -c
+
+
+Building a module with SBS:
+
+1. git clone git://112.106.1.251/pkgs/e/ecore.git
+2. cd ecore
+3. ~/sbs-install/bin/sbs -e dpkg-buildpackage -b # will fail because of missing build deps
+4. ~/sbs-install/bin/sbs -et apt-get install ... # install list of build dependencies
+5. ~/sbs-install/bin/sbs -e dpkg-buildpackage -b
+
+
+Updating SBS environment:
+
+1. ~/sbs-install/bin/sbs -et apt-get update
+2. ~/sbs-install/bin/sbs -et apt-get upgrade
+
+
+Rebuild SBS environment (takes around 30 minutes)
+
+1. ~/sbs-install/bin/sbs -k #then type "YES"
+2. ~/sbs-install/bin/sbs -c
+
diff --git a/README.quickstart b/README.quickstart
new file mode 100644
index 0000000..9ec6918
--- /dev/null
+++ b/README.quickstart
@@ -0,0 +1,96 @@
+New Build System: Quickstart
+============================
+
+This is (very) brief introduction to new build system based on
+scratchbox2 path mapping application.
+
+"sbs" is the script responsible for setting environment up,
+compiling packages and creating binary images. Note that this script
+can be run only as normal user, not root.
+
+Creating environment from scratch
+=================================
+
+To create environment one needs to meet following requirements:
+
+ - recent Debian/Ubuntu system for i386/x86_64 architecture
+ - scratchbox2 version 1:2.1-0slp2+s1 (provided by our team)
+ - debootstrap, qemu-arm
+ - access to Debian and Tizen's mirrors
+
+By default packages are installed from local repositories, if needed
+one could change following:
+
+ - SBS_TOOLS_MIRROR - http/ftp mirror to Debian squeeze repository
+ for i386/x86_64. Change by e.g.:
+
+ export SBS_TOOLS_MIRROR=http://ftp.uk.debian.org/debian
+
+ - SBS_TARGET_MIRROR - http/ftp mirror to Tizen's repository of
+ ARM packages. You might need to change it to http://127.0.0.1/apt
+
+ - SBS_CROSS_MIRROR - http/ftp mirror to Tizen's repository of
+ cross-compilers and related tools. You might need to change it to
+ http://127.0.0.1/apt
+
+To create environment please type (as user, not as root!):
+
+ sbs --create
+
+This will try to setup complete build environment at $HOME/sbs.
+To change default directory please do:
+
+ export SBS_ROOTDIR=/requested/path
+
+To completely remove environment please type:
+
+ sbs --kill
+
+
+Building packages
+=================
+
+With pre-setup environment following operations should succeed.
+
+ 1. To compile Debian package PKG given prepared sources please run:
+
+ sbs --build PKG.dsc
+
+ This will try to build package using (preliminary) automatic
+ builder. Missing dependencies will be satisfied and installed
+ if possible.
+
+ You can download appropriate sources for given PKG by running:
+
+ apt-get source PKG
+
+
+ 2. To enter build environment please run:
+
+ sbs --execute
+
+ This will login you into environment where you can build
+ packages. Typical commands like ./configure, make, gcc,
+ etc. should all work as in normal environment (but produce
+ ARM-architecture binaries).
+
+ To satisfy missing build dependencies you need to install
+ required packages. Please run:
+
+ sbs --execute-target apt-get install PKG1 PKG2
+
+ to install missing packages for ARM.
+
+ You *CAN'T* install packages in mode designed for building
+ packages. For full discussion please see provided usage
+ documentation (sbs-usage.ppt).
+
+
+Following doesn't require setup environment but working package
+repositories:
+
+ N. To create binary filesystem/kernel image for Aquila board
+ please type:
+
+ sbs --makeimage TESTIMAGE --board aquila
+
diff --git a/bin/make-ext4 b/bin/make-ext4
new file mode 100755
index 0000000..2539529
--- /dev/null
+++ b/bin/make-ext4
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -x
+set -e
+
+PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
+
+INFILE="$1"
+SIZE="$2"
+EXT4_BLOCK_SIZE="$3"
+
+# As we will write one byte, we have to subtract it from total size
+SEEK=$(($SIZE - 1))
+
+if [ $# -ne 3 ]; then
+ echo "usage: $0 FILESYSTEM_TGZ FILESYSTEM_SIZE EXT4_BLOCK_SIZE" >&2
+ exit 1
+fi
+
+# Perform sanity checks before we install cleanup handler
+if test -z "$SUDO_UID"; then
+ echo "$0: error: use sudo to run this script" >&2
+ exit 1
+fi
+
+if test "$SUDO_UID" -ne "`stat -c '%u' \"$INFILE\" 2>/dev/null`"; then
+ echo "$0: error: you aren't owner of input file $INFILE" >&2
+ exit 1
+fi
+
+cleanup()
+{
+ if [ $? -ne 0 ]; then
+ test "$OUTFILE" -a -f "$OUTFILE" && rm -f "$OUTFILE" >&2
+ fi
+
+ if test "$MNT"; then
+ if mountpoint -q "$MNT"; then
+ umount "$MNT" >&2
+ fi
+ rmdir "$MNT" >&2 || true
+ fi
+}
+trap cleanup 0
+trap cleanup 1
+trap cleanup 15
+
+MNT="`mktemp -d /tmp/make-ext4.mountpoint.XXXXXX 2>/dev/null`"
+OUTFILE="`mktemp /tmp/make-ext4.filesystem.XXXXXX 2>/dev/null`"
+
+
+# Create sparse file for filesystem
+dd if=/dev/zero of="$OUTFILE" bs=1 seek="$SEEK" count=1 >&2
+mkfs.ext4 -O '^huge_file' -F "$OUTFILE" -b "$EXT4_BLOCK_SIZE" >&2
+
+mount -o loop "$OUTFILE" "$MNT" >&2
+tar xlpsfC "$INFILE" "$MNT" >&2
+umount "$MNT" >&2
+
+# Allow user to do what he wants with newly created file
+chown "$SUDO_UID:$SUDO_GID" "$OUTFILE" >&2
+echo "$OUTFILE"
diff --git a/bin/sbs b/bin/sbs
new file mode 100755
index 0000000..4c9682d
--- /dev/null
+++ b/bin/sbs
@@ -0,0 +1,1957 @@
+#!/bin/sh
+
+# Copyright (C) 2010 Samsung Electronics, Inc.
+# All rights reserved.
+#
+# This software is a confidential and proprietary information
+# of Samsung Electronics, Inc. ("Confidential Information"). You
+# shall not disclose such Confidential Information and shall use
+# it only in accordance with the terms of the license agreement
+# you entered into with Samsung Electronics.
+#
+# sbs: cross-compilation setup tool
+#
+# OVERVIEW
+#
+# This script provides necessary automation to setup and manage
+# complete cross-compilation environment based on scratchbox2.
+#
+# It was designed mainly to automate process of creating build
+# environment consisting of:
+#
+# (a) native architecture distribution (Debian) with
+# cross-compilers for target (ARM), and
+#
+# (b) target distribution (SLP2) with libraries, etc. files
+# required for compilation.
+#
+# These two are combined together to provide single view on
+# filesystem, where tools required to be fast (read: compilers,
+# linkers) are executed from native binaries and
+# architecture-dependent files (read: libraries) are taken from
+# target distribution.
+#
+# Creating flexible filesystem views are possible with scratchbox2,
+# which allows one to freely map any path to another. Thus, it's
+# possible to map e.g.
+#
+# path as accessed in environment | real path
+# ---------------------------------+---------------------------
+# /usr/bin/gcc | tools_root/usr/bin/arm-gcc
+# /usr/bin/ld | tools_root/usr/bin/arm-ld
+# /usr/lib/gcc | tools_root/usr/lib/gcc
+# /usr/lib | target_root/usr/lib
+#
+# This simplified map shows that's possible to take gcc and ld from
+# native distribution (tools_root) and all libraries /usr/lib
+# (except /usr/lib/gcc needed by cross-compilers) from target
+# distribution.
+#
+# While simplifying creation of such environment was tools' primary
+# goal, utility in current form allows one to perform various
+# management tasks (install, remove packages), automatically build
+# packages and even create binary kernel/filesystem images from
+# selected repositories.
+#
+#
+# REQUIREMENTS
+#
+# To use this tool it's required to meet following requirements:
+#
+# - x86/amd64 debian/ubuntu system,
+# - qemu-arm (>= 0.14) + with preloader patch
+# - scratchbox2 (>= 1:2.1-rc1-0slp2+6) - this *MUST* be
+# SPRC-provided version.
+#
+# Variables: $SBS_ROOTDIR
+#
+# Few operations might have additional requirements:
+#
+# I. BUILD ENVIRONMENT MANAGEMENT
+#
+# (1) Creating build environment
+#
+# - debootstrap (>= 1.0.20),
+# - access to Debian package repositories for x86/amd64
+# architecture,
+# - access to SPRC-provided package repositories for x86/amd64
+# (cross-compilers) and ARM/i386 (SLP2 distribution).
+#
+# Variables: $SBS_TOOLS_SUITE, $SBS_TOOLS_MIRROR,
+# $SBS_CROSS_SUITE, $SBS_CROSS_MIRROR,
+# $SBS_TARGET_SUITE, $SBS_TARGET_MIRROR
+#
+# Successful creation of build environment is prerequisite for
+# points 2-5 and whole section II.
+#
+# (2) Environment maintenance - target (--execute-target)
+#
+# (3) Environment maintenance - tools (--execute-tools)
+#
+# (4) Mapping correctness tests (--selftest)
+#
+# (5) Environment deletion (--kill)
+#
+#
+# II. BUILD ENVIRONMENT USAGE
+#
+# (a) Executing commands in build environment (--execute)
+#
+# (b) Automatic package builder (--build)
+#
+# - access to SPRC-provided package repositories for ARM (SLP2
+# distribution). Missing dependencies will be automatically
+# installed from this repository.
+#
+# Variables: $SBS_TARGET_SUITE, $SBS_TARGET_MIRROR
+#
+#
+# III. BINARY IMAGE CREATION
+#
+# - access to SPRC-provided package repositories for ARM (SLP2
+# distribution). Image will be created from packages that are
+# installable from this repository.
+#
+# Variables: $SBS_TARGET_SUITE, $SBS_TARGET_MIRROR
+#
+#
+# DIRECTORY LAYOUT
+#
+# All operations on build environment are relative to path selected
+# by SBS_ROOTDIR variable (by default $HOME/sbs). One can
+# change it to operate on different, separate environments.
+#
+# Below SBS_ROOTDIR following directory structure can be found:
+#
+# - tools/ - directory containing native architecture distribution
+# (i386/amd64) of Debian squeeze along with SPRC-provided
+# cross-compilers and tools.
+#
+# - target/ - directory containing target architecture
+# distribution (armel).
+#
+# - .state/ - directory used to keep track of environment state.
+#
+#
+# AUTHORS
+#
+# Written by:
+# Karol Lewandowski <k.lewandowsk@samsung.com>
+# Rafał Krypa <r.krypa@samsung.com>
+# Tomasz Stanisławski <t.stanislaws@samsung.com>
+#
+# This utility originates from Samsung Poland R&D Center (SPRC).
+
+set -e
+
+## Public variables
+
+# Official program name. This will probably change again some day...
+_M="sbs"
+
+# Build environment location (by default $HOME/sbs)
+_ROOTDIR="${SBS_ROOTDIR:-$HOME/$_M}"
+
+## Definitions of package sources
+
+# load local configuration
+[ ! -f "$_ROOTDIR/.sbs-config" ] || . "$_ROOTDIR/.sbs-config"
+
+# The server with all required APT repositories
+_APT_SERVER="${SBS_APT_SERVER:-112.106.1.254}"
+
+# Native Debian distribution that will be installed at $SBS_ROOTDIR/tools
+_TOOLS_SUITE="${SBS_TOOLS_SUITE:-squeeze}"
+
+# Additional, SPRC-provided packages that go to $SBS_ROOTDIR/tools - namely
+# cross-compilers and related utilities
+_CROSS_SUITE="${SBS_CROSS_SUITE:-slp2-tools}"
+
+# SLP2 (target/ARM) distribution that will be installed to
+# $SBS_ROOTDIR/target and from which binary images will be built
+_TARGET_SUITE="${SBS_TARGET_SUITE:-slp2-target}"
+
+# Default architecture for execute, execute-tools, build, makeimage and selftest commands
+_arch="${SBS_ARCH:-armel}"
+
+# Keep temporary files if following variable is set
+_NO_CLEAN="${SBS_NO_CLEAN:-}"
+
+# Default temporary directory location
+_TMPDIR="${TMPDIR:-/tmp}"
+
+# CPU transparency program for native architecture
+# This is used to run statically linked native binaries.
+_CPUTRANSP_NATIVE="${SBS_CPUTRANSP_NATIVE:-qemu-i386}"
+
+### NOTE ###
+# In implementation section (below) we usually refer to variables
+# _without_ leading "SBS", i.e. we use $_ROOTDIR, not $SBS_ROOTDIR.
+
+
+## Private variables
+_STATE_DIR="$_ROOTDIR/.state"
+
+# List of packages to be installed into tools and target environments
+_TOOLS_PKGS="${SBS_TOOLS_PKGS:-sbs-build-essential-tools sbs-build-tools}"
+_TARGET_PKGS="${SBS_TARGET_PKGS:-sbs-build-essential-target}"
+
+# XXX Workaround broken proxy at SPRC
+# avoid trying to proxy localhost
+no_proxy="127.0.0.1,$no_proxy"
+export no_proxy
+__apt_opts="-oAPT::Get::AllowUnauthenticated=true -oAPT::Install-Recommends=false -oAcquire::http::No-Cache=true -oAcquire::http::BrokenProxy=true -V -q"
+_apt="apt-get $__apt_opts"
+
+# Default scratchbox2 map for --build and --execute commands.
+# NOTE This requires SPRC-provided scratchbox2 package.
+_TARGET_SB2_MAP='slp2'
+
+# Short name of this script
+N="`basename \"$0\"`"
+
+# List of files and directories to delete upon script's termination.
+# See cleanup().
+_CLEANUP_LIST="`mktemp \"$_TMPDIR/${_M}_cleanuplist.XXXXXX\"`"
+
+# cleanup: exit handler
+#
+# PARAMETERS
+# <none>
+#
+# DESCRIPTION
+# This function removes all temporary files and directories used
+# during script's lifetime. In order for this to happen particular
+# entry must be registered via adding line to file pointed via
+# $_CLEANUP_LIST variable.
+#
+# $_CLEANUP_LIST file has following syntax:
+#
+# "T ENTRY"
+#
+# where:
+#
+# - T - denotes entry type, it might be one of:
+# "d" | "D" for directories,
+# "f" | "F" for files,
+# "s" | "S" for scratchbox2 profile name.
+#
+# - "ENTRY" - pathname is expected for all types except "s". In
+# last case ("s" - scratchbox2 profile name) use e.g. NAME to
+# delete $HOME/.scratchbox2/NAME directory.
+#
+# Examples:
+# echo "f /tmp/tmp.42" >> $_CLEANUP_LIST # delete /tmp/tmp.42 file
+# echo "d /p/tools" >> $_CLEANUP_LIST # delete /p/tools dir
+# echo "s xarm" >> $_CLEANUP_LIST # delete $HOME/.scratchbox2/xarm dir
+#
+# SIDE EFFECTS
+# Files and directories defined in $_CLEANUP_LIST are deleted.
+cleanup()
+{
+ ret=$? # We can't even define "local ret" here as this would change $?...
+
+ [ $ret -ne 0 ] && echo "$CE$N: failed to perform requested operation$CN"
+
+ if [ -n "$_NO_CLEAN" ]
+ then
+ debug "Won't delete temporary files listed in $_CLEANUP_LIST"
+ else
+
+ [ -s "$_CLEANUP_LIST" ] && while read type entry
+ do
+ [ -z "$entry" ] && continue
+
+ case $type in
+ d|D) logexec rm -rf "$entry";;
+ f|F) logexec rm -f "$entry";;
+ s|S) logexec rm -rf "$HOME/.scratchbox2/$entry";;
+ *) debug "Unknown type ($type). Ignoring.";;
+ esac
+ done < "$_CLEANUP_LIST"
+ logexec rm -f "$_CLEANUP_LIST"
+ fi
+
+ trap : 0
+ exit $ret
+}
+
+# die: print message to stderr and exit with error code
+#
+# PARAMETERS
+# $1 $2 ... - message to be printed
+die()
+{
+ echo "$CE$N: fatal error: $*$CN" >&2
+ exit 1
+}
+
+# notice: print arguments to stderr if verbosity level >= 1
+#
+# PARAMETERS
+# $1 $2 ... - message to be printed
+notice()
+{
+ [ "$_verbose" -lt 1 ] || echo "$CI$N: $*$CN" >&2
+}
+
+# debug: print arguments to stderr if verbosity level >= 2
+#
+# PARAMETERS
+# $1 $2 ... - message to be printed
+debug()
+{
+ [ "$_verbose" -lt 2 ] || notice "$*"
+}
+
+# logexec: execute command and log invocation to stderr
+#
+# PARAMETERS
+# $1 $2 ... - command line to be run
+#
+# DESCRIPTION
+# This function executes command and logs full command line to stderr
+# (verbosity level needs to be >= 2).
+#
+# NOTE It's not possible to properly exec function that make use of
+# shell redirection without manually using subshells.
+logexec()
+{
+ [ "$_verbose" -lt 2 ] || echo "$CX$N: [exec] $*$CN" >&2
+ "$@"
+}
+
+# usage: print usage information
+#
+# PARAMETERS
+# <none>
+usage()
+{
+ cat <<EOF
+$N: {COMMAND} [ARGS..]
+Commands:
+ -c|--create Create build environment at $_ROOTDIR (\$SBS_ROOTDIR)
+ -k|--kill Completely remove build environment $_ROOTDIR (\$SBS_ROOTDIR)
+ --reset Reset environment to last saved state (last -c/-u invocation)
+ -u|--upgrade [PKG...] Upgrade given PKGs or whole distribution for selected architecure
+ Additionally, save target distribution state to file
+ -et|--execute-target [CMD..] Execute CMD.. within SLP *maintenance* environment (install pkgs here)
+ -eo|--execute-tools [CMD..] Execute CMD.. within Debian *maintenance* (install native Debian tools here)
+
+ -e|--execute [CMD..] Execute CMD.. within SLP *build* environment
+ -d|--depends Install build depeneded on packages (as described in debian/control)
+ for source package located in current directory
+ -b|--build [DSC_FILE] Try to build package in current directory or in DSC_FILE if it's provided
+ the build will be done in clean environment if DSC_FILE is given
+ --clean-build [DSC_FILE] Similar to --build, but always does the build in clean environment
+
+ -s|--source PKG Download sources without history from git for binary package PKG
+ --clone PKG Like --source, but fetches full history instead of latest revision
+
+ -i|--makeimage NAME Create binary filesystem image NAME (use with --board);
+ this option doesn't require configured environment at \$SBS_ROOTDIR
+ --selftest [NAME] Run tests checking correctness of scratchbox's mappings for NAME
+
+ -h|--help Show this help screen
+
+Options:
+ -A|--arch ARCH Change target architecture to ARCH (takes precedence over \$SBS_ARCH);
+ applicable for {-c|-r|-b|-u|-i|-e*} commands. Defaults to $_arch
+ -v|--verbose [0|1|2] Set verbosity level - 0: errors only, 1: warnings, 2: debug output
+ -B|--board BOARD Set target board type to BOARD for makeimage
+
+NOTES:
+ - Only one command can be specified at once
+ - There can be no options after -u and -e* commands
+ - Shell is launched if CMD.. is omitted for -e* commands
+EOF
+}
+
+# get_single_id: get and check the user's single ID
+#
+# PARAMETERS
+# <none>
+#
+# DESCRIPTION
+# Get the user's single ID (read from file or ask for it) and check if
+# he/she is able to login to the APT server non-interactively.
+# This is required to download Debian packages from the server by
+# debootstrap and apt.
+# The function dies if user supplied single ID isn't working.
+get_single_id()
+{
+ unset _SINGLE_ID
+ local email
+ if ! email="`git config --global --get user.email`" ||
+ ! echo $email | grep -q '.com$'
+ then
+ die "Please setup up your email address first using:
+ git config --global user.email your_id@your_company.com"
+ fi
+ _SINGLE_ID="`echo \"$email\" | cut -d@ -f1`"
+
+ if ! ssh -n -oNumberOfPasswordPrompts=0 -q -l"$_SINGLE_ID" "$_APT_SERVER" /bin/true >/dev/null 2>&1
+ then
+ notice "Checking for non-interactive SSH access for $_SINGLE_ID@$_APT_SERVER failed!"
+ notice "."
+ notice "You require non-interactive SSH access to the package server to use SBS"
+ notice "(this means logging in without need to enter a password)."
+ notice "It isn't working for you, which could mean:"
+ notice "- You entered incorrect single ID"
+ notice "- You don't have account on the server"
+ notice "- A firewall is blocking you from the server"
+ notice "- The server is down at the moment"
+ notice "- You haven't setup public key authentication"
+ notice " (see http://www.tizendev.org)"
+ notice "- You are using public key authentication, but it has a password and you don't"
+ notice " have ssh-agent configured"
+ notice ""
+ notice "If you don't know how to fix this, please contact your administrator."
+ die "Unable to proceed without proper acces to the package server."
+ fi
+}
+
+# get_apt_mirrors: construct variables for APT mirrors
+#
+# PARAMETERS
+# <none>
+#
+# DESCRIPTION
+# This function sets value for variables pointing at the APT mirrors.
+# It is done based on the value of some other variables.
+get_apt_mirrors()
+{
+ if [ -z "$SBS_TOOLS_MIRROR" -o -z "$SBS_CROSS_MIRROR" -o -z "$SBS_TARGET_MIRROR" ]
+ then
+ # check for local mirror
+ if [ -d "$_REPO_DIR" ]
+ then
+ SBS_TOOLS_MIRROR="file://$_REPO_DIR/mirror"
+ SBS_CROSS_MIRROR="file://$_REPO_DIR/apt.sbs"
+ SBS_TARGET_MIRROR="file://$_REPO_DIR/apt.sbs"
+# else
+# get_single_id
+ fi
+ fi
+
+# _TOOLS_MIRROR="${SBS_TOOLS_MIRROR:-ssh://$_SINGLE_ID@$_APT_SERVER/home/tizen/mirror}"
+ _TOOLS_MIRROR="${SBS_TOOLS_MIRROR:-http://$_APT_SERVER/home/tizen/mirror}"
+# _CROSS_MIRROR="${SBS_CROSS_MIRROR:-ssh://$_SINGLE_ID@$_APT_SERVER/home/tizen/apt.sbs}"
+ _CROSS_MIRROR="${SBS_CROSS_MIRROR:-http://$_APT_SERVER/home/tizen/apt.sbs}"
+# _TARGET_MIRROR="${SBS_TARGET_MIRROR:-ssh://$_SINGLE_ID@$_APT_SERVER/home/tizen/apt.sbs}"
+ _TARGET_MIRROR="${SBS_TARGET_MIRROR:-http://$_APT_SERVER/home/tizen/apt.sbs}"
+}
+
+# check_sanity: check if we have appropriate rights to perform actions
+#
+# PARAMETERS
+# <none>
+#
+# DESCRIPTION
+# This function checks if any of following conditions is true and
+# dies if that's the case:
+#
+# (1) user logged as root
+#
+# (2) command is run under scratchbox2, fakeroot or fakechroot
+check_sanity()
+{
+ if [ `id -u` -eq 0 -o -n "$SBOX_SESSION_DIR" -o -n "$FAKEROOTKEY" -o -n "$FAKECHROOT" ]
+ then
+ die "You mustn't be root. Also, you can't run this script under fakeroot/fakechroot/scratchbox2."
+ exit 1
+ fi
+
+ [ ! -e /proc/self/exe ] && die "Mounted proc file system is required. Try mounting it first: 'mount none /proc -tproc'."
+
+ [ -n "$LD_PRELOAD" ] && notice "warning: LD_PRELOAD set. Program might fail, I guess."
+ return 0
+}
+
+# check_env: check if environment is properly setup
+#
+# PARAMETERS
+# <none>
+#
+# VARIABLES
+# $_ROOTDIR
+#
+# DESCRIPTION
+# This function checks if environment selected by $_ROOTDIR is
+# properly created. If it's not - script is terminated with error.
+check_env()
+{
+ [ "`xget state`" = 'all-ok' ] || die "Environment not configured properly. Please run: $N --create"
+}
+
+# xget: get configuration variable
+#
+# PARAMETERS
+# $1 - architecture selector (i386,armel,tools)
+# $2 - configuration variable
+xget()
+{
+ local arch suffix suite mirror file st
+
+ arch="$2"
+
+ case "$1" in
+
+ arch)
+ # We need Debian architecture name for debootstrap and Linux one for scratchbox2.
+ # Use $3 parameter to switch between Debian and Linux arch names.
+ [ "$arch" != "tools" ] || arch=i386
+ echo -n $(dpkg-architecture -a"$arch" -q`[ "$3" = "debian" ] && echo -n DEB_HOST_ARCH || echo -n DEB_HOST_GNU_CPU` 2>/dev/null)
+ ;;
+
+ system_id)
+ [ "$arch" != "tools" ] || arch=`xget arch $arch`
+ echo -n `dpkg-architecture -a"$arch" -qDEB_HOST_GNU_TYPE 2>/dev/null`
+ ;;
+
+ compiler_path)
+ case "$arch" in
+ tools) echo -n '';;
+ i386) echo -n "`xget dir tools`/usr/bin/gcc";;
+ *) echo -n "`xget dir tools`/usr/bin/`xget system_id $arch`-gcc";;
+ esac
+ ;;
+
+ archive_path)
+ echo -n "`xget dir $arch`.tgz"
+ ;;
+
+ cpu_emulation)
+ case "$arch" in
+ tools|i386) echo -n '';;
+ *) echo -n "`which qemu-\`xget arch $arch\``";;
+ esac
+ ;;
+
+ dir)
+ case "$arch" in
+ tools) echo -n "$_ROOTDIR/tools";;
+ *) echo -n "$_ROOTDIR/target-${arch}";;
+ esac
+ ;;
+
+ id)
+ suffix="`echo $_ROOTDIR | sed -e 's@/*$@@' -e 's@[ /]@_@g'`"
+ case "$arch" in
+ tools) echo -n "${_M}-tools${suffix}";;
+ *) echo -n "${_M}-${arch}${suffix}";;
+ esac
+ ;;
+
+ suite)
+ case "$arch" in
+ tools) [ "$3" = "secondary" ] && echo -n "$_TOOLS_SUITE" || echo -n "$_CROSS_SUITE";;
+ *) echo -n "$_TARGET_SUITE";;
+ esac
+ ;;
+
+ mirror)
+ case "$arch" in
+ tools) [ "$3" = "secondary" ] && echo -n "$_TOOLS_MIRROR" || echo -n "$_CROSS_MIRROR/$arch";;
+ *) echo -n "$_TARGET_MIRROR/$arch";;
+ esac
+ ;;
+
+ # Packages to include during debootstrap's first stage
+ pkgincl)
+ case "$arch" in
+ tools) echo -n "libsb2,sbs-archive-keyring";;
+ # We have to explicitly select 'busybox-symlinks-adduser' because it
+ # satisfies 'adduser' dependency for 'openssh-client' and debootstrap
+ # doesn't look at Provides fields of packages.
+ i386) echo -n "libsb2,fakeroot,openssh-client,busybox-symlinks-adduser,sbs-archive-keyring";;
+ armel) echo -n "openssh-client,busybox-symlinks-adduser,sbs-archive-keyring";;
+
+ # Used by makeimage
+ board-*) echo -n "`xget pkgincl armel`";;
+ esac
+ ;;
+
+ pkglist)
+ case "$arch" in
+ tools) echo -n "$_TOOLS_PKGS";;
+ *) echo -n "$_TARGET_PKGS";;
+ esac
+ ;;
+
+ map)
+ case "$arch" in
+ tools) echo -n "emulate";;
+ *) echo -n "$_TARGET_SB2_MAP";;
+ esac
+ ;;
+
+ sources_list)
+ suite="`xget suite $arch`"
+ mirror="`xget mirror $arch`"
+
+ echo "deb $mirror $suite main contrib non-free"
+
+ if [ "$arch" = "tools" ]; then
+ echo "deb `xget mirror $arch secondary` `xget suite $arch secondary` main contrib non-free"
+ fi
+ ;;
+
+ state)
+ # 2 - alternative state file
+ [ "$2" ] && file="$2" || file=state
+ file="${_STATE_DIR}/$file"
+
+ test -d "$_STATE_DIR" -a -f "$file" || { echo -n "invalid"; return; }
+ st="`cat \"$file\" | sed -e 1q`"
+ [ ! "$st" ] && st="invalid"
+ echo -n "$st"
+
+ debug "Got state: $file/$st"
+ ;;
+
+ *) die "invalid option: $*"; # XXX
+ esac
+}
+
+xset()
+{
+ local file
+
+ case "$1" in
+
+ state)
+ # 2 - state to be set
+ # 3 - alternative state file
+ [ "$3" ] && file="$3" || file=state
+ file="${_STATE_DIR}/$file"
+
+ test -d "$_STATE_DIR" || mkdir -p "$_STATE_DIR" || die "Can't create state directory. Aborting."
+ ( echo "$2"; test -f "$file" && cat "$file" || true ) >"${file}.new"
+ mv "${file}.new" "$file"
+
+ debug "Set state: $file/$2"
+ ;;
+
+ *) die "invalid option: $*";; # XXX
+ esac
+}
+
+cmd()
+{
+ local arch map tid pwd acsrc acdst
+
+ arch="$1"
+ shift
+
+ [ "$_cmd_id" ] && tid="-t $_cmd_id" || tid="-t `xget id $arch`"
+ [ "$arch" != "tools" -a "$_cmd_map" ] && map="-m $_cmd_map" || map="-m emulate"
+
+ # XXX HACK
+ if [ "$arch" != "tools" ]; then
+ acsrc="`xget dir tools`"/usr/share/aclocal
+ [ ! -z "$_cmd_targetdir" ] && acdst="$_cmd_targetdir"/usr/share/aclocal || acdst="`xget dir $arch`"/usr/share/aclocal
+
+ mkdir -p "$acdst"
+
+ if [ -d "$acdst" -a x"`echo $acdst/*`" != x"$acdst/*" ]; then
+ debug "hack: checking for stray aclocal symlinks in target"
+ ( set -e && for i in "$acdst"/*; do test ! -L $i -o -e $i || logexec rm $i; done )
+ fi
+
+ if [ -d "$acsrc" -a x"`echo $acsrc/*`" != x"$acsrc/*" ]; then
+ debug "hack: linking missing aclocal files from tools to target"
+ ( set -e && logexec cd "$acdst" && for i in "$acsrc"/*; do test -e "`basename $i`" || logexec ln -sf "$i" .; done )
+ fi
+ fi
+
+ # make pkg-config search tools dir in addition to target
+ export PKG_CONFIG_PATH="`xget dir $arch`/usr/lib/pkgconfig:`xget dir $arch`/usr/share/pkgconfig:`xget dir tools`/usr/share/pkgconfig"
+
+ logexec sb2 -R $tid $map -- "$@"
+}
+
+# setup_sb2_envvars:
+# $1 - Scratchbox 2 environment id
+# $2 - Directory to take environment from (optional)
+setup_sb2_envvars()
+{
+ local sb2_id env_src env_dst
+ sb2_id="$1"
+ env_src="$2"
+ [ "$env_src" = "" ] && env_src="$_SHARE_DIR/default_env"
+ env_dst="$HOME/.scratchbox2/$id/sb2.config.d/env_vars"
+ if [ ! -e "$env_dst" -a -d "$env_src" ]; then
+ logexec mkdir -p "`dirname \"$env_dst\"`"
+ logexec cp -a "$env_src" "$env_dst"
+ fi
+}
+
+# setup_target:
+# $1 - architecture - tools or i386/armel
+setup_target()
+{
+ local arch compiler emul dir id suite mirror suite2 mirror2 pkglist
+ local srclist rawarch debarch pkgincl sysid script toolsopt sf state origin
+ local map tmp
+
+ arch="$1"
+ compiler="`xget compiler_path $arch`"
+ emul="`xget cpu_emulation $arch`"
+ [ "$emul" ] && emul="-c \"$emul\""
+ emul_native="`which \"$_CPUTRANSP_NATIVE\"`"
+ [ "$emul_native" ] && emul_native="-p \"$emul_native\""
+ dir="`xget dir $arch`"
+ id="`xget id $arch`"
+ suite="`xget suite $arch`"
+ mirror="`xget mirror $arch`"
+ suite2="`xget suite $arch secondary`"
+ mirror2="`xget mirror $arch secondary`"
+ pkglist="`xget pkglist $arch`"
+ srclist="`xget sources_list $arch`"
+ rawarch="`xget arch $arch`"
+ debarch="`xget arch $arch debian`"
+ pkgincl="`xget pkgincl $arch`"
+ [ "$pkgincl" ] && pkgincl="--include=$pkgincl"
+ map="`xget map $arch`"
+
+ # Bootstrap Debian-like distribution using generic debootstrap script
+ #
+ # NOTE Distribution will be (de)bootstrapped using $_TOOLS_SUITE
+ # script. By using universally available suite (squeeze by default)
+ # to setup our's (slp2-target) we trying avoid debian/ubuntu-related
+ # debootstrap compatibility problems.
+ #
+ # Use system-provided debootstrap script because both debian and
+ # ubuntu provide "squeeze" script compatible with their version of
+ # debootstrap AND capable of setting up our suite (slp2-target).
+ script="$_DEBOOTSTRAP_SCRIPT"
+ toolsopt="-t \"`xget dir tools`\""
+
+ sf="state_$arch" # state file
+ _cmd_map='emulate'
+ while : ; do
+ state="`xget state state_$arch`"
+
+ case "$state" in
+ invalid)
+ logexec mkdir -p "$dir"
+ logexec cd "$dir"
+ xset state init-ok $sf
+ ;;
+
+ init-ok)
+ logexec cd "$dir"
+ export PATH="$_SHARE_DIR/wrappers:$PATH"
+ DEBOOTSTRAP_DIR="$_DEBOOTSTRAP_DIR"
+ export DEBOOTSTRAP_DIR
+ if [ "$arch" = "tools" ]
+ then
+ # !! Native architecture - perform special processing to
+ # !! workaround dynamic linker problems (/lib/ld-linux.so*)
+ # !! This is needed as we use mixed repositories (Debian's and ours).
+
+ # Bootstrap native architecture distribution (Debian squeeze by default) in tools
+ logexec fakeroot debootstrap $_DEBOOTSTRAP_OPTS --arch="$debarch" --foreign --variant=minbase --include=fakeroot,openssh-client "$suite2" "$dir" "$mirror2" "$script"
+
+ # Poor man's multistrap - we need to replace several packages
+ # with ours before proceeding. It is done in the following steps:
+ # - first stage debootstrap of $_CROSS_SUITE to directory "tools.tmp" directory,
+ # include libsb2 because it will be needed in real "tools" dir
+ # - remove from "tools" all files that were extracted from packages present also
+ # in "tools.tmp"
+ # - copy debs from "tools.tmp" to "tools", change paths in "tools/debootstrap/debpaths"
+ # - extract fakeroot package in "tools" because debootstrap first stage
+ # doesn't do it and Scratchbox 2 will need libfakeroot right away
+ logexec fakeroot debootstrap $_DEBOOTSTRAP_OPTS --arch="$debarch" --foreign --variant=minbase --exclude=apt $pkgincl "$suite" "${dir}.tmp" "$mirror" "$script"
+ logexec sh -c "cat \"$dir\".tmp/debootstrap/debpaths | while read p f; do grep \"^\$p \" debootstrap/debpaths | sed 's/.* /./' | xargs -r dpkg --fsys-tarfile | tar t 2>/dev/null | grep -v '/\$' | xargs rm -f; done"
+ logexec sh -c "cat \"$dir\".tmp/debootstrap/debpaths | while read p f; do echo \"-e 's|^\$p .*||'\";done | xargs sed -i debootstrap/debpaths"
+ logexec sh -c "cat \"$dir\".tmp/debootstrap/debpaths >> debootstrap/debpaths"
+ logexec sh -c "cat debootstrap/required >> \"$dir\".tmp/debootstrap/required"
+ logexec sh -c "cat \"$dir\".tmp/debootstrap/required | tr ' ' '\n' | sort | uniq | xargs echo >debootstrap/required"
+ logexec sh -c "cat debootstrap/base >> \"$dir\".tmp/debootstrap/base"
+ logexec sh -c "cat \"$dir\".tmp/debootstrap/base | tr ' ' '\n' | sort | uniq | xargs echo >debootstrap/base"
+ logexec sh -c "cp -a \"$dir\".tmp/var/cache/apt/archives/* var/cache/apt/archives/"
+ logexec sh -c "cat \"$dir\".tmp/debootstrap/debpaths | while read p f; do dpkg -x .\"\$f\" .;done"
+ logexec sh -c "dpkg -x var/cache/apt/archives/fakeroot_* ."
+ logexec rm -rf "$dir".tmp
+ else
+ logexec fakeroot debootstrap $_DEBOOTSTRAP_OPTS --arch="$debarch" --foreign --variant=minbase $pkgincl "$suite" "$dir" "$mirror" "$script"
+ fi
+ unset DEBOOTSTRAP_DIR
+ logexec ln -sf $HOME/.ssh $dir/root/
+ xset state debootstrap-ok $sf
+ ;;
+
+ debootstrap-ok)
+ logexec cd "$dir"
+ logexec sb2-init -N -n -m "$map" $emul $emul_native $toolsopt -A "$rawarch" "$id" "$compiler"
+ setup_sb2_envvars "$id"
+ xset state scratchbox2-ok $sf
+ ;;
+
+ scratchbox2-ok)
+ # XXX Workaround bugs present in debootstrap scripts
+ logexec mkdir -p "$dir/etc" "$dir/var/cache/ldconfig"
+ logexec touch "$dir/etc/fstab" "$dir/etc/ld.so.cache"
+ xset state workarounds-ok $sf
+ ;;
+
+ workarounds-ok)
+ logexec cd "$dir"
+ logexec sh -c "echo scratchbox >'$dir/debootstrap/variant'"
+ # Work around debootstrap creation of device nodes
+ logexec sh -c "tar czfT $dir/debootstrap/devices.tar.gz /dev/null"
+ cmd "$arch" ./debootstrap/debootstrap --second-stage
+ xset state second-stage-ok $sf
+ ;;
+
+ second-stage-ok)
+ logexec cd "$dir"
+ # Install basic set of packages into tools environment
+ logexec sh -c "echo \"$srclist\" >'$dir/etc/apt/sources.list'"
+ # Prefer custom packages even if these have lower version number
+ # Note: We use "origin" tag as it's more likely to work than "release"
+ origin="`echo $mirror | sed -e 's!.*://\([^:/]\+\).*!\1!g'`" # get host name from URI
+ if [ "$arch" = "tools" ]; then
+ cat >"$dir/etc/apt/preferences.d/slp" <<EOF
+Package: *
+Pin: release n=$suite2
+Pin-Priority: 400
+
+Package: *
+Pin: origin $origin
+Pin-Priority: 1500
+EOF
+ else
+ logexec sh -c "printf 'Package: *\nPin: origin $origin\nPin-Priority: 1500\n' >'$dir/etc/apt/preferences.d/slp'"
+ fi
+ # Update package lists taking into account new _CROSS_* entries
+ cmd "$arch" $_apt update -y
+ # XXX Fixup installation - shouldn't be needed
+ cmd "$arch" $_apt install -f -y
+ cmd "$arch" $_apt upgrade -y
+ cmd "$arch" $_apt install -y $pkglist
+ cmd "$arch" $_apt clean
+ xset state packages-ok $sf
+ ;;
+
+ packages-ok)
+ logexec cd "$dir"
+ if [ "$arch" = "tools" ]
+ then
+ # XXX Scratchbox2 workaround: Replace symlinks provided by
+ # cross-compilers with hard links.
+ #
+ # gcc family of packages provide links from arm-*-gcc-VER to
+ # /etc/alternatives/arm-*-gcc-VER. This makes scratchbox2 enter
+ # infinite path-resolution loop when accessed. Following bug probably
+ # should be solved by altering scratchbox2 slp2 map.
+ sysid="`xget system_id armel`"
+ logexec ln -f "$dir/usr/bin/${sysid}-cpp-"* "$dir/usr/bin/${sysid}-cpp"
+ logexec ln -f "$dir/usr/bin/${sysid}-gcc-"* "$dir/usr/bin/${sysid}-gcc"
+ logexec ln -f "$dir/usr/bin/${sysid}-gcc" "$dir/usr/bin/${sysid}-cc"
+ logexec ln -f "$dir/usr/bin/${sysid}-g++-"* "$dir/usr/bin/${sysid}-g++"
+ logexec ln -f "$dir/usr/bin/${sysid}-g++" "$dir/usr/bin/${sysid}-c++"
+ fi
+
+ tmp="
+APT::Get::AllowUnauthenticated \"true\";
+APT::Install-Recommends \"false\";
+APT::Get::Show-Versions \"true\";
+Acquire::http::No-Cache \"true\";
+Acquire::http::BrokenProxy \"true\";"
+ logexec sh -c "echo \"$tmp\" >'$dir/etc/apt/apt.conf.d/99slp'"
+
+ logexec mkdir -p "$dir/`dirname \"$HOME\"`"
+ logexec ln -s "$HOME" "$dir/${HOME%/}"
+
+ xset state postinst-ok $sf
+ ;;
+
+ postinst-ok)
+ # Create compressed copy of created environment. This
+ # will be used later by automatic package builder.
+ if [ "$arch" != 'tools' ]; then
+ debug "Preserving initial $arch environment"
+ logexec sh -c "cd $dir && tar czpf `xget archive_path $arch` ."
+ fi
+ xset state archive-ok $sf
+ ;;
+
+ archive-ok)
+ echo "$id" >> "$_STATE_DIR/sb2ids"
+ xset state all-ok $sf
+ ;;
+
+ all-ok)
+ debug "Successfully setup environment for $arch"
+ return
+ ;;
+
+ *) die "Internal error."
+ esac
+ done
+}
+
+# create_env: initialize build environment
+#
+# PARAMETERS
+# <none>
+#
+# VARIABLES
+# $_ROOTDIR, $_TOOLS_SUITE, $_TOOLS_MIRROR, $_CROSS_SUITE,
+# $_CROSS_MIRROR, $_TARGET_SUITE, $_TARGET_MIRROR, $_NO_CLEAN
+#
+# DESCRIPTION
+# This function setups new environment at path selected by
+# $_ROOTDIR. Following steps are preformed:
+#
+# (1) Debian distribuition for native architecture in installed at
+# $_ROOTDIR/tools. This is done with debootstrap through
+# scratchbox2.
+#
+# Packages are fetched according to $_TOOLS_{SUITE,MIRROR}
+# variables.
+#
+# (2) SPRC-provided cross-compilers and tools are installed for
+# native architecture in $_ROOTDIR/tools.
+#
+# Packages are fetched according to $_CROOS_{SUITE,MIRROR}
+# variables.
+#
+# (3) SLP2 distribution for given architecture (${ARCH}) is
+# installed in $_ROOTDIR/target-${ARCH}. This is done with
+# debootstrap wrapped by scratchbox2 (thus, no special rights
+# are required).
+#
+# Packages are fetched according to $_TARGET_{SUITE,MIRROR}
+# variables. Currently armel and i386 targets are supported.
+#
+# (4) SLP2 distribution in compressed into
+# $_ROOTDIR/target-${ARCH}.tgz for later use by autobuilder.
+#
+# NOTE
+# Native distribution installed in $_ROOTDIR/tools is called
+# "tools". Respectively, SLP2 distribution installed in
+# $_ROOTDIR/target-${ARCH} is called "target".
+#
+# If this step was interrupted, in next run this function will try
+# to continue from last checkpoint (saved state). For this
+# functionality to be available saved state is preserved between
+# script runs in $_ROOTDIR/.state
+#
+# It's possible to have multiple of build environment. By default
+# environment at $HOME/sbs is created.
+#
+# To setup environment at different path simply change
+# $SBS_ROOTDIR variable. E.g.
+#
+# $ sbs --create # create env at $HOME/sbs
+#
+# $ export SBS_ROOTDIR=/proj/build
+# $ sbs --create # create env at /proj/build ...
+# $ sbs -e dpkg-buildpackage # ... and build package here
+#
+# $ export SBS_ROOTDIR=$HOME/sbs # switch to default env ...
+# $ sbs -e dpkg-buildpackge # ... and build package here
+#
+# SIDE EFFECTS
+# This function creates new build environment at $_ROOTDIR.
+# Process is resumed from last checkpoint if it was interrupted.
+create_env()
+{
+ local arch state tstate
+
+ arch="$1"
+
+ while :
+ do
+ state="`xget state`"
+
+ # Check if we're setting up environment for consecutive target architecture.
+ # That mean we should re-run setup_target for new $arch.
+ tstate="`xget state state_$arch`"
+ [ "$state" = "all-ok" -a "$tstate" != "all-ok" ] && state=tools-ok
+
+ case "$state" in
+ invalid)
+ logexec mkdir -p "$_ROOTDIR"
+ logexec mkdir -p "$_STATE_DIR"
+ xset state init-ok
+ ;;
+
+ init-ok)
+ setup_target tools; xset state tools-ok;;
+
+ tools-ok)
+ setup_target "$arch"; xset state target-ok;;
+
+ target-ok)
+ xset state all-ok;;
+
+ all-ok)
+ notice "All done. Build environment was successfully setup at $_ROOTDIR"
+ exit 0
+ ;;
+
+ *) die "state: $state"
+ esac
+ done
+}
+
+# kill_env: purge selected build environment
+#
+# PARAMETERS
+# <none>
+#
+# VARIABLES
+# $_ROOTDIR
+#
+# DESCRIPTION
+# This function deletes all files related to build environment
+# created at $_ROOTDIR. Additionally, linked scratchbox2
+# profile is deleted.
+#
+# SIDE EFFECTS
+# Build environment at $_ROOTDIR and linked scratchbox2
+# profile are removed.
+kill_env()
+{
+ [ -n "$_ROOTDIR" -a -d "$_ROOTDIR" ] || die "Invalid directory selected ($_ROOTDIR). Aborting."
+
+ notice "This program will delete following directories:"
+ notice " * $_ROOTDIR"
+ [ -f "$_STATE_DIR/sb2ids" ] && while read id junk; do
+ notice " * $HOME/.scratchbox2/$id"
+ done < "$_STATE_DIR/sb2ids"
+
+ notice "Type YES to continue"
+ read answer junk
+
+ if [ "$answer" = "YES" ]; then
+ [ -f "$_STATE_DIR/sb2ids" ] && while read id junk; do
+ logexec rm -rf -- "$HOME/.scratchbox2/$id"
+ done < "$_STATE_DIR/sb2ids"
+
+ logexec rm -rf -- "$_ROOTDIR"
+ else
+ notice "Aborting."
+ fi
+}
+
+# build_dep: extract build dependencies required to build package
+#
+# PARAMETERS
+# $1 - target architecture
+#
+# VARIABLES
+# $_ROOTDIR, $_NO_CLEAN
+#
+# DESCRIPTION
+# This function extracts list of build-time dependencies required to
+# build package located in current working directory.
+build_dep()
+{
+ local arch tmp
+
+ arch="$1"
+ tmp="$(mktemp "$_TMPDIR/sbs_builddep.XXXXXX")"
+
+ echo "f $tmp" >> "$_CLEANUP_LIST"
+
+ # Check for missing dependencies via scratchbox2 wrapper for
+ # dpkg-checkbuilddeps (checks dependencies in tools and
+ # target).
+ #
+ # Additionally, make sure that dpkg-checkbuilddeps produces
+ # output in expected format - unset SBOX_CHECKBUILDDEPS_VERBOSE
+ # as this variable modifies program's behaviour.
+ unset SBOX_CHECKBUILDDEPS_VERBOSE
+
+ cmd "$arch" dpkg-checkbuilddeps > "$tmp" 2>&1 && return || true
+
+ # dpkg-checkbuilddeps failed - there are missing dependencies. Parse
+ # it's output to extract package list. Expected output format:
+ # "dpkg-checkbuilddeps: Unmet build dependencies: libz-dev (>= 1.2) | zlib1g libbz2-dev"
+ # Transform above line to form proper "Depends" field, i.e.
+ # "libz-dev (>=1.2) | zlib1g, libbz2-dev"
+ sed -ne '/Unmet build dependencies: / { s/\(.*Unmet build dependencies: \)//; s_\([-+.a-z0-9]\) \+\([[:alpha:]]\)_\1, \2_g; p; q}' < "$tmp"
+}
+
+# create_dummy_deb: create temporary package with specified depends line
+#
+# PARAMETERS
+# $1 - package name (as identified by apt-get)
+# $2 - dependency line
+# $3 - output .deb file
+#
+# VARIABLES
+# $_ROOTDIR, $_NO_CLEAN
+#
+# DESCRIPTION
+# This function builds package depending on other as specified
+# by $2 argument.
+#
+# SIDE EFFECTS
+# This function creates .deb file in location pointed by $3.
+# Temporary directory is also used (removed unless $_NO_CLEAN
+# variable is set).
+create_dummy_deb()
+{
+ local name deplist outfile tmp
+
+ name="$1"
+ deplist="$2"
+ outfile="$3"
+
+ tmpdir="$(mktemp -d "$_TMPDIR/sbs_create_dummy_deb.XXXXXX")"
+ echo "d $tmpdir" >> "$_CLEANUP_LIST"
+
+ # Create dummy package depending on packages found to be missing
+ logexec mkdir -p -m755 "$tmpdir/DEBIAN"
+ # "dpkg-deb -b" will complain if following dir has setgid bit set - strip it
+ chmod a-s "$tmpdir/DEBIAN" || true
+ cat <<EOF >"$tmpdir/DEBIAN/control"
+Package: $name
+Maintainer: Karol Lewandowski <k.lewandowsk@samsung.com>
+Architecture: all
+Version: 1.0
+Depends: $deplist
+Description: Dummy package created to satisfy build dependencies
+EOF
+ logexec chmod 644 "$tmpdir/DEBIAN/control"
+ logexec dpkg-deb -b "$tmpdir" "$outfile"
+}
+
+# setup_auto_apt_repo: create apt repository from given directory
+#
+# PARAMETERS
+# $1 - directory pointing to target's environment
+# $2 - repository path below $2
+#
+# VARIABLES
+# $_ROOTDIR, $_NO_CLEAN
+#
+# DESCRIPTION
+# This function builds package depending on other as specified
+# by $2 argument.
+#
+# SIDE EFFECTS
+# This function creates package indexes for directory specified by $1.
+# Newly created repositry is also added to target's sources.list
+setup_auto_apt_repo()
+{
+ local targetdir repodir
+
+ targetdir="$1"
+ repodir="$2"
+
+ # We have to use dpkg-scanpackages from tools as we can't be sure that it's available on host
+ # XXX We use shell redirection directly because passing commands with embedded whitespace isn't
+ # working properly in scratchbox2.
+ ( logexec cd "$targetdir/$repodir" && _cmd_id='' cmd tools dpkg-scanpackages . > Packages )
+}
+
+# satisfy_deps: find and install missing build-deps
+#
+# VARIABLES
+# $_ROOTDIR, $_NO_CLEAN
+#
+# DESCRIPTION
+# This function checks and install build-dependencies - designed
+# to be called by build_pkg() under lock.
+satisfy_deps()
+{
+ local deplist repodir trdir pkgname listf ret
+
+ repodir="/var/lib/sbs/autobuilder-apt-$$" # this will be below $_cmd_targetdir
+ listf="/etc/apt/sources.list.d/sbs-auto.list" # likewise
+
+ if ! [ "$_arch" -a "$_cmd_targetdir" -a "$_cmd_id" ]; then
+ die "Internal command."
+ fi
+
+ debug "Extracting build-dependencies"
+ deplist="`build_dep \"$arch\"`"
+
+ if [ -z "$deplist" ]; then
+ debug "All build-dependencies already satisfied"
+ exit 0
+ fi
+ debug "Will try to install following packages: $deplist"
+
+ trdir="$_cmd_targetdir/$repodir"
+ echo "d $trdir" >> "$_CLEANUP_LIST"
+ logexec mkdir -p "$trdir"
+
+ pkgname="${_M}-dummy-dep"
+ create_dummy_deb "$pkgname" "$deplist" "$trdir/dummy-dep.deb"
+ setup_auto_apt_repo "$_cmd_targetdir" "$repodir"
+
+ debug "Installing dummy dependency package"
+ echo "f $_cmd_targetdir/$listf" >> "$_CLEANUP_LIST"
+ echo "deb file://$repodir/ ./" > "$_cmd_targetdir/$listf"
+
+ ret=0
+ _cmd_map="emulate"
+
+ cmd "$arch" $_apt update && cmd "$arch" $_apt install -y "$pkgname" || ret=$?
+ cmd "$arch" dpkg --purge "$pkgname" || true
+
+ exit $ret
+}
+
+# build_pkg: automatically build package given .dsc file
+#
+# PARAMETERS
+# $1 - build architecture
+# $2 - clean build
+# $3 - install build-dependent packages only
+# $4 - source package description (Debian's .dsc file)
+#
+# VARIABLES
+# $_ROOTDIR, $_TARGET_SUITE, $_TARGET_MIRROR, $_NO_CLEAN
+#
+# DESCRIPTION
+# This function performs following steps in order to create binary
+# packages:
+#
+# (1) Extracts source package according to .dsc file definition
+#
+# (2) Checks and installs missing dependencies under a lock
+#
+# Function finishes at this step if arg $3 is set to 1.
+#
+# (3) Builds package (binary only, signing step is disabled)
+#
+# (4) Copies generated files (*.deb and .changes) back to original
+# working directory
+#
+# SIDE EFFECTS
+# This function creates copy of target's filesystem in $_ROOT_DIR
+# for compilation purposes. This copy is removed unless $_NO_CLEAN
+# variable is set.
+#
+# When building a dsc file, files resulting from successful build
+# are copied to current working directory (*.deb and *.changes).
+build_pkg()
+{
+ local arch origdsc origcwd emul xbwork srcdir ret
+ local deplist repodir trdir pkgname fail dpkg_buildflags cpucount
+
+ arch="$1"
+ clean_env="$2"
+ deps_only="$3"
+ origdsc="$4"
+ origcwd="`pwd`"
+ _cmd_targetdir="`xget dir $arch`"
+ _cmd_id="`xget id $arch`"
+
+ # create temporary directory if necessary
+ if [ "$clean_env" = 1 ] || [ "$origdsc" ]
+ then
+ xbwork="`mktemp -d \"$_ROOTDIR/xbwork_$(date +%Y-%m-%d_%H-%M).XXXXXXX\"`"
+ echo "d $xbwork" >> "$_CLEANUP_LIST"
+ fi
+
+ # Put copy of target's environment below current working dir
+ if [ "$clean_env" = 1 ]
+ then
+ _cmd_id="${_cmd_id}-$$"
+ emul="`xget cpu_emulation $arch`"
+ [ "$emul" ] && emul="-c \"$emul\""
+ emul_native="`which \"$_CPUTRANSP_NATIVE\"`"
+ [ "$emul_native" ] && emul_native="-p \"$emul_native\""
+
+ _cmd_targetdir="$xbwork/target"
+ debug "Preparing target root directory under $_cmd_targetdir"
+ logexec mkdir -p "$_cmd_targetdir"
+ logexec cd "$_cmd_targetdir"
+ logexec sh -c "fakeroot tar xpf `xget archive_path $arch`"
+
+ # Create temporary scratchbox2 profile used only for this build
+ debug "Preparing scratchbox2 environment"
+ logexec sb2-init -n -m "`xget map $arch`" $emul $emul_native -t "`xget dir tools`" -A "`xget arch $arch`" "$_cmd_id" "`xget compiler_path $arch`"
+ # Use environment setup from ordinary SB2 environemt for this arch
+ setup_sb2_envvars "$_cmd_id" "$HOME/.scratchbox2/`xget id $arch`/sb2.config.d/env_vars"
+ echo "s $_cmd_id" >> "$_CLEANUP_LIST"
+ fi
+
+ # Are we building from .dsc or current dir?
+ if [ "$origdsc" ]; then
+ srcdir="$xbwork/src"
+ debug "Unpacking package $origdsc"
+ logexec dpkg-source -x "$origcwd/$origdsc" "$srcdir"
+
+ # Make ccache strip $srcdir when computing hash - this feature
+ # is required for ccache to work effectively when compiling
+ # same code in different directories. Requires ccache 3.0.
+ export CCACHE_BASEDIR="$srcdir"
+ else
+ srcdir="$origcwd"
+ fi
+ logexec cd "$srcdir"
+
+ # figure out which architectures we build on
+ debug "Checking build architectures"
+ eval $(grep "^Architecture:" debian/control | sed -e '/^Architecture:/ { s/[^:]*:\s*//; s/\s\+$//; s/-/_/g; s/\(\S*\)/build_\1=1/g;}')
+ if [ "x$build_any" != x1 ] && [ "x$build_all" != x1 ] &&
+ [ "x$build_linux_any" != x1 ] &&
+ $(eval '[ x$build_any_'$arch' != x1 ]') &&
+ $(eval '[ x$build_'$arch' != x1 ]')
+ then
+ notice "Nothing to build for $arch"
+ return 0
+ fi
+
+ # check if the package supports parallelism
+ # use the number of CPUs on this machine or $SBS_MAKE_JOBS
+ if [ -f debian/jobs ]
+ then
+ if [ "$SBS_MAKE_JOBS" ]
+ then
+ cpucount="$SBS_MAKE_JOBS"
+ else
+ cpucount="`cat /proc/cpuinfo | grep ^processor | wc -l`"
+ fi
+ dpkg_buildflags="-j$cpucount"
+ fi
+
+ # reexecute ourselfs under lock to check dependencies and install packages in one step
+ SBS_ARCH="$_arch" _cmd_targetdir="$_cmd_targetdir" _cmd_id="$_cmd_id" \
+ flock "$_STATE_DIR/satisfy-deps-${_arch}.lock" "$script_path" --verbose "$_verbose" --satisfy-deps
+
+ if [ "$deps_only" = 1 ]; then
+ debug "All done. Build dependencies have been satisfied."
+ return
+ fi
+
+ # Build package and copy output back to working directory
+ debug "Building package"
+ _cmd_map="`xget map $arch`"
+ cmd "$arch" time dpkg-buildpackage -b -uc -us $dpkg_buildflags
+
+ if [ "$origdsc" ]; then
+ logexec cd ..
+ logexec cp -v *.deb *.changes "$origcwd/"
+ logexec sh -c "cp -v *.udeb \"$origcwd/\" || true"
+ fi
+
+ debug "All done. Package has been built."
+}
+
+upgrade_target()
+{
+ local arch dir apath
+
+ arch="$1"
+ shift
+ dir="`xget dir $arch`"
+ apath="`xget archive_path $arch`"
+
+ _cmd_map="emulate"
+ cmd "$arch" $_apt update
+
+ if [ $# -gt 0 ]; then
+ cmd "$arch" $_apt -y install "$@"
+ else
+ notice "No packages selected - performing full upgrade for ${arch}"
+ cmd "$arch" $_apt -y dist-upgrade
+ fi
+
+ logexec sh -c "tar czpf \"${apath}\" -C \"$dir\" ."
+}
+
+# makeimage: create binary images containing kernel and filesystem image(s)
+#
+# PARAMETERS
+# $1 - board configuration id - needs to resolve to file (with .conf
+# suffix) in $_BOARDS_DIR
+# $2 - user-selected board name
+#
+# VARIABLES
+# $_TARGET_SUITE, $_TARGET_MIRROR, $_NO_CLEAN
+#
+# DESCRIPTION
+# This function constructs binary ubi filesystem and kernel images
+# from packages downloaded from $_TARGET_{SUITE/MIRROR} pair.
+#
+# By default slp2-image-poc is installed providing default package
+# selection for PoC aquila board.
+#
+# Image's temporary files are preserved if $_NO_CLEAN variable
+# is set.
+#
+# SIDE EFFECTS
+# This function puts ${NAME}_${BOARD}_{kernel,ubifs}.tar files containing
+# kernel and ubi images respectively into current working directory.
+makeimage()
+{
+ set -e
+ local arch workdir tid emul permfile rootdir pkgincl
+ arch="$1"
+
+ umask 022
+ mkdir -p "$HOME/sbs-image"
+ workdir="`mktemp -d \"$HOME/sbs-image/image.XXXXX\"`"
+ echo "d $workdir" >> "$_CLEANUP_LIST"
+
+ # Preserve environment for debugging purposes
+ cat >>"$workdir/env.sh" <<EOF
+set -a
+SBS_BOARD_NAME="$2"
+SBS_IMG_NAME="$3"
+SBS_DATA_DIR="$_SHARE_DIR/data"
+SBS_SCRIPTS_DIR="$_SHARE_DIR/scripts"
+SBS_BOARDS_DIR="$_SHARE_DIR/boards"
+SBS_OUT_DIR=`pwd`
+PATH="$_SHARE_DIR/wrappers:$PATH"
+. $_BOARDS_DIR/${2}.conf
+set +a
+EOF
+ . "$workdir/env.sh"
+
+ pkgincl="`xget pkgincl \"board-${SBS_BOARD_NAME}\"`"
+ [ ! "$pkgincl" ] || pkgincl="--include=$pkgincl"
+
+ tid="${_M}-makeimage_$$"
+ permfile="$workdir/fakeroot.perm"
+ rootdir="$workdir/rootdir"
+ emul="`xget cpu_emulation $arch`"
+ [ "$emul" ] && emul="-c \"$emul\""
+ emul_native="`which \"$_CPUTRANSP_NATIVE\"`"
+ [ "$emul_native" ] && emul_native="-p \"$emul_native\""
+
+ echo "s $tid" >> "$_CLEANUP_LIST"
+
+ logexec mkdir -p "$rootdir"
+ logexec cd "$rootdir"
+
+ printf "#!/bin/sh -e\n\ncd \"$rootdir\";. ../env.sh; sb2 -R -f \"-i$permfile -s$permfile\" -t \"$tid\" -e -- \"\$@\"\n" >>"$workdir/run-sb2.sh"
+ printf "#!/bin/sh -e\n\ncd \"$rootdir\";. ../env.sh; fakeroot -i \"$permfile\" -s \"$permfile\" \"\$@\"\n" >>"$workdir/run-fakeroot.sh"
+ printf "#!/bin/sh -e\n\ncd \"$rootdir\";. ../env.sh; \"\$@\"\n" >>"$workdir/run-native.sh"
+ chmod u+x "$workdir/run-native.sh" "$workdir/run-fakeroot.sh" "$workdir/run-sb2.sh"
+ touch "$permfile"
+
+ [ -x "$_SCRIPTS_DIR/pre-debootstrap" ] && "$_SCRIPTS_DIR/pre-debootstrap"
+ [ -r "$_DEBOOTSTRAP_SCRIPT" ] || die "debootstrap script for selected suite doesn't exist ($_DEBOOTSTRAP_SCRIPT)."
+ DEBOOTSTRAP_DIR="$_DEBOOTSTRAP_DIR"
+ export DEBOOTSTRAP_DIR
+ logexec sh "$workdir/run-fakeroot.sh" debootstrap $_DEBOOTSTRAP_OPTS --variant=minbase $pkgincl --foreign --arch="`xget arch $arch debian`" "`xget suite $arch`" . "`xget mirror $arch`" "$_DEBOOTSTRAP_SCRIPT"
+ unset DEBOOTSTRAP_DIR
+ echo 'scratchbox' > ./debootstrap/variant
+ logexec ln -sf "$HOME/.ssh" "$rootdir/root/"
+
+ logexec sb2-init -n -m emulate $emul $emul_native -A `xget arch $arch` -t /bin "$tid" /bin/false
+
+ # Work around debootstrap creation of device nodes
+ logexec sh -c "tar czfT $rootdir/debootstrap/devices.tar.gz /dev/null"
+ logexec sh "$workdir/run-sb2.sh" ./debootstrap/debootstrap --second-stage
+ logexec sh "$workdir/run-sb2.sh" apt-get clean
+ logexec sh -c "echo \"`xget sources_list $arch`\" >'$rootdir/etc/apt/sources.list'"
+
+ [ -x "$_SCRIPTS_DIR/post-debootstrap" ] && "$_SCRIPTS_DIR/post-debootstrap"
+
+ for hook in "$_SCRIPTS_DIR"/???.makeimage-hook.*; do
+ if ! test -x "$hook"; then
+ debug "Ignoring non-executable hook file: ${hook}"
+ continue
+ fi
+ case $hook in
+ *.native) logexec "$workdir/run-native.sh" "$hook";;
+ *.fakeroot) logexec "$workdir/run-fakeroot.sh" "$hook";;
+ *.sb2) logexec "$workdir/run-sb2.sh" "$hook";;
+ *) debug "Ignoring hook file: ${hook}. Please use either .native, .fakeroot or .sb2 suffix";;
+ esac
+ done
+
+ debug "All done. Makeimage finished without errors."
+}
+
+# selftest: test scratchbox2 maps used during build environment
+#
+# PARAMETERS
+# $1 - scratchbox2 configuration id - by default it's chosen from
+# $_ROOTDIR variable
+#
+# VARIABLES
+# $_ROOTDIR
+#
+# DESCRIPTION
+# This function checks if mappings in selected build environment are
+# correct. slp2 and emulate maps are currently checked. After test
+# run summary of failed/passed tests is presented.
+#
+# By default scratchbox2 profile is selected based on current value
+# of $_ROOTDIR. However, one might force profile id by providing
+# first positional parameter.
+#
+# NOTE It's not possible to check paths with different than default
+# scratchbox2 exec policy. Thus, it's not possible to check if e.g.
+# /usr/lib/perl, /usr/lib/python and similar map correctly.
+selftest()
+{
+ local arch tmp log tools target map variant src rtext
+ local r failed nfail npass mark status
+
+ arch="$1"
+ _cmd_id="${2:-`xget id \"$arch\"`}"
+ tmp="`mktemp \"$_TMPDIR/${_M}_selftest.XXXXXXX\"`"
+ log="`mktemp \"$_TMPDIR/${_M}_selftest.XXXXXXX\"`"
+ echo "f $tmp" >> "$_CLEANUP_LIST"
+ echo "f $log" >> "$_CLEANUP_LIST"
+
+ tools="`egrep '^SBOX_TOOLS_ROOT=' < \"$HOME/.scratchbox2/$_cmd_id/sb2.config\" | cut -d= -f2`"
+ target="`egrep '^SBOX_TARGET_ROOT=' < \"$HOME/.scratchbox2/$_cmd_id/sb2.config\" | cut -d= -f2`"
+
+ cd "$_SHARE_DIR/t/map" && for suite in *.t
+ do
+ map="${suite%-*.t}"
+ variant="`echo $suite | sed -e 's/.*-\(.*\).t/\1/g'`"
+ echo ">>> Running tests for map ${map}, variant $variant"
+ _cmd_map="$map"
+
+ sed -e "s!@TOOLS@!$tools!g" -e "s!@TARGET@!$target!g" < "$suite" > "$tmp"
+ while read t
+ do
+ src="`echo $t | awk '{print $1}'`"
+ set +e
+ r="`cmd \"$arch\" sb2-show path \"$src\" 2>/dev/null`"
+ set -e
+
+ [ x"$t" = x"$r" ] && rtext=passed || rtext='failed @@@'
+ printf "### %-16s %-40s %s\n" "$map:$variant" "$src" "$rtext" | tee -a "$log"
+ echo "... expected $t" >> "$log"
+ echo "... got $r" >> "$log"
+ echo >> "$log"
+ done < "$tmp"
+ done
+
+ failed="`egrep '^###.*failed @@@$' < $log || true`"
+ nfail="`egrep '^###.*failed @@@$' < $log | wc -l || true`"
+ npass="`egrep '^###.*passed$' < $log | wc -l || true`"
+
+ echo "Summary for test suite run finished on `date -R`"
+ echo "Number of tests:"
+ echo " total: $(($nfail + $npass))"
+ echo " passed: $npass"
+ echo " failed: $nfail"
+
+ if [ $nfail -gt 0 ]
+ then
+ printf "\nTests that failed:"
+
+ n=0
+ while read line
+ do
+ mark="`echo $line | awk '{print $1}'`"
+ status="`echo $line | awk '{print $4}'`"
+
+ if [ $n -gt 0 ]; then echo "$line"; n=$(($n - 1)); continue; fi
+ if [ x"$mark" = x"###" -a x"$status" = x"failed" ]
+ then
+ printf "\n$line\n"
+ n=2
+ fi
+ done < "$log"
+ fi
+ echo
+}
+
+# get_source: Intended to be a replacement for apt-get source $binary
+#
+# PARAMETERS
+# $1 - binary package name
+# $2 - clone full history instead of choosen revision only when set
+#
+# DESCRIPTION
+# Downloads the source for a binary package from a git repository
+# specified in the binary.
+# Assumes a binary package is tagged as follows:
+#
+# Package: libeet-dev
+# Source: eet
+# ...
+# Vcs-Git: ssh://your_id@112.106.1.251:29418/pkgs/e/eet
+# Vcs-Git-Commit: e334f092a63c46854baecde88ee8e0152074ce21
+# Vcs-Git-Rev: eet_1.2.0+svn.57246slp2+build03
+#
+get_source() {
+ local binary_package gitrepo gitrev opt do_clone
+
+ #_mode=execute-target
+ binary_package="$1"
+ do_clone=$2
+ _cmd_map='emulate'
+ opt="--no-all-versions" # show one package only - apt's "candidate to install"
+
+ # Extract gitrepo, gitrev srcname, pkgname and place these into our environment
+ eval $(cmd "$_arch" apt-cache show $opt "$binary_package" | sed -n \
+ -e '/^Vcs-Git:/ { s/[^:]*:\s*\(\S*\)/gitrepo=\1/; p; }' \
+ -e '/^Vcs-Git-Commit:/ { s/[^:]*:\s*\(\S*\)/gitrev=\1/; p; }' \
+ -e '/^Source:/ { s/[^:]*:\s*\(\S*\)/srcname=\1/; p; }' \
+ -e '/^Package:/ { s/[^:]*:\s\(\S*\)/pkgname=\1/; p; }' \
+ -e '/^$/ q')
+
+ # Debian policy allows omitting Source for packages that produce only one binary .deb
+ [ "$srcname" ] || srcname="$pkgname"
+
+ [ "$gitrepo" ] && [ "$gitrev" ] && [ "$srcname" ] || die "git repository not specified in package"
+
+ notice "Fetching source for $srcname from $gitrepo commit-ish $gitrev"
+
+ [ ! -d "$srcname" ] || die "$srcname already exists"
+
+ if [ -z "$do_clone" ]; then
+ mkdir "$srcname"
+ logexec git archive --format=tar --remote "$gitrepo" "$gitrev" | tar x -C "$srcname"
+ else
+ logexec git clone "$gitrepo"
+ fi
+}
+
+# reset_environment: implement functionality similar to sb1's reset
+#
+# PARAMETERS
+# $1 - the architecture to reset
+#
+# DESCRIPTION
+#
+# Reset environment back to its initial state (as it was after sbs -c)
+#
+reset_environment() {
+ local dir tar arch id
+
+ arch="$1"
+ notice "Resetting $arch environment"
+ tar="$_ROOTDIR/target-$arch.tgz"
+ dir="$_ROOTDIR/target-$arch"
+ [ -f "$tar" ] || die "Backup $tar missing..."
+
+ # restore the preserved environment
+ rm -rf "$dir"
+ mkdir -p "$dir"
+ tar zxf "$tar" -C "$dir"
+
+ # delete the build package database, it's now stale
+ id=`xget id "$arch"`
+ rm -rf "$HOME/.scratchbox2/$id/tmp-pkg-db.slp2"
+}
+
+## entry point
+
+# enable colors only on terminal devices
+TPUT="`which tput`"
+if test -t 0 -a -t 1 -a -n "$TPUT"
+then
+ CI="`$TPUT setf 6 || true`"
+ CE="`$TPUT setf 4 || true`"
+ CX="`$TPUT setf 2 || true`"
+ CN="`$TPUT sgr0 || true`"
+else
+ CI=''
+ CE=''
+ CX=''
+ CN=''
+fi
+
+# perform cleanup on exit - successfull or not
+trap cleanup 0 INT TERM
+
+# setup a path to our directory
+script_path=""
+case "$0" in
+ /*)
+ # absolute path
+ script_path="$0"
+ ;;
+ */*)
+ # relative path
+ script_path="`pwd`/$0"
+ ;;
+ *)
+ # no directory in $0, search in PATH
+ saved_ifs=$IFS
+ IFS=:
+ for d in $PATH
+ do
+ if [ -x "$d/$0" ]
+ then
+ script_path="$d/$0"
+ break
+ fi
+ done
+ IFS=$saved_ifs
+ ;;
+esac
+
+script_path="`readlink -e \"$script_path\"`"
+_BIN_DIR="`dirname \"$script_path\"`"
+_SHARE_DIR="`readlink -e \"${_BIN_DIR}/../share/${_M}\"`"
+_BOARDS_DIR="${_SHARE_DIR}/boards"
+_SCRIPTS_DIR="${_SHARE_DIR}/scripts"
+_DATA_DIR="${_SHARE_DIR}/data"
+
+# ensure that we can access utilities normally installed in *sbin
+# directories (mkfs.ubi, debootstrap, etc.)
+export PATH="${_BIN_DIR}:$PATH:/usr/local/sbin:/usr/sbin:/sbin"
+
+_DEBOOTSTRAP_DIR=$(readlink -e "`dirname \"\`which debootstrap\`\"`/../share/debootstrap")
+[ "$_DEBOOTSTRAP_DIR" -a -e "$_DEBOOTSTRAP_DIR" ] || die "debootstrap not found"
+_DEBOOTSTRAP_SCRIPT="$_DEBOOTSTRAP_DIR/scripts/$_TOOLS_SUITE"
+_REPO_DIR="${_SHARE_DIR}/apt_mirror"
+
+# avoid locale-related problems, drop problematic vars - switch back to C/POSIX locale
+export LANG=C
+export LC_ALL=C
+
+# Don't check release file signature on APT repositories.
+# debootstrap >= 1.0.30 checks this by default, which would break SBS.
+# debootstrap << 1.0.30 doesn't know --no-check-gpg option, so we have to check.
+if DEBOOTSTRAP_DIR="$_DEBOOTSTRAP_DIR" debootstrap --help | grep -q -- --no-check-gpg
+then
+ _DEBOOTSTRAP_OPTS="--no-check-gpg"
+fi
+
+# Parse command line parameters one by one.
+
+# Save selected mode of operation. Note that we allow only one
+# command/operation to be chosen.
+_mode=''
+
+# Set following variable to use "git clone" instead of "git archive" while fetching sources
+_source_clone=''
+
+# set the following variable to 1 to build from a clean environment
+_clean_build=0
+
+# set the following variable to 1 to install build dependencies only (applicable for build_pkg)
+_build_deps_only=0
+
+# verbosity level: 0 - quiet, 1 - warnings only, 2 - debug output
+_verbose=1
+
+# set_if_null: assign value to variable only if it's null, die otherwise
+#
+# PARAMETERS:
+# $1 - target variable
+# $2 - new value
+set_if_null()
+{
+ local old
+
+ old="`eval echo '$'$1`"
+ [ -n "$old" ] && die "You can use only one command."
+ eval "$1=$2"
+}
+
+while [ $# -ge 1 ]
+do
+ arg="$1"
+ shift
+
+ case "$arg" in
+ -c|--create)
+ set_if_null _mode create
+ ;;
+
+ -k|--kill)
+ set_if_null _mode kill
+ ;;
+
+ # After execute*-like cmd parsing real command line arguments are kept unaltered in "$@"
+ # to avoid whitespace problems.
+ -e|--execute)
+ set_if_null _mode execute
+ break
+ ;;
+
+ -et|--execute-target)
+ set_if_null _mode execute-target
+ break
+ ;;
+
+ -eo|--execute-tools)
+ set_if_null _mode execute-tools
+ break
+ ;;
+
+ -b|--build|--clean-build)
+ set_if_null _mode build
+ if [ $# -ge 1 -a "$1" -a "${1#-}" = "$1" ]; then
+ build_dsc="$1"
+ _clean_build=1 # backwards compatibility
+ shift
+ fi
+ [ "$arg" = "--clean-build" ] && _clean_build=1
+ ;;
+
+ -d|--depends)
+ set_if_null _mode build
+ _build_deps_only=1
+ ;;
+
+ --satisfy-deps)
+ # internal command
+ set_if_null _mode satisfy-deps
+ break
+ ;;
+
+ -u|--upgrade)
+ set_if_null _mode upgrade
+ break;
+ ;;
+
+ -i|--makeimage)
+ set_if_null _mode makeimage
+ [ $# -lt 1 -o -z "$1" ] && die "Please provide image name."
+ makeimage_name="$1"
+ shift
+ ;;
+
+ -B|--board)
+ if [ $# -lt 1 -o -z "$1" ]
+ then
+ test -d "$_BOARDS_DIR" || die "Board configuration directory ($_BOARDS_DIR) doesn't exist."
+
+ notice "Please select one of following available board types:"
+ cd "$_BOARDS_DIR" && for i in *.conf
+ do
+ echo " ${i%%.conf}"
+ done
+ exit 1
+ else
+ makeimage_board="$1"
+ shift
+ fi
+ ;;
+
+ -A|--arch)
+ [ $# -ge 1 -a "$1" ] || die "Please provide valid architecture in next argument (e.g. armel, i386)"
+ _arch="$1"
+ shift
+ ;;
+
+ --selftest)
+ set_if_null _mode selftest
+ if [ ! -z "$1" -a "`echo $1 | cut -b-1`" != "-" ]
+ then
+ selftest_id="$1"
+ shift
+ fi
+ ;;
+
+ -s|--source|--clone)
+ set_if_null _mode getsource
+ [ $# -lt 1 -o -z "$1" ] && die "Please provide binary package name."
+ binary_package="$1"
+ shift
+ [ "$arg" = "--clone" ] && _source_clone=1
+ ;;
+
+ --reset)
+ set_if_null _mode reset
+ ;;
+
+ -v|--verbose)
+ if [ $# -ge 1 -a ! -z "$1" -a "${1#-}" = "$1" ]; then
+ _verbose="$1"
+ shift
+ else
+ _verbose="$(($_verbose + 1))"
+ fi
+
+ [ "$_verbose" -ge 0 -a "$_verbose" -le 2 ] || die "Invalid verbosity level provided ($_verbose). Please use numbers from 0 to 2."
+ ;;
+
+ -h|--help)
+ set_if_null _mode help
+ ;;
+
+ *)
+ die "Unknown commmand line option. Please see $script_path --help";
+ ;;
+ esac
+done
+
+_cmd_map="`xget map $arch`"
+
+# Perform chosen action
+case $_mode in
+ create)
+ check_sanity
+ get_apt_mirrors
+ create_env "$_arch"
+ ;;
+
+ kill)
+ kill_env
+ ;;
+
+ execute)
+ check_sanity
+ check_env
+ cmd "$_arch" "$@"
+ ;;
+
+ execute-target)
+ check_sanity
+ check_env
+ _cmd_map='emulate'
+ cmd "$_arch" "$@"
+ ;;
+
+ execute-tools)
+ check_sanity
+ check_env
+ cmd tools "$@"
+ ;;
+
+ build)
+ check_env
+ build_pkg "$_arch" "$_clean_build" "$_build_deps_only" $build_dsc
+ ;;
+
+ satisfy-deps)
+ satisfy_deps
+ ;;
+
+ upgrade)
+ check_sanity
+ check_env
+ upgrade_target "$_arch" "$@"
+ ;;
+
+ makeimage)
+ check_sanity
+ get_apt_mirrors
+ if [ -z "$makeimage_board" -o -z "$makeimage_name" ]
+ then
+ usage
+ exit 1
+ fi
+ makeimage "$_arch" $makeimage_board $makeimage_name
+ ;;
+
+ selftest)
+ selftest "$_arch" $selftest_id
+ ;;
+
+ getsource)
+ check_sanity
+ check_env
+ get_source "$binary_package" $_source_clone
+ ;;
+
+ reset)
+ check_sanity
+ check_env
+ reset_environment "$_arch"
+ ;;
+
+ help)
+ usage
+ exit 0
+ ;;
+esac
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..ed0aeda
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,348 @@
+sbs (1.7.3) unstable; urgency=low
+
+ * Temporary revert "Drop workaround for cross-compiler links."
+
+ -- Rafal Krypa <r.krypa@samsung.com> Thu, 15 Dec 2011 14:00:27 +0100
+
+sbs (1.7.2) unstable; urgency=low
+
+ [ Jinhyuk Lee ]
+ * makeimage:
+ - Change binary name I9200 -> I9500.
+ - Add i9200 conf file for old snapshot build.
+
+ [ Rafal Krypa ]
+ * install:
+ - Check for dpkg-dev early.
+ - Assume that cpp or gcc might be missing.
+ * sbs:
+ - Require /proc to be mounted.
+ - Drop workaround for cross-compiler links.
+
+ [ Rafał Krypa ]
+
+ -- Rafal Krypa <r.krypa@samsung.com> Mon, 28 Nov 2011 18:37:48 +0100
+
+sbs (1.7.1) unstable; urgency=low
+
+ * debian: depend on qemu-user package with epoch in version (available in the
+ same Samsung repo).
+
+ -- Rafal Krypa <r.krypa@samsung.com> Fri, 04 Nov 2011 14:41:11 +0100
+
+sbs (1.7) unstable; urgency=low
+
+ [ Karol Lewandowski ]
+ * sbs:
+ - Fix: Don't fail to create environment when $HOME contains trailing slash.
+ - Use deboostrap from $PATH.
+ - Fix: Use proper root directory specification.
+ * makeimage:
+ - systemd: Create required device nodes for earlyboot.
+ - systemd: Install current set of systemd packages.
+ - systemd: Set hostname to something known in /etc/hosts.
+ - systemd: Adjust package list after systemd-units-slp split.
+
+ [ Rafal Krypa ]
+ * sbs:
+ - Work around debootstrap creation of device nodes.
+ - Fix: move setting PATH before guessing DEBOOTSTRAP_DIR.
+ - Fix: deal with relative path returned by which command.
+ - Fix: avoid "permission denied" error while debootstrap unpacks devices.tar.gz.
+ * install:
+ - require gcc-multilib on x86_64 (needed by Scratchbox 2).
+
+ [ Jinhyuk Lee ]
+ * makeimage:
+ - making csc binary with c210 and changing languagepack setup.
+ - modify version name as like this -> SLP2.0(BIN_NAME).
+ - moderate the name of auto binary.
+
+ [ Yeongil Jang ]
+ * makeimage:
+ - Change folder "/mnt/ums" to "/opt/media".
+ - Add i9200-e4412 config and code for making Exynos binary.
+
+ [ Kibum Kim ]
+ * makeimage:
+ - change img file name(system.img -> platform.img).
+ - change FLAVOR value in slp.conf file(c110->c210).
+
+ [ Dongsu Kim ]
+ * makeimage:
+ - modify script for marvell build.
+
+ -- Rafal Krypa <r.krypa@samsung.com> Tue, 25 Oct 2011 13:04:50 +0200
+
+sbs (1.6) unstable; urgency=low
+
+ [ Karol Lewandowski ]
+ * sbs:
+ - Add -d/--depends option to install build dependencies.
+ - Fix: Treat argument to --build* as DSC_FILE only if it doesn't start with dash ("-").
+ - Die early if unknown option is found.
+ - Janitorial: Rewrite help/usage screen.
+ - Move build-dep checking and package installation under a lock.
+ - Search debootstrap in system-wide directory if it isn't found in sbs' bin dir.
+ - Export CFLAGS=-Wall by default.
+ - Kill short version of reset command (-r) as it's too easy to type it accidentally.
+ * makeimage:
+ - Remove sbs-specific metapackages in addition to these SCM-managed.
+ - Optionally prelink binaries on produced image.
+ - Don't permit apt-get to fail during package installation.
+ - Preliminary systemd support.
+ - Shrink all ext4 filesystems by default.
+ - Allow overriding ext4 block size on per-partition basis.
+ - Add support for generating csc data partition.
+ - Prepare backup data for factory reset.
+ * install:
+ - Check for uuid-dev needed by mkfs.ubifs.
+
+ [ Mike McCormack ]
+ * makeimage:
+ - Create compressed tar files.
+ - Fail early if tools are missing.
+ - mk_movi_image is not used anywhere.
+ - Create a list of files in the image.
+ - Set the umask to 022 when building an image.
+ - Prelink by default.
+ * install:
+ - Lodin doesn't use libtar any longer.
+ - Test for the presence of archive.h.
+ - Use QEMU 0.14.0 with the preloader.
+ - Build mtd-utils.
+ - Remove check for non-existant package autoheader.
+ - Allow overriding the remote.
+ * debian:
+ - Remove vmmincheck.
+ - Ignore debian build files.
+ * sbs:
+ - Avoid problems if debootstrap is not install on the host.
+ - Allow packages to indicate they support parallel build.
+
+ [ Rafal Krypa ]
+ * sbs:
+ - Use qemu-i386 by default as native "cpu transparency" for sb2.
+ - Don't check release file signature on APT repositories.
+ * makeimage:
+ - Make image tars rsyncable.
+ - Revert "Add partition information for c210 (overflow capacity when build c210)".
+ * debian:
+ - Explicitly depend on qemu-user (= 0.14.1+dfsg-3slp2+s1).
+ - Bump scratchbox2 dependency version.
+
+ [ KwangWeon Park ]
+ * makeimage:
+ - SBS build script change for Marvell board.
+ - Change output images to make tar.gz for Marvell.
+
+ [ Yeongil Jang ]
+ * makeimage:
+ - Remove syslayer link and directory.
+
+ [ Kibum Kim ]
+ * makeimage:
+ - Change c210 binary partition.
+
+ [ Jinhyuk Lee ]
+ * makeimage:
+ - Change the image file of c210. It was once applied by Kibum Kim, but someone added old script.
+
+ [ Sangil Yoon ]
+ * makeimage:
+ - Fix backuplist directory existence checking.
+
+ -- Rafal Krypa <r.krypa@samsung.com> Tue, 26 Jul 2011 15:43:59 +0200
+
+sbs (1.5.1) unstable; urgency=low
+
+ [ Rafal Krypa ]
+ * sbs:
+ - Use absolute path to qemu for sb2-init.
+ - Don't create archive with tools environment.
+ * install:
+ - Require realpath program to be installed, SB2 now needs it.
+ * debian: Update scratchbox2 dependency.
+
+ [ Mike McCormack ]
+ * sbs:
+ - Cleanup the temporary repo directory.
+
+ -- Rafal Krypa <r.krypa@samsung.com> Tue, 05 Apr 2011 15:14:33 +0200
+
+sbs (1.5) unstable; urgency=low
+
+ [ Mike McCormack ]
+ * offline install:
+ - Move offline repo check into sbs script
+ - Fix typo in variable name
+ - Put the mirror in the right place
+ * sbs:
+ - Use a more explicit remote for source download
+ - Don't try build if the environment hasn't been created
+ - Time building of packages
+
+ [ Rafal Krypa ]
+ * sbs:
+ - Fix checking package architecture in build_pkg()
+ - Check sanity and env before running upgrade_target
+ - Describe --clean-build option in the usage() function
+ - Export CCACHE_BASEDIR only when build from debian source package
+ - Provide more flexible default environment for SBS instances
+ - Add CCACHE_COMPRESS=1 to default environment
+ * install:
+ - Fix installation from a Makefile and old file removal during installation
+
+ [ Karol Lewandowski ]
+ * makeimage:
+ - Preliminary support for creating images for c210
+ - makeimage: Try to correct filesystem errors before shrinking fs
+ * sbs:
+ - Introduce --verbose flag to control volume of debug messages
+ - Use debug() to print non-essential information
+ - Fix: Don't use /tmp directly - we have _TMPDIR for that
+ * install:
+ - Install from a Makefile
+ - Add few pretty-printing functions
+ - Unify scratchbox2 dependency checking
+ - Add fakeroot required to build debootstrap
+ - Remove old sbs installation prior to installing new one
+ - Use mktemp(1) to open log file
+ * debian:
+ - Use toplevel Makefile rules to compile and install sbs
+
+ [ Yeongil Jang ]
+ * makeimage:
+ - Add partition information for c210 (overflow capacity when build c210)
+ - Modify build script for omap4 (partitionning, conf)
+
+ [ Howon Jung ]
+ * makeimage:
+ - Modify build script for c210(csc, data file do not make)
+
+ -- Rafal Krypa <r.krypa@samsung.com> Wed, 30 Mar 2011 17:59:30 +0200
+
+sbs (1.4) unstable; urgency=low
+
+ [ Mike McCormack ]
+ * offline install:
+ - Set the install directory correctly
+ - Remove mention of non-existant log
+ * sbs:
+ - Fix build_pkg documentation
+ - Store temporary workspace under SBS rootdir
+ - Use a clean workspace for builds from source trees too
+ - Add --clean-build option
+ - Fix architectures with a minus in their name.
+
+ [ Yeongil Jang ]
+ * makeimage:
+ - Change partition information for pit 0.5
+ - Add mkfs.ext4 data-block-size option from default-size to 4k for writing
+ performance improvement
+
+ -- Rafal Krypa <r.krypa@samsung.com> Wed, 16 Mar 2011 18:41:59 +0100
+
+sbs (1.3) unstable; urgency=low
+
+ [ Mike McCormack ]
+ * install:
+ - Allow installing to an alternate directory
+ - Add a lax mode for installs
+ - Save the versions used to build SBS
+ - Fix up-to-date check
+ - Avoid zip, tar is more standard
+ - Make variables used in function local
+ * offline install:
+ - Add offline installer
+ - Create an offline debian mirror
+ * sbs:
+ - Add a config file
+ - Add a reset feature
+ - Add -s option to download source
+ - Make sure to remove the dummy package if we fail to install
+ - Only build on appropriate architectures
+ - Add a function to clone a package's source
+
+ [ Karol Lewandowski ]
+ * install:
+ - Install lodin and its related tools
+ - Check dependencies first and drop not-required uuid dep
+ - Pretty-print warnings using warn()
+ - Check for zlib development files required to build qemu
+ - Check for libarchive-dev/libtar-dev existence for lodin
+ * offline install:
+ - Don't use bash-specific test expression syntax in sbs-offline-install
+ * makeimage:
+ - Import xml-version of PIT file
+ - Create partitions of size as specified in PIT (xml) file
+ - Generate PIT from xml description
+ - Drop binary version of partition table layout
+ - Bump mangle-ext4-parts script number to allow hooks in between
+ - Shrink selected filesystems after they have been built
+ - Run e2fsck before shrinking filesystem
+ * sbs:
+ - Kill bashisms from get_source
+ - Make get_source faster by minimizing expensive "cmd" calls
+ - get_source: Grab package tags from apt's "candidate to install"
+ - Add information about usage of --reset/--source
+ - Fix: Skip over $binary_package which shouldn't be parsed
+
+ [ Rafal Krypa ]
+ * sbs:
+ - When installing tools from two repositories, merge also base packages list.
+ - Add sbs-archive-keyring to pkgincl.
+ - Warn instead of failing when vm.mmap_min_addr > 4096 on x86_64.
+
+ [ Yeongil Jang ]
+ * makeimage:
+ - Change binary extension from *.bin to *.img
+
+ -- Rafal Krypa <r.krypa@samsung.com> Tue, 15 Mar 2011 16:13:55 +0100
+
+sbs (1.2) unstable; urgency=low
+
+ [ Karol Lewandowski ]
+ * makeimage: Generate etc/score.ini file.
+
+ [ Mike McCormack ]
+ * makeimage: Fix binary name as displayed in admin app.
+ * makeimage: Avoid ending up with /mnt/media/media.
+ * makeimage: Extract major/minor version from image name.
+
+ [ Jongwoo Chae ]
+ * README: Change git paths.
+
+ -- Rafal Krypa <r.krypa@samsung.com> Wed, 23 Feb 2011 17:22:51 +0100
+
+sbs (1.1) UNRELEASED; urgency=low
+
+ [ Rafal Krypa ]
+ * install-sbs: work around for older git.
+ * Merge required packages information from both package sources for tools.
+ * makeimage: run sudo with absolute path to make-ext4.
+
+ [ Karol Lewandowski ]
+ * Upgrade blob: Partition table layout needed by mk_movi_image.
+ * makeimage: Adjust scripts to new partition layout.
+ * makeimage: Remove metapackages after installation.
+
+-- Rafal Krypa <r.krypa@samsung.com> Tue, 15 Feb 2011 16:47:29 +0100
+
+sbs (1.0) unstable; urgency=low
+
+ * New package release.
+
+ -- Rafal Krypa <r.krypa@samsung.com> Mon, 17 Jan 2011 17:49:35 +0100
+
+sbs (0.2) unstable; urgency=low
+
+ * Rename package to SBS.
+
+ -- Karol Lewandowski <k.lewandowsk@samsung.com> Mon, 30 Aug 2010 15:40:42 +0900
+
+ssbs (0.1) unstable; urgency=low
+
+ * Initial release.
+
+ -- Karol Lewandowski <k.lewandowsk@samsung.com> Thu, 29 Jul 2010 17:05:31 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7f8f011
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..a496a80
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,11 @@
+Source: sbs
+Section: non-free/utils
+Priority: optional
+Maintainer: Karol Lewandowski <k.lewandowsk@samsung.com>, Rafal Krypa <r.krypa@samsung.com>
+Build-Depends: debhelper (>= 7.0.51~)
+
+Package: sbs
+Architecture: all
+Depends: ${shlibs:Depends}, scratchbox2 (>= 2.2.3-1slp2+s2), qemu-user (>= 1:0.14), debootstrap (>= 1.0.20), dpkg-dev
+Recommends: openssh-client, git-core, mtd-utils
+Description: SPRC Samsung Build System setup tool
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..fef675f
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,65 @@
+#!/usr/bin/make -f
+#export DH_VERBOSE=1
+
+PREFIX := /usr
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+ make build
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+ make clean
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_prep
+ install -m755 -d debian/sbs/$(PREFIX)
+ make DESTDIR=debian/sbs/ prefix=$(PREFIX) install
+
+binary-indep: build install
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+# dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installcatalogs
+# dh_installpam
+# dh_installmime
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+# dh_installwm
+# dh_installudev
+# dh_lintian
+# dh_bugfiles
+# dh_undocumented
+# dh_installman
+# dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/install-sbs b/install-sbs
new file mode 100755
index 0000000..89f59c0
--- /dev/null
+++ b/install-sbs
@@ -0,0 +1,285 @@
+#!/bin/sh
+
+# die: print message to stderr and exit with error code
+#
+# PARAMETERS
+# $1 $2 ... - message to be printed
+die()
+{
+ echo "$CE$N: fatal error: $*$CN" >&2
+ echo "For detailed log, see: $LOG"
+ exit 1
+}
+
+warn()
+{
+ echo "$CE$N: warning: $*$CN" >&2
+}
+
+notice()
+{
+ echo "$CX$N: $*$CN" >&2
+}
+
+lx()
+{
+ notice "[exec]: $*"
+ "$@"
+}
+
+# make sure we're not root
+if test `id -u` = "0"
+then
+ die "Please install SBS in a user account, not as root"
+fi
+
+# enable colors only on terminal devices
+TPUT="`which tput`"
+if test -t 0 -a -t 1 -a -n "$TPUT"
+then
+ CI="`$TPUT setf 6 || true`"
+ CE="`$TPUT setf 4 || true`"
+ CX="`$TPUT setf 2 || true`"
+ CN="`$TPUT sgr0 || true`"
+else
+ CI=''
+ CE=''
+ CX=''
+ CN=''
+fi
+
+N="`basename \"$0\"`"
+
+# default logging is none
+LOG="$(mktemp /tmp/.sbs-install-XXXXXX)"
+[ $? -eq 0 ] || { echo "$CE$N: error: unable to open log file$CN" >&2; exit 1; }
+echo "SBS install begin" > "$LOG"
+date >> "$LOG"
+git rev-parse --short HEAD >> "$LOG"
+echo >> "$LOG"
+
+echo
+echo "$CI""SBS install script$CN"
+echo "$CI""git version: `git rev-parse --short HEAD`$CN"
+echo "$CI""last commit: `git log HEAD^1.. | grep ^Date:`$CN"
+echo "$CI""For help see: http://www.tizendev.org$CN"
+echo
+
+check_email_and_complain()
+{
+ local email name
+
+ # figure out the user's single ID
+ while true
+ do
+ email="`git config --global --get user.email`"
+
+ if [ "$email" ]
+ then
+ break
+ fi
+
+ echo "git username and email address are not set correctly."
+ echo "SBS will configure these for you now."
+ echo "Example name: Ko Jengi"
+ echo "Example email: ko.jengi@samsung.com"
+ echo
+ echo -n "Your name: "
+ read name
+ echo -n "Your email: "
+ read email
+ git config --global user.name "$name"
+ git config --global user.email "$email"
+ echo
+ done
+}
+
+copy_key_from_scratchbox()
+{
+ if ! test -f "$HOME/.ssh/id_rsa"
+ then
+ if test -f "/scratchbox/users/$USER/home/$USER/.ssh/id_rsa"
+ then
+ echo "Copying public key from old scratchbox install"
+ mkdir -p "$HOME/.ssh"
+ cp -f "/scratchbox/users/$USER/home/$USER/.ssh"/id_rsa* "$HOME/.ssh"
+ fi
+ fi
+}
+
+check_sbs_uptodate()
+{
+ local branch
+
+ # update sbs
+ echo -n "Updating sbs... "
+
+ # using origin/master because this is the default setup by git
+ (git fetch "$REMOTE""tools/sbs" master:origin/master -q >> "$LOG") || die "failed to fetch sbs repository"
+ if ! git diff-index --quiet HEAD
+ then
+ echo
+ echo
+ echo "$CE""Files have been changed. Please checkin changes or remove them with:""$CN"
+ echo "$CE""git reset --hard origin""$CN"
+ echo
+ die "Repository not clean"
+ fi
+
+ # check the current branch contains the latest we fetched from above
+ branch=`git branch --contains origin/master 2> /dev/null | grep "^\\* "`
+ if [ ! "$branch" ]
+ then
+ warn "Please update to origin. e.g. git reset --hard origin"
+ die "Repository not up-to-date"
+ fi
+
+ echo "done"
+}
+
+# location of server with all our source
+REMOTE=${SBS_INSTALL_REMOTE:-"112.106.1.251:"}
+
+# our original cwd
+ROOTDIR="`pwd`"
+
+# no user compile options, thanks
+unset CC CFLAGS LDFLAGS MAKE MAKEFLAGS PANTS
+
+if [ ! "$SBS_INSTALL_LAX" ]
+then
+ check_email_and_complain
+ copy_key_from_scratchbox
+#check_sbs_uptodate
+fi
+
+# which distribution are we installing on?
+cat /etc/lsb-release >> "$LOG" 2> /dev/null
+
+INSTALLDIR=${SBS_INSTALL_DIR:-"$HOME/sbs-install"}
+BUILDDIR="$ROOTDIR/Build"
+SB2DIR="$BUILDDIR/scratchbox2"
+QEMUDIR="$BUILDDIR/qemu"
+DEBOOTDIR="$BUILDDIR/debootstrap"
+LUTILDIR="$BUILDDIR/lutil"
+
+missing=''
+pkg-config --version >/dev/null 2>&1 || { missing="$missing pkg-config"; warn "pkg-config missing - dependency checks won't be accurate"; }
+pkg-config --exists libxml-2.0 >/dev/null 2>&1 || missing="$missing libxml2-dev"
+pkg-config --exists uuid >/dev/null 2>&1 || missing="$missing uuid-dev"
+cpp --version >/dev/null 2>&1 || { missing="$missing cpp"; warn "cpp missing - dependency checks won't be accurate"; }
+echo | cpp -include archive.h >/dev/null 2>&1 || missing="$missing libarchive-dev"
+echo | cpp -include lzo/lzo1x.h >/dev/null 2>&1 || missing="$missing liblzo2-dev"
+gcc --version >/dev/null 2>&1 || { missing="$missing gcc"; warn "gcc missing - dependency checks won't be accurate"; }
+[ `uname -m` != 'x86_64' ] || echo '#include <asm/errno.h>' | gcc -m32 -xc -c -o /dev/null - >/dev/null 2>&1 || missing="$missing gcc-multilib"
+
+if ! pkg-config --exists zlib >/dev/null 2>&1; then
+ # Either pkg-config or zlib itself wasn't found (Debian provide .pc file, Ubuntu doesn't)
+ # We have to check zlib existence manually.
+ echo | cpp -include zlib.h >/dev/null 2>&1 || missing="$missing zlib1g-dev"
+fi
+
+# check for things needed to build scratchbox2
+for prog in automake autoconf make fakeroot realpath; do
+ $prog --version >/dev/null 2>&1 || missing="$missing $prog"
+done
+
+# check for dpkg-dev
+if ! dpkg-architecture --version >/dev/null 2>&1; then
+ missing="$missing dpkg-dev"
+fi
+
+[ -z "$missing" ] || die "please install required packages: $missing"
+
+mkdir -p "$BUILDDIR"
+
+git rev-parse HEAD > "$BUILDDIR/versions"
+
+# download stuff
+while read name
+do
+ srcfile="$BUILDDIR/$name.tar"
+ srcdir="$BUILDDIR/$name"
+ echo -n "Downloading $name... "
+ echo "Downloading $name" >> "$LOG"
+ rm -rf "$srcdir"
+ wget --no-check-certificate -P $BUILDDIR http://112.106.1.254/sbs/$name.tar
+ mkdir "$srcdir"
+ tar xf "$srcfile" -C "$srcdir" --touch
+ rm -f "$srcfile"
+ echo "done"
+done <<END
+scratchbox2
+qemu
+debootstrap
+lutil
+END
+
+# build scratchbox2
+echo -n "Building scratchbox2... "
+(cd "$SB2DIR" && make clean > /dev/null 2>&1)
+(cd "$SB2DIR" && ./autogen.sh && ./configure && make 2>&1 ) >> "$LOG" || die "scratchbox2 build failed"
+echo "done"
+echo -n "Installing scratchbox2... "
+(cd "$SB2DIR" && make install prefix="$INSTALLDIR" 2>&1 ) >> "$LOG" || die "scratchbox2 install failed"
+echo "done"
+
+# build qemu
+echo -n "Building qemu... "
+(cd "$QEMUDIR" && make clean > /dev/null 2>&1)
+(cd "$QEMUDIR" && ./configure --target-list=arm-linux-user,i386-linux-user --disable-blobs --disable-uuid && make 2>&1) >> "$LOG" || die "qemu build failed"
+echo "done"
+echo -n "Installing qemu... "
+(cd "$QEMUDIR" && make install prefix="$INSTALLDIR" 2>&1 ) >> "$LOG" || die "qemu install failed"
+echo "done"
+
+# build lutil and related tools
+echo -n "Building lutil... "
+(cd "$LUTILDIR" && ./autogen.sh && make prefix=/) >> "$LOG" || die "failed to build lutil"
+(cd "$LUTILDIR" && make install prefix=/ DESTDIR="$INSTALLDIR" 2>&1 ) >> "$LOG" || die "lutil install failed"
+echo "done"
+
+# install debootstrap
+echo -n "Installing debootstrap... "
+(cd "$DEBOOTDIR" && fakeroot make devices.tar.gz) >> "$LOG" || die "failed to build debootstrap"
+mkdir -p "$INSTALLDIR"/share/debootstrap/scripts/
+cp -fd "$DEBOOTDIR"/scripts/* "$INSTALLDIR"/share/debootstrap/scripts/
+cp -f "$DEBOOTDIR"/functions "$INSTALLDIR"/share/debootstrap
+cp -f "$DEBOOTDIR"/devices.tar.gz "$INSTALLDIR"/share/debootstrap
+cp -f "$DEBOOTDIR"/debootstrap "$INSTALLDIR"/bin/debootstrap
+echo "done"
+
+# update the sbs binary
+echo -n "Installing sbs scripts... "
+if [ -e "$INSTALLDIR"/sbs.list ]; then
+ notice "removing old sbs installation files" >>"$LOG" 2>&1
+ sort -r "$INSTALLDIR"/sbs.list |
+ while read path; do
+ if [ -d "$INSTALLDIR/$path" ]
+ then
+ lx rmdir "$INSTALLDIR/$path" || true
+ else
+ lx rm "$INSTALLDIR/$path" || true
+ fi
+ done >>"$LOG" 2>&1
+ mv -f "$INSTALLDIR"/sbs.list "$INSTALLDIR"/sbs.list.old
+fi
+mkdir -p "$INSTALLDIR"
+make install DESTDIR="$INSTALLDIR" prefix=/ >"$INSTALLDIR/sbs.list" 2>>$LOG || die "failed to install SBS"
+echo "done"
+
+# save the versions, to enable OSS license compliance
+cp -f "$BUILDDIR"/versions "$INSTALLDIR"
+
+SBS_ROOTDIR=${SBS_ROOTDIR:-$HOME/sbs}
+if ! test -d "$SBS_ROOTDIR"
+then
+ echo
+ echo "$CX""Run $INSTALLDIR/bin/sbs -c to create your initial environment$CN"
+ echo
+else
+ echo
+ echo "$CX""SBS update successful$CN"
+ echo
+fi
+
diff --git a/make-offline-mirror.sh b/make-offline-mirror.sh
new file mode 100755
index 0000000..d00e627
--- /dev/null
+++ b/make-offline-mirror.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+die()
+{
+ echo "$CE$N: fatal error: $*$CN" >&2
+ exit 1
+}
+
+# enable colors only on terminal devices
+TPUT="`which tput`"
+if test -t 0 -a -t 1 -a -n "$TPUT"
+then
+ CI="`$TPUT setf 6 || true`"
+ CE="`$TPUT setf 4 || true`"
+ CX="`$TPUT setf 2 || true`"
+ CN="`$TPUT sgr0 || true`"
+else
+ CI=''
+ CE=''
+ CX=''
+ CN=''
+fi
+
+# default name of the repository
+if [[ $1 ]]
+then
+ dir="$1"
+else
+ dir="repo"
+fi
+
+# can't do any mirroring without reprepro
+rpp=`which reprepro`
+if [ ! "$rpp" ]
+then
+ die "reprepro is not installed. (try: sudo aptitude install reprepro)"
+fi
+
+# get the user's Single ID
+if ! email="`git config --global --get user.email`" ||
+ ! echo $email | grep -q '.com$'
+then
+ die "Please setup up your email address first using:
+ git config --global user.email your_id@your_company.com"
+fi
+SINGLE_ID="`echo \"$email\" | cut -d@ -f1`"
+
+# mirror URL base
+base="http://112.106.1.254/home/tizen"
+
+# mirror the armel repository
+#mkdir -p "$dir/apt.sbs/armel/conf"
+#cat > "$dir/apt.sbs/armel/conf/distributions" <<EOF
+#Codename: slp2-target
+#Origin: slp
+#Suite: unstable
+#Components: main contrib non-free
+#Architectures: armel
+#Update: slp2-target-update
+#EOF
+
+#cat > "$dir/apt.sbs/armel/conf/updates" <<EOF
+#Name: slp2-target-update
+#Method: $base/apt.sbs/armel
+#EOF
+
+# mirror the i386 repository
+mkdir -p "$dir/apt.sbs/i386/conf"
+cat > "$dir/apt.sbs/i386/conf/distributions" <<EOF
+Codename: slp2-target
+Origin: slp
+Suite: unstable
+Components: main contrib non-free
+Architectures: i386
+Update: slp2-target-update
+EOF
+
+cat > "$dir/apt.sbs/i386/conf/updates" <<EOF
+Name: slp2-target-update
+Method: $base/apt.sbs/i386
+EOF
+
+# mirror the tools repository
+mkdir -p "$dir/apt.sbs/tools/conf"
+cat > "$dir/apt.sbs/tools/conf/distributions" <<EOF
+Codename: slp2-tools
+Origin: slp
+Suite: unstable
+Components: main contrib non-free
+Architectures: i386
+Update: slp2-tools-update
+EOF
+
+cat > "$dir/apt.sbs/tools/conf/updates" <<EOF
+Name: slp2-tools-update
+Method: $base/apt.sbs/tools
+EOF
+
+# mirror the debian/squeeze repository
+mkdir -p "$dir/mirror/conf"
+cat > "$dir/mirror/conf/distributions" <<EOF
+Codename: squeeze
+Architectures: i386
+Description: Debian Squeeze
+Components: main contrib non-free
+Update: debian-squeeze-update
+EOF
+
+cat > "$dir/mirror/conf/updates" <<EOF
+Name: debian-squeeze-update
+Architectures: i386
+Method: $base/mirror
+EOF
+# FIXME: filter the list of packages to reduce repository size
+#FilterList: purge mirror.packages
+
+# do the mirroring
+#echo "$CI""Mirroring armel""$CN"
+#(cd "$dir/apt.sbs/armel" && "$rpp" update)
+echo "$CI""Mirroring tools""$CN"
+(cd "$dir/apt.sbs/tools" && "$rpp" update)
+echo "$CI""Mirroring i386""$CN"
+(cd "$dir/apt.sbs/i386" && "$rpp" update)
+echo "$CI""Mirroring Debian""$CN"
+(cd "$dir/mirror" && "$rpp" update)
diff --git a/sbs-make-devkit b/sbs-make-devkit
new file mode 100755
index 0000000..46640e5
--- /dev/null
+++ b/sbs-make-devkit
@@ -0,0 +1,85 @@
+#!/bin/sh
+#
+# Mike McCormack
+# 2011/2/24
+#
+# Build a self-extracting devkit to be used on 2nd party machines
+#
+
+# die: print message to stderr and exit with error code
+#
+# PARAMETERS
+# $1 $2 ... - message to be printed
+die()
+{
+ echo "$CE$N: fatal error: $*$CN" >&2
+ exit 1
+}
+
+# make sure we're not root
+if test `id -u` = "0"
+then
+ die "Please install SBS in a user account, not as root"
+fi
+
+# enable colors only on terminal devices
+TPUT="`which tput`"
+if test -t 0 -a -t 1 -a -n "$TPUT"
+then
+ CI="`$TPUT setf 6 || true`"
+ CE="`$TPUT setf 4 || true`"
+ CX="`$TPUT setf 2 || true`"
+ CN="`$TPUT sgr0 || true`"
+else
+ CI=''
+ CE=''
+ CX=''
+ CN=''
+fi
+
+N="`basename \"$0\"`"
+
+set +e
+
+ms=`which makeself`
+if [ ! "$ms" ]
+then
+ die "makeself is not installed. (try: sudo aptitude install makeself)"
+fi
+
+if [ ! -x ./install-sbs ]
+then
+ die "must be run from sbs git repository"
+fi
+
+# remove everything
+cleanup()
+{
+ rm -rf "$tmpdir"
+}
+
+trap cleanup 0 INT TERM
+
+# setup a temporary home directory
+datestr=`date '+%Y%m%d'`
+tmpdir=`mktemp -d`
+
+# mirroring may take a long time, so cache the mirror
+echo
+echo "$CI""Mirroring debian repositories""$CN"
+echo
+./make-offline-mirror.sh ./repo || die "Mirroring failed"
+
+# make sure SBS is installed
+SBS_INSTALL_DIR="$tmpdir/sbs-install" ./install-sbs || die "SBS install failed"
+
+mirror_dir="$tmpdir"/sbs-install/share/sbs/apt_mirror
+mkdir -p "$mirror_dir"
+cp -R ./repo/* "$mirror_dir/"
+
+echo
+echo "$CI""Creating installer""$CN"
+echo
+makeself "$tmpdir" "sbs-offline-$datestr.sh" "sbs-offline-$datestr" ./sbs-install/share/sbs/scripts/sbs-offline-install || die "failed to build self-extracting archive"
+
+exit 0
diff --git a/share/sbs/boards/generic.conf b/share/sbs/boards/generic.conf
new file mode 100644
index 0000000..5518ea0
--- /dev/null
+++ b/share/sbs/boards/generic.conf
@@ -0,0 +1,11 @@
+# Uncomment line below to avoid shrinking ext4 filesystems
+#SBS_NO_FS_SHRINK=1
+
+APT_OPTS="-oAPT::Get::AllowUnauthenticated=true"
+
+MIN_IO_SIZE=4KiB
+LEB_SIZE=248KiB
+MAX_LEB_CNT=4KiB
+SUB_PAGE_SIZE=4KiB
+PEB_SIZE=256KiB
+VID_HDR_OFFSET=0
diff --git a/share/sbs/boards/slp.conf b/share/sbs/boards/slp.conf
new file mode 100644
index 0000000..389483d
--- /dev/null
+++ b/share/sbs/boards/slp.conf
@@ -0,0 +1,4 @@
+. $SBS_BOARDS_DIR/generic.conf
+ROOT_METAPKG=sbs-image-tizen
+MISC_PKGS="default-files-tizen"
+FLAVOR="c210"
diff --git a/share/sbs/boards/slp.preseed-debconf b/share/sbs/boards/slp.preseed-debconf
new file mode 100644
index 0000000..dfd9a13
--- /dev/null
+++ b/share/sbs/boards/slp.preseed-debconf
@@ -0,0 +1 @@
+#locales-init locales-init/locales-regex string (en_US).*UTF-8
diff --git a/share/sbs/boards/tizen.conf b/share/sbs/boards/tizen.conf
new file mode 100644
index 0000000..f4ec182
--- /dev/null
+++ b/share/sbs/boards/tizen.conf
@@ -0,0 +1,4 @@
+. $SBS_BOARDS_DIR/generic.conf
+ROOT_METAPKG=tizen-clean-armel-pkgs
+MISC_PKGS="default-files-slp"
+FLAVOR="c210"
diff --git a/share/sbs/data/new_part_plan.xml b/share/sbs/data/new_part_plan.xml
new file mode 100644
index 0000000..c9d2b34
--- /dev/null
+++ b/share/sbs/data/new_part_plan.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <partition Name="ums" FileName="ums.bin" DeltaName="" DevType="2" ID="1" Attribute="1" BlockSize="64" BlockLength="1"/>
+ <partition Name="platform" FileName="platform.bin" DeltaName="" DevType="2" ID="2" UpdateAttr="1" BlockSize="64" BlockLength="16384"/>
+ <partition Name="data" FileName="data.bin" DeltaName="" DevType="2" ID="3" Attribute="1" BlockSize="64" BlockLength="48000"/>
+ <partition Name="csc" FileName="csc.bin" DeltaName="" DevType="2" ID="4" Attribute="1" BlockSize="64" BlockLength="2400"/>
+ <partition Name="qboot" FileName="qboot.bin" DeltaName="" DevType="2" ID="6" Attribute="1" BlockSize="64" BlockLength="960"/>
+</root>
diff --git a/share/sbs/default_env/AS b/share/sbs/default_env/AS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/AS
diff --git a/share/sbs/default_env/ASFLAGS b/share/sbs/default_env/ASFLAGS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/ASFLAGS
diff --git a/share/sbs/default_env/CC b/share/sbs/default_env/CC
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/CC
diff --git a/share/sbs/default_env/CCACHE_COMPRESS b/share/sbs/default_env/CCACHE_COMPRESS
new file mode 100644
index 0000000..522d146
--- /dev/null
+++ b/share/sbs/default_env/CCACHE_COMPRESS
@@ -0,0 +1 @@
+CCACHE_COMPRESS=1
diff --git a/share/sbs/default_env/CFLAGS b/share/sbs/default_env/CFLAGS
new file mode 100644
index 0000000..2c0981b
--- /dev/null
+++ b/share/sbs/default_env/CFLAGS
@@ -0,0 +1 @@
+CFLAGS=-Wall
diff --git a/share/sbs/default_env/CPP b/share/sbs/default_env/CPP
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/CPP
diff --git a/share/sbs/default_env/CPPFLAGS b/share/sbs/default_env/CPPFLAGS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/CPPFLAGS
diff --git a/share/sbs/default_env/CXX b/share/sbs/default_env/CXX
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/CXX
diff --git a/share/sbs/default_env/CXXFLAGS b/share/sbs/default_env/CXXFLAGS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/CXXFLAGS
diff --git a/share/sbs/default_env/LD b/share/sbs/default_env/LD
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/LD
diff --git a/share/sbs/default_env/LDFLAGS b/share/sbs/default_env/LDFLAGS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/LDFLAGS
diff --git a/share/sbs/default_env/MAKE b/share/sbs/default_env/MAKE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/MAKE
diff --git a/share/sbs/default_env/MAKEFLAGS b/share/sbs/default_env/MAKEFLAGS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/share/sbs/default_env/MAKEFLAGS
diff --git a/share/sbs/scripts/010.makeimage-hook.checktools.native b/share/sbs/scripts/010.makeimage-hook.checktools.native
new file mode 100755
index 0000000..c95211b
--- /dev/null
+++ b/share/sbs/scripts/010.makeimage-hook.checktools.native
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+echo -n "Checking mkfs.ubifs... "
+ver=`mkfs.ubifs -V`
+[ "$ver" = "Version 1.4" ]
+echo "OK"
+
+echo -n "Checking for mkrfs_3.0.0... "
+which "mkrfs_3.0.0" > /dev/null
+echo "OK"
diff --git a/share/sbs/scripts/099.makeimage-hook.set-hostname.native b/share/sbs/scripts/099.makeimage-hook.set-hostname.native
new file mode 100755
index 0000000..5037aea
--- /dev/null
+++ b/share/sbs/scripts/099.makeimage-hook.set-hostname.native
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo localhost > etc/hostname
+exit 0
diff --git a/share/sbs/scripts/105.makeimage-hook.apt-fixup.sb2 b/share/sbs/scripts/105.makeimage-hook.apt-fixup.sb2
new file mode 100755
index 0000000..ccadc43
--- /dev/null
+++ b/share/sbs/scripts/105.makeimage-hook.apt-fixup.sb2
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+set -x
+
+apt-get update
+apt-get $APT_OPTS install -f -y
diff --git a/share/sbs/scripts/110.makeimage-hook.download-all.sb2 b/share/sbs/scripts/110.makeimage-hook.download-all.sb2
new file mode 100755
index 0000000..844ab99
--- /dev/null
+++ b/share/sbs/scripts/110.makeimage-hook.download-all.sb2
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -x
+
+for i in `seq 1 9`; do
+ apt-get update
+ apt-get $APT_OPTS install -d -y $MISC_PKGS $ROOT_METAPKG && exit 0
+ echo "can't download packages - probably inconsistent repository - sleeping for a while"
+ sleep 10
+done
+
+exit 1
diff --git a/share/sbs/scripts/112.makeimage-hook.preseed-debconf.sb2 b/share/sbs/scripts/112.makeimage-hook.preseed-debconf.sb2
new file mode 100755
index 0000000..3de03ae
--- /dev/null
+++ b/share/sbs/scripts/112.makeimage-hook.preseed-debconf.sb2
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+set -x
+
+conf="$SBS_BOARDS_DIR/${SBS_BOARD_NAME}.preseed-debconf"
+
+if test -e "$conf"; then
+ debconf-set-selections -v "$conf"
+fi
+
+exit 0 \ No newline at end of file
diff --git a/share/sbs/scripts/114.makeimage-hook.pre-default-files.fakeroot b/share/sbs/scripts/114.makeimage-hook.pre-default-files.fakeroot
new file mode 100755
index 0000000..cf72c5c
--- /dev/null
+++ b/share/sbs/scripts/114.makeimage-hook.pre-default-files.fakeroot
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -e
+set -x
+
+mkdir -p etc/init.d etc/rc.d
+if [ -d etc/rc.d/init.d ]; then
+ mv -v etc/rc.d/init.d/* etc/init.d/ || true
+ rmdir etc/rc.d/init.d || rm -r etc/rc.d/init.d
+fi
+ln -s /etc/init.d etc/rc.d/init.d
+
+# mangle /home and /root dirs as in default-files
+mkdir -p opt
+if [ -e home ]; then
+ mv home opt/
+fi
+mkdir -p opt/home
+ln -sf opt/home home
+
+if [ -e root ]; then
+ mv root opt/home/
+fi
+mkdir -p opt/home/root
+ln -sf opt/home/root root
diff --git a/share/sbs/scripts/115.makeimage-hook.install-default-files.sb2 b/share/sbs/scripts/115.makeimage-hook.install-default-files.sb2
new file mode 100755
index 0000000..a4395f2
--- /dev/null
+++ b/share/sbs/scripts/115.makeimage-hook.install-default-files.sb2
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -x
+
+export USER=root
+export LOGNAME=root
+apt-get $APT_OPTS install -y default-files-slp
+cp -a ./default-files/opt/etc/* /etc || true
+
+exit 0
diff --git a/share/sbs/scripts/119.makeimage-hook.repace-bin-sh-with-bash.fakeroot b/share/sbs/scripts/119.makeimage-hook.repace-bin-sh-with-bash.fakeroot
new file mode 100755
index 0000000..ef698f1
--- /dev/null
+++ b/share/sbs/scripts/119.makeimage-hook.repace-bin-sh-with-bash.fakeroot
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -x
+
+# There is a lot of bashisms in post,post-inst/rm scripts - replace /bin/sh with bash
+# to give them a chance to succeed.
+rm -f ./bin/sh.ORIGINAL || true
+mv ./bin/sh ./bin/sh.ORIGINAL
+ln -sf /bin/bash ./bin/sh
+
+exit 0
diff --git a/share/sbs/scripts/120.makeimage-hook.install-pkgs.sb2 b/share/sbs/scripts/120.makeimage-hook.install-pkgs.sb2
new file mode 100755
index 0000000..3662758
--- /dev/null
+++ b/share/sbs/scripts/120.makeimage-hook.install-pkgs.sb2
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -x
+set -e
+
+export USER=root
+export LOGNAME=root
+
+apt-get $APT_OPTS install -y $MISC_PKGS $ROOT_METAPKG
+dpkg --configure -a
+
+exit 0
diff --git a/share/sbs/scripts/121.makeimage-hook.revert-bin-bash-workaround.fakeroot b/share/sbs/scripts/121.makeimage-hook.revert-bin-bash-workaround.fakeroot
new file mode 100755
index 0000000..a615455
--- /dev/null
+++ b/share/sbs/scripts/121.makeimage-hook.revert-bin-bash-workaround.fakeroot
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -x
+
+# Revert the /bin/sh back to original
+rm -f ./bin/sh
+mv ./bin/sh.ORIGINAL ./bin/sh
+
+exit 0
diff --git a/share/sbs/scripts/122.makeimage-hook.prune-metapkgs.sb2 b/share/sbs/scripts/122.makeimage-hook.prune-metapkgs.sb2
new file mode 100755
index 0000000..1d33f50
--- /dev/null
+++ b/share/sbs/scripts/122.makeimage-hook.prune-metapkgs.sb2
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -x
+
+dpkg --get-selections | awk '$1 ~ /^sbs-image-|-pkgs$/ {print $1}' | xargs dpkg --force-depends --remove
+
+exit 0
diff --git a/share/sbs/scripts/123.makeimage-hook.add_systemd.fakeroot b/share/sbs/scripts/123.makeimage-hook.add_systemd.fakeroot
new file mode 100755
index 0000000..3428229
--- /dev/null
+++ b/share/sbs/scripts/123.makeimage-hook.add_systemd.fakeroot
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# Device nodes needed by earlyboot scripts
+
+if [ ! -b dev/mmcblk0 ]; then
+ rm -f dev/mmcblk0
+ mknod dev/mmcblk0 b 179 0
+fi
+
+for i in $(seq 1 16); do
+ if [ ! -b dev/mmcblk0p$i ]; then
+ rm -f dev/mmcblk0p$i
+ mknod dev/mmcblk0p$i b 179 $i
+ fi
+done
+
+n=0
+for i in $(seq 0 2 30); do
+ mknod dev/mtd$n c 90 $i
+ n=$(($n + 1))
+done
diff --git a/share/sbs/scripts/123.makeimage-hook.add_systemd.sb2 b/share/sbs/scripts/123.makeimage-hook.add_systemd.sb2
new file mode 100755
index 0000000..1231c8c
--- /dev/null
+++ b/share/sbs/scripts/123.makeimage-hook.add_systemd.sb2
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -x
+
+[ "$WITH_SYSTEMD" = yes ] || exit 0
+
+pkgs="earlyboot systemd systemd-units-slp-common busybox-systemd-klogd busybox-systemd-sysklogd"
+
+pkgs="systemd-units-slp-${FLAVOR} $pkgs"
+
+apt-get $APT_OPTS install -y $pkgs
+
+exit 0
diff --git a/share/sbs/scripts/123.makeimage-hook.prelink.sb2 b/share/sbs/scripts/123.makeimage-hook.prelink.sb2
new file mode 100755
index 0000000..e436233
--- /dev/null
+++ b/share/sbs/scripts/123.makeimage-hook.prelink.sb2
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -x
+
+[ "$WITH_PRELINK" != "no" ] || exit 0
+
+export USER=root
+export LOGNAME=root
+
+apt-get $APT_OPTS install -y prelink
+prelink --all --verbose
+
+exit 0
diff --git a/share/sbs/scripts/125.makeimage-hook.pkglist-create.sb2 b/share/sbs/scripts/125.makeimage-hook.pkglist-create.sb2
new file mode 100755
index 0000000..2f2cd59
--- /dev/null
+++ b/share/sbs/scripts/125.makeimage-hook.pkglist-create.sb2
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -x
+
+dpkg -l > /installed_pkg_list
+
+ls -lR > /installed_file_list
+
+exit 0
diff --git a/share/sbs/scripts/126.makeimage-hook.pkglist-move.fakeroot b/share/sbs/scripts/126.makeimage-hook.pkglist-move.fakeroot
new file mode 100755
index 0000000..cdf093f
--- /dev/null
+++ b/share/sbs/scripts/126.makeimage-hook.pkglist-move.fakeroot
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -x
+
+if test -e ./installed_pkg_list; then
+ cat ./installed_pkg_list > "$SBS_OUT_DIR/${SBS_IMG_NAME}.INSTALLED_PACKAGES.list" || true
+ cat ./installed_file_list > "$SBS_OUT_DIR/${SBS_IMG_NAME}.INSTALLED_FILES.list" || true
+ rm -f ./installed_pkg_list
+fi
+
+exit 0
diff --git a/share/sbs/scripts/129.makeimage-hook.clean-apt-cache.sb2 b/share/sbs/scripts/129.makeimage-hook.clean-apt-cache.sb2
new file mode 100755
index 0000000..91ff95c
--- /dev/null
+++ b/share/sbs/scripts/129.makeimage-hook.clean-apt-cache.sb2
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+set -x
+
+apt-get clean
+
+exit 0 \ No newline at end of file
diff --git a/share/sbs/scripts/130.makeimage-hook.apply-default-files.fakeroot b/share/sbs/scripts/130.makeimage-hook.apply-default-files.fakeroot
new file mode 100755
index 0000000..1891871
--- /dev/null
+++ b/share/sbs/scripts/130.makeimage-hook.apply-default-files.fakeroot
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+set -x
+
+# XXX Ugly, nasty, bloody hack (read - another one)
+if [ -d ./default-files/etc/rc.d/init.d ]; then
+ mv -f ./default-files/etc/rc.d/init.d/* ./etc/init.d/ || true
+ rmdir ./default-files/etc/rc.d/init.d || rm -r ./default-files/etc/rc.d/init.d || true
+fi
+rm ./default-files/etc/init.d || rm -r ./default-files/etc/init.d || true
+cp -a ./default-files/* ./ || true
+rm -rf ./default-files
+
+exit 0 \ No newline at end of file
diff --git a/share/sbs/scripts/190.makeimage-hook.write-install-ini.fakeroot b/share/sbs/scripts/190.makeimage-hook.write-install-ini.fakeroot
new file mode 100755
index 0000000..a61e2f3
--- /dev/null
+++ b/share/sbs/scripts/190.makeimage-hook.write-install-ini.fakeroot
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+set -e
+set -x
+
+echo "SBS_IMG_NAME=$SBS_IMG_NAME"
+
+# Try to extract major/minor version from image name (SBS_IMG_NAME)
+# Treat everything after last hyphen (-) as minor number and anything
+# before it as major. This heuristic should be compatible with procedure
+# used in scratchbox1.
+#MAJOR="${SBS_IMG_NAME%-*}"
+#MINOR="${SBS_IMG_NAME##*-}"
+MAJOR="2"
+MINOR="0"
+
+# Fallback to defaults if image name didn't contain expected pattern
+#[ "$MAJOR" ] || MAJOR="`date +%Y%m%d`"
+#[ "$MINOR" ] || MINOR="AUTO"
+
+# dump out what we decided on
+echo "MAJOR=$MAJOR"
+echo "MINOR=$MINOR"
+
+for i in etc usr/etc opt/etc; do
+ mkdir -p $i
+ cat >$i/info.ini <<EOF
+[Version]
+Major=$MAJOR;
+Minor=$MINOR;
+Build=$SBS_IMG_NAME;
+Order=;
+[Build]
+Date=`date +%Y.%m.%d`;
+Time=`date +%H:%M:%S`;
+EOF
+done
diff --git a/share/sbs/scripts/200.makeimage-hook.mangle.fakeroot b/share/sbs/scripts/200.makeimage-hook.mangle.fakeroot
new file mode 100755
index 0000000..db08f2b
--- /dev/null
+++ b/share/sbs/scripts/200.makeimage-hook.mangle.fakeroot
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+set -x
+
+ROOTDIR="`pwd`"
+
+## Factory reset
+
+# List of directories to be preserved for "reset to factory defaults" functionality.
+BACKUPLIST="apps data dbspace etc lib media share var"
+
+rdir=opt/system/RestoreDir/
+
+mkdir -p opt/var mnt/data mnt/csc mnt/db
+mkdir -p $rdir
+cp -a var/lib var/cache opt/var
+
+# Capture detailed file list of preserved content. This list will be
+# used at run-time to locate files.
+rldir=opt/system/RestoreDir/list
+
+mkdir -p ${rldir}
+echo "$(ls -c opt)" > "${rldir}/factory_file_opt"
+
+for i in $BACKUPLIST; do
+ if [ -d "opt/${i}" ]; then
+ find "opt/${i}" > "${rldir}/temp"
+ sort -d "${rldir}/temp" > "${rldir}/factory_file_${i}"
+ rm "${rldir}/temp"
+ fi
+done
+
+# Preserve backup in /opt/system/RestoreDir
+for i in $BACKUPLIST; do
+ echo "${i} backup processing..."
+ if [ "${i}" = "apps" ]; then
+ for item in `find opt/apps -maxdepth 2 -name data`; do
+ cp -a --parents "$item" "$rdir"
+ done
+ else
+ cp -a --parents "opt/${i}" "$rdir" || true
+ fi
+done
+
+
+## Split directory hierarchy to partitions - almost verbatim copy of
+## KyuYoung's Kim make-binary.sh
+cd ..
+
+mkdir -p data/var db_fs ums qboot csc
+
+(cd $ROOTDIR/opt && mkdir -p media dbspace var/kdb)
+
+mv $ROOTDIR/opt/media/* ums || true
+
+mv $ROOTDIR/opt/* data
+mkdir -p $ROOTDIR/opt/etc
+cp -a data/etc/passwd data/etc/group $ROOTDIR/opt/etc
+
+exit 0
+
diff --git a/share/sbs/scripts/310.makeimage-hook.create-ubifs.fakeroot b/share/sbs/scripts/310.makeimage-hook.create-ubifs.fakeroot
new file mode 100755
index 0000000..65a0dba
--- /dev/null
+++ b/share/sbs/scripts/310.makeimage-hook.create-ubifs.fakeroot
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
+
+set -e
+set -x
+
+cd ..
+
+for i in $partitions; do
+ mkfs.ubifs -r $i -m "$MIN_IO_SIZE" -e "$LEB_SIZE" -c "$MAX_LEB_CNT" -o ${i}.ubifs
+done
diff --git a/share/sbs/scripts/320.makeimage-hook.create-rfs.fakeroot b/share/sbs/scripts/320.makeimage-hook.create-rfs.fakeroot
new file mode 100755
index 0000000..5697778
--- /dev/null
+++ b/share/sbs/scripts/320.makeimage-hook.create-rfs.fakeroot
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
+
+set -e
+set -x
+
+cd ..
+
+mkrfs_3.0.0 -S 512 -s 32 -F 32 -d ums -c -o 16000M ums.img
+
+exit 0
diff --git a/share/sbs/scripts/330.makeimage-hook.create-ext4-tgz.fakeroot b/share/sbs/scripts/330.makeimage-hook.create-ext4-tgz.fakeroot
new file mode 100755
index 0000000..8564d85
--- /dev/null
+++ b/share/sbs/scripts/330.makeimage-hook.create-ext4-tgz.fakeroot
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
+
+set -e
+set -x
+
+cd ..
+
+partitions="rootdir data"
+
+for i in $partitions; do
+ ( cd $i && tar cpszf ../${i}.tgz --one-file-system . )
+done
+
diff --git a/share/sbs/scripts/420.makeimage-hook.create-ext4-parts.native b/share/sbs/scripts/420.makeimage-hook.create-ext4-parts.native
new file mode 100755
index 0000000..4b6aa20
--- /dev/null
+++ b/share/sbs/scripts/420.makeimage-hook.create-ext4-parts.native
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+set -e
+set -x
+
+PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH"
+XPIT="$SBS_DATA_DIR/new_part_plan.xml"
+BLOCKSZ=1024
+EXT4_BLOCK_SIZE=4096
+
+cd ..
+
+getsize()
+{
+ part="$1"
+
+ BLOCKSIZE="$(xmlgetent -i "$XPIT" -e BlockSize "$part")"
+ BLOCKLENGTH="$(xmlgetent -i "$XPIT" -e BlockLength "$part")"
+
+ if [ -z "$BLOCKSIZE" -o -z "$BLOCKLENGTH" ]; then
+ echo "$0: Invalid BlockSize ($BLOCKSIZE) or BlockLength ($BLOCKLENGTH)" >&2
+ exit 1
+ fi
+
+ SIZE=$(($BLOCKSZ * $BLOCKSIZE * $BLOCKLENGTH))
+ echo -n "$SIZE"
+}
+
+# Create ext4 fs from precreated .tgzs
+for i in *.tgz; do
+ DIRNAME="${i%.tgz}"
+
+ # try to use $DIRNAME as key
+ if xmlgetent -i "$XPIT" "$DIRNAME" >/dev/null 2>&1; then
+ SIZE="$(getsize "$DIRNAME")"
+ elif [ "$DIRNAME" = "rootdir" ]; then
+ SIZE="$(getsize platform)"
+ else
+ echo "$0: Partition name not found in PIT ($DIRNAME)" >&2
+ exit 1
+ fi
+
+ # Check for per-partition block size overrides
+ eval FINAL_BLOCK_SZ='$EXT4_BLOCK_SIZE'_$DIRNAME
+ [ "$FINAL_BLOCK_SZ" ] || FINAL_BLOCK_SZ="$EXT4_BLOCK_SIZE"
+
+ FILE="`sudo \"$(which make-ext4)\" \"$i\" \"$SIZE\" \"$FINAL_BLOCK_SZ\"`"
+ if test -r "$FILE"; then
+ mv -v "$FILE" "${DIRNAME}.ext4"
+ else
+ echo "$0: error: ext4 partition file not created - expected $FILE" >&2
+ exit 1
+ fi
+done
diff --git a/share/sbs/scripts/430.makeimage-hook.shrink-ext4-parts.native b/share/sbs/scripts/430.makeimage-hook.shrink-ext4-parts.native
new file mode 100755
index 0000000..1571010
--- /dev/null
+++ b/share/sbs/scripts/430.makeimage-hook.shrink-ext4-parts.native
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+set -e
+set -x
+
+PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
+
+cd ..
+
+[ "$SBS_NO_FS_SHRINK" ] && exit 0
+
+do_fsck()
+{
+ local devpath
+
+ devpath="$1"
+
+ # die on uncorrected fs errors (e2fsck exit code 4)
+ if ! e2fsck -p -f "$devpath"; then
+ if [ $? -ge 4 ]; then
+ echo "Unable to repair filesystem $devpath. e2fsck exit code=$?" >&2
+ exit 1
+ fi
+ fi
+}
+
+
+for i in *.ext4; do
+ BN="${i%.ext4}"
+
+ echo "$0: Shrinking $BN filesystem to its minimum size"
+
+ do_fsck "$i" # XXX FIXME shouldn't be needed
+ resize2fs -M "$i"
+ do_fsck "$i"
+done
diff --git a/share/sbs/scripts/440.makeimage-hook.mangle-ext4-parts.native b/share/sbs/scripts/440.makeimage-hook.mangle-ext4-parts.native
new file mode 100755
index 0000000..a5e06e2
--- /dev/null
+++ b/share/sbs/scripts/440.makeimage-hook.mangle-ext4-parts.native
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+set -x
+
+cd ..
+
+mv rootdir.ext4 platform.img
+
+for i in $(find . -maxdepth 1 -type f -iname '*.ext4'); do
+ mv "$i" "${i%.ext4}.img"
+done
diff --git a/share/sbs/scripts/500.makeimage-hook.create-final-tars.native b/share/sbs/scripts/500.makeimage-hook.create-final-tars.native
new file mode 100755
index 0000000..9397e16
--- /dev/null
+++ b/share/sbs/scripts/500.makeimage-hook.create-final-tars.native
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+set -x
+
+export GZIP='--rsyncable -9'
+
+test -f boot/uImage && tar zcvf "${SBS_OUT_DIR}/${SBS_IMG_NAME}_${SBS_BOARD_NAME}_kernel.tar.gz" -C boot uImage
+
+cd ..
+
+tar cvf "${SBS_OUT_DIR}/${SBS_IMG_NAME}_C210.tar" data.img platform.img ums.img
+
diff --git a/share/sbs/scripts/find-missingpkgs b/share/sbs/scripts/find-missingpkgs
new file mode 100755
index 0000000..fae57c9
--- /dev/null
+++ b/share/sbs/scripts/find-missingpkgs
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# usage: myname METAPKG..
+#
+# Check if it's possible to install METAPKG.. and print missing dependencies
+# if not. You can specify more than one pkg.
+
+# Example apt-get's output
+#The following packages have unmet dependencies:
+# slp-web-pkgs: Depends: browser but it is not installable
+# Depends: libdownload-agent-0 but it is not installable
+# Depends: libug-download-efl but it is not installable
+# Depends: libwebenginegtk-1 but it is not installable
+# Depends: libug-bookmark-efl but it is not installable
+# Depends: libug-picker-efl but it is not installable
+# Depends: libug-setting-browser-efl but it is not installable
+
+SBS="`which sbs`"
+export SBS_ROOTDIR=$HOME/sbs.ignoremissing.auto
+export LANG=C
+export LC_ALL=C
+
+# entry point
+set -e
+
+if [ $# -lt 1 ]; then
+ echo "usage: $0 METAPKG..." >&2
+ exit 1
+fi
+if [ -z "$SBS" ]; then
+ echo "$0: Error: sbs not found" >&2
+ exit 1
+fi
+
+$SBS -c >/dev/null >&2 || true
+
+cat >$SBS_ROOTDIR/target-armel/walkdep.sh <<"EOF"
+#!/bin/sh
+TRACE=""
+
+walkdep()
+{
+ pkg="$1"
+ backtrace="$2"
+ local d
+ local p
+
+ if [ ! -z "$TRACE" ]; then
+ for i in $TRACE; do
+ [ "$i" = "$pkg" ] && return
+ done
+ fi
+
+ d="`apt-cache showpkg \"$pkg\" 2>/dev/null`"
+
+ if ! echo "$d" | egrep -q "^Package: $pkg"; then
+ echo "$pkg" >> "$F"
+ TRACE="$TRACE $pkg"
+ return
+ fi
+
+ TRACE="$TRACE $pkg"
+ backtrace="$backtrace:$pkg"
+ # traverse deps
+ d="`apt-get install --no-act -y \"$pkg\" 2>/dev/null`"
+
+ p=""
+ if echo "$d" | egrep -q 'Package.*not available.*referred.*another package'; then
+ echo "$pkg" >> "$F"
+ TRACE="$TRACE $pkg"
+ return
+ elif echo "$d" | egrep -q 'packages have unmet dependencies'; then
+ p="`echo \"$d\" | perl -ne 'if (/Depends: (\S+).*(not installable|not going to be installed)$/) { print \"$1\n\"; }'`"
+ fi
+
+ for i in $p; do walkdep $i "$backtrace"; done
+}
+
+F="/tmp/make-ignorepkg.$$"
+
+rm -f "$F" >/dev/null 2>&1
+for i in "$@"; do
+ walkdep "$i" ""
+done
+sort -u < "$F"
+rm -f "$F"
+EOF
+
+$SBS -et apt-get clean >/dev/null 2>&1
+$SBS -et apt-get update >/dev/null 2>&1
+$SBS -et /bin/sh /walkdep.sh "$@" 2>/dev/null
+exit 0
diff --git a/share/sbs/scripts/make-ignorepkg b/share/sbs/scripts/make-ignorepkg
new file mode 100755
index 0000000..e366445
--- /dev/null
+++ b/share/sbs/scripts/make-ignorepkg
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# usage: myname DEBFILE METAPKG [METAPKG...]
+#
+# Create dummy package DEBFILE providing missing packages required to install METAPKGs
+
+cleanup()
+{
+ test ! -z "$T" && rm -r "$T"
+}
+
+# entry point
+set -e
+export LANG=C
+export LC_ALL=C
+ORIGDIR="`pwd`"
+
+if [ $# -lt 2 ]; then
+ echo "usage: $0 OUTFILE_DEB METAPKGs... " >&2
+ exit 1
+fi
+OUTFILE="$1"
+shift
+
+trap cleanup 0
+T="`mktemp -d /tmp/make-ignorepkg.XXXXXX`"
+
+PROVIDES=""
+while [ $# -gt 0 ]; do
+ PKG="$1"
+ shift
+
+ `dirname $0`/find-missingpkgs "$PKG" >> "$T/list"
+done
+
+# Every dependency of METAPKGs can be installed - nothing to do - horray!
+[ -s "$T/list" ] || exit 2;
+
+sort -u < "$T/list" > "$T/list.compact"
+while read line; do
+ PROVIDES="$line, $PROVIDES"
+done < "$T/list.compact"
+PROVIDES="${PROVIDES%, }"
+
+mkdir -p "$T/deb/DEBIAN"
+
+cat >"$T/deb/DEBIAN/control" <<EOF
+Package: dummy-ignore-missing-packages
+Maintainer: Karol Lewandowski <k.lewandowsk@samsung.com>
+Architecture: all
+Version: 1.0
+Provides: $PROVIDES
+Description: Dummy package created to provide missing packages
+EOF
+
+chmod 755 "$T/deb/DEBIAN"
+chmod 644 "$T/deb/DEBIAN/control"
+dpkg-deb -b "$T/deb/" "$OUTFILE"
diff --git a/share/sbs/scripts/pre-debootstrap b/share/sbs/scripts/pre-debootstrap
new file mode 100755
index 0000000..eb668d7
--- /dev/null
+++ b/share/sbs/scripts/pre-debootstrap
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# we are executed with rootfs as cwd
+
+mkdir -p etc var/cache/ldconfig
+touch etc/fstab etc/ld.so.cache
+
diff --git a/share/sbs/scripts/sbs-offline-install b/share/sbs/scripts/sbs-offline-install
new file mode 100755
index 0000000..aaa2ebf
--- /dev/null
+++ b/share/sbs/scripts/sbs-offline-install
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+die()
+{
+ echo "$CE$N: fatal error: $*$CN" >&2
+ exit 1
+}
+
+# make sure we're not root
+if test `id -u` = "0"
+then
+ die "Please install SBS in a user account, not as root"
+fi
+
+# enable colors only on terminal devices
+TPUT="`which tput`"
+if test -t 0 -a -t 1 -a -n "$TPUT"
+then
+ CI="`$TPUT setf 6 || true`"
+ CE="`$TPUT setf 4 || true`"
+ CX="`$TPUT setf 2 || true`"
+ CN="`$TPUT sgr0 || true`"
+else
+ CI=''
+ CE=''
+ CX=''
+ CN=''
+fi
+
+pwd
+echo
+echo "$CX""SBS Offline installer$CN"
+echo
+
+# replace with the new install
+INSTALLDIR="$HOME/sbs-install"
+rm -rf "$HOME/sbs-install"
+mv sbs-install "$HOME"
+
+# check for dpkg-dev
+if ! dpkg-architecture --version >/dev/null 2>&1
+then
+ echo "Before using SBS, please install dpkg-dev:"
+ echo
+ echo "sudo aptitude install dpkg-dev"
+fi
+
+SBS_ROOTDIR=${SBS_ROOTDIR:-$HOME/.sbs}
+if ! test -d "$SBS_ROOTDIR"
+then
+ echo
+ echo "$CX""Run $INSTALLDIR/bin/sbs -c to create your initial environment$CN"
+ echo
+else
+ echo
+ echo "$CX""SBS update successful$CN"
+ echo
+fi
+
+exit 0
diff --git a/share/sbs/t/map/all-notmapped.tmpl b/share/sbs/t/map/all-notmapped.tmpl
new file mode 100644
index 0000000..5a84a3a
--- /dev/null
+++ b/share/sbs/t/map/all-notmapped.tmpl
@@ -0,0 +1,5 @@
+/home => /home
+/home/kenny => /home/kenny
+/proc => /proc
+/dev => /dev
+/sys => /sys
diff --git a/share/sbs/t/map/emulate-bin.t b/share/sbs/t/map/emulate-bin.t
new file mode 100644
index 0000000..0104c9e
--- /dev/null
+++ b/share/sbs/t/map/emulate-bin.t
@@ -0,0 +1,55 @@
+/bin/ash => @TARGET@/bin/busybox
+/bin/bash => @TARGET@/bin/bash
+/bin/busybox => @TARGET@/bin/busybox
+/bin/cat => @TARGET@/bin/busybox
+/bin/chgrp => @TARGET@/bin/busybox
+/bin/chmod => @TARGET@/bin/busybox
+/bin/chown => @TARGET@/bin/busybox
+/bin/cp => @TARGET@/bin/busybox
+/bin/date => @TARGET@/bin/busybox
+/bin/dd => @TARGET@/bin/busybox
+/bin/df => @TARGET@/bin/busybox
+/bin/dmesg => @TARGET@/bin/busybox
+/bin/echo => @TARGET@/bin/busybox
+/bin/egrep => @TARGET@/bin/busybox
+/bin/false => @TARGET@/bin/busybox
+/bin/fgrep => @TARGET@/bin/busybox
+/bin/fsync => @TARGET@/bin/busybox
+/bin/grep => @TARGET@/bin/busybox
+/bin/gunzip => @TARGET@/bin/busybox
+/bin/gzip => @TARGET@/bin/busybox
+/bin/hostname => @TARGET@/bin/busybox
+/bin/ln => @TARGET@/bin/busybox
+/bin/login => @TARGET@/bin/login
+/bin/lsmod => @TARGET@/bin/lsmod
+/bin/ls => @TARGET@/bin/busybox
+/bin/mkdir => @TARGET@/bin/busybox
+/bin/mknod => @TARGET@/bin/busybox
+/bin/mktemp => @TARGET@/bin/busybox
+/bin/more => @TARGET@/bin/busybox
+/bin/mountpoint => @TARGET@/bin/mountpoint
+/bin/mount => @TARGET@/bin/busybox
+/bin/mv => @TARGET@/bin/busybox
+/bin/nc => @TARGET@/bin/busybox
+/bin/pidof => @TARGET@/sbin/killall5
+/bin/pwd => @TARGET@/bin/busybox
+/bin/rbash => @TARGET@/bin/bash
+/bin/readlink => @TARGET@/bin/busybox
+/bin/rmdir => @TARGET@/bin/busybox
+/bin/rm => @TARGET@/bin/busybox
+/bin/run-parts => @TARGET@/bin/run-parts
+/bin/sed => @TARGET@/bin/busybox
+/bin/sh => @TARGET@/bin/busybox
+/bin/sleep => @TARGET@/bin/busybox
+/bin/stty => @TARGET@/bin/busybox
+/bin/su => @TARGET@/bin/su
+/bin/sync => @TARGET@/bin/busybox
+/bin/tar => @TARGET@/bin/busybox
+/bin/tempfile => @TARGET@/bin/tempfile
+/bin/touch => @TARGET@/bin/busybox
+/bin/true => @TARGET@/bin/busybox
+/bin/umount => @TARGET@/bin/busybox
+/bin/uname => @TARGET@/bin/busybox
+/bin/uncompress => @TARGET@/bin/busybox
+/bin/which => @TARGET@/bin/which
+/bin/zcat => @TARGET@/bin/busybox
diff --git a/share/sbs/t/map/emulate-dirs.t b/share/sbs/t/map/emulate-dirs.t
new file mode 100644
index 0000000..aee1553
--- /dev/null
+++ b/share/sbs/t/map/emulate-dirs.t
@@ -0,0 +1,191 @@
+/bin => @TARGET@/bin
+/boot => @TARGET@/boot
+/etc/alternatives => @TARGET@/etc/alternatives
+/etc/apt/apt.conf.d => @TARGET@/etc/apt/apt.conf.d
+/etc/apt/preferences.d => @TARGET@/etc/apt/preferences.d
+/etc/apt/sources.list.d => @TARGET@/etc/apt/sources.list.d
+/etc/apt => @TARGET@/etc/apt
+/etc/apt/trusted.gpg.d => @TARGET@/etc/apt/trusted.gpg.d
+/etc/bash_completion.d => @TARGET@/etc/bash_completion.d
+/etc/cron.daily => @TARGET@/etc/cron.daily
+/etc/default => @TARGET@/etc/default
+/etc/dpkg/dpkg.cfg.d => @TARGET@/etc/dpkg/dpkg.cfg.d
+/etc/dpkg/origins => @TARGET@/etc/dpkg/origins
+/etc/dpkg => @TARGET@/etc/dpkg
+/etc/init.d => @TARGET@/etc/init.d
+/etc/insserv.conf.d => @TARGET@/etc/insserv.conf.d
+/etc/insserv/overrides => @TARGET@/etc/insserv/overrides
+/etc/insserv => @TARGET@/etc/insserv
+/etc/ld.so.conf.d => @TARGET@/etc/ld.so.conf.d
+/etc/logrotate.d => @TARGET@/etc/logrotate.d
+/etc/lsb-base => @TARGET@/etc/lsb-base
+/etc/modprobe.d => @TARGET@/etc/modprobe.d
+/etc/network/if-up.d => @TARGET@/etc/network/if-up.d
+/etc/network => @TARGET@/etc/network
+/etc/opt => @TARGET@/etc/opt
+/etc/rc0.d => @TARGET@/etc/rc0.d
+/etc/rc1.d => @TARGET@/etc/rc1.d
+/etc/rc2.d => @TARGET@/etc/rc2.d
+/etc/rc3.d => @TARGET@/etc/rc3.d
+/etc/rc4.d => @TARGET@/etc/rc4.d
+/etc/rc5.d => @TARGET@/etc/rc5.d
+/etc/rc6.d => @TARGET@/etc/rc6.d
+/etc/rcS.d => @TARGET@/etc/rcS.d
+/etc/skel => @TARGET@/etc/skel
+/etc => @TARGET@/etc
+/etc/terminfo => @TARGET@/etc/terminfo
+/etc/udev/.dev => @TARGET@/etc/udev/.dev
+/etc/udev/rules.d => @TARGET@/etc/udev/rules.d
+/etc/udev => @TARGET@/etc/udev
+/lib/firmware => @TARGET@/lib/firmware
+/lib/init => @TARGET@/lib/init
+/lib/lsb => @TARGET@/lib/lsb
+/lib/modules => @TARGET@/lib/modules
+/lib => @TARGET@/lib
+/lib/terminfo => @TARGET@/lib/terminfo
+/lib/udev/devices => @TARGET@/lib/udev/devices
+/lib/udev => @TARGET@/lib/udev
+/mnt => @TARGET@/mnt
+/opt => @TARGET@/opt
+/root => @TARGET@/root
+/sbin => @TARGET@/sbin
+/srv => @TARGET@/srv
+/usr/bin => @TARGET@/usr/bin
+/usr/games => @TARGET@/usr/games
+/usr/include/arpa => @TARGET@/usr/include/arpa
+/usr/include/asm-generic => @TARGET@/usr/include/asm-generic
+/usr/include/asm => @TARGET@/usr/include/asm
+/usr/include/bits => @TARGET@/usr/include/bits
+/usr/include/drm => @TARGET@/usr/include/drm
+/usr/include/gnu => @TARGET@/usr/include/gnu
+/usr/include/linux/byteorder => @TARGET@/usr/include/linux/byteorder
+/usr/include/linux/can => @TARGET@/usr/include/linux/can
+/usr/include/linux/dvb => @TARGET@/usr/include/linux/dvb
+/usr/include/linux/hdlc => @TARGET@/usr/include/linux/hdlc
+/usr/include/linux/isdn => @TARGET@/usr/include/linux/isdn
+/usr/include/linux/netfilter_arp => @TARGET@/usr/include/linux/netfilter_arp
+/usr/include/linux/netfilter_bridge => @TARGET@/usr/include/linux/netfilter_bridge
+/usr/include/linux/netfilter_ipv4 => @TARGET@/usr/include/linux/netfilter_ipv4
+/usr/include/linux/netfilter_ipv6 => @TARGET@/usr/include/linux/netfilter_ipv6
+/usr/include/linux/netfilter => @TARGET@/usr/include/linux/netfilter
+/usr/include/linux/nfsd => @TARGET@/usr/include/linux/nfsd
+/usr/include/linux/raid => @TARGET@/usr/include/linux/raid
+/usr/include/linux/spi => @TARGET@/usr/include/linux/spi
+/usr/include/linux/sunrpc => @TARGET@/usr/include/linux/sunrpc
+/usr/include/linux => @TARGET@/usr/include/linux
+/usr/include/linux/tc_act => @TARGET@/usr/include/linux/tc_act
+/usr/include/linux/tc_ematch => @TARGET@/usr/include/linux/tc_ematch
+/usr/include/linux/usb => @TARGET@/usr/include/linux/usb
+/usr/include/linux/wimax => @TARGET@/usr/include/linux/wimax
+/usr/include/mtd => @TARGET@/usr/include/mtd
+/usr/include/netash => @TARGET@/usr/include/netash
+/usr/include/netatalk => @TARGET@/usr/include/netatalk
+/usr/include/netax25 => @TARGET@/usr/include/netax25
+/usr/include/neteconet => @TARGET@/usr/include/neteconet
+/usr/include/netinet => @TARGET@/usr/include/netinet
+/usr/include/netipx => @TARGET@/usr/include/netipx
+/usr/include/netiucv => @TARGET@/usr/include/netiucv
+/usr/include/netpacket => @TARGET@/usr/include/netpacket
+/usr/include/netrom => @TARGET@/usr/include/netrom
+/usr/include/netrose => @TARGET@/usr/include/netrose
+/usr/include/net => @TARGET@/usr/include/net
+/usr/include/nfs => @TARGET@/usr/include/nfs
+/usr/include/protocols => @TARGET@/usr/include/protocols
+/usr/include/rdma => @TARGET@/usr/include/rdma
+/usr/include/rpcsvc => @TARGET@/usr/include/rpcsvc
+/usr/include/rpc => @TARGET@/usr/include/rpc
+/usr/include/scsi => @TARGET@/usr/include/scsi
+/usr/include/sound => @TARGET@/usr/include/sound
+/usr/include/sys => @TARGET@/usr/include/sys
+/usr/include => @TARGET@/usr/include
+/usr/include/video => @TARGET@/usr/include/video
+/usr/lib/apt/methods => @TARGET@/usr/lib/apt/methods
+/usr/lib/apt => @TARGET@/usr/lib/apt
+/usr/lib/dpkg/methods/apt => @TARGET@/usr/lib/dpkg/methods/apt
+/usr/lib/dpkg/methods => @TARGET@/usr/lib/dpkg/methods
+/usr/lib/dpkg => @TARGET@/usr/lib/dpkg
+/usr/lib/gcc/arm-linux-gnueabi => @TARGET@/usr/lib/gcc/arm-linux-gnueabi
+/usr/lib/gcc => @TARGET@/usr/lib/gcc
+/usr/lib/gconv => @TARGET@/usr/lib/gconv
+/usr/lib/hotplug => @TARGET@/usr/lib/hotplug
+/usr/lib/locale => @TARGET@/usr/lib/locale
+/usr/lib/mime/packages => @TARGET@/usr/lib/mime/packages
+/usr/lib/mime => @TARGET@/usr/lib/mime
+/usr/lib/perl/5.10.1/Scalar => @TARGET@/usr/lib/perl/5.10.1/Scalar
+/usr/lib/perl/5.10.1 => @TARGET@/usr/lib/perl/5.10.1
+/usr/lib/perl => @TARGET@/usr/lib/perl
+/usr/lib/python2. => @TARGET@/usr/lib/python2.
+/usr/lib => @TARGET@/usr/lib
+/usr/local/bin => @TARGET@/usr/local/bin
+/usr/local/etc => @TARGET@/usr/local/etc
+/usr/local/games => @TARGET@/usr/local/games
+/usr/local/include => @TARGET@/usr/local/include
+/usr/local/lib => @TARGET@/usr/local/lib
+/usr/local/sbin => @TARGET@/usr/local/sbin
+/usr/local/share => @TARGET@/usr/local/share
+/usr/local/src => @TARGET@/usr/local/src
+/usr/local => @TARGET@/usr/local
+/usr/sbin => @TARGET@/usr/sbin
+/usr/share/apt => @TARGET@/usr/share/apt
+/usr/share/base-files => @TARGET@/usr/share/base-files
+/usr/share/base-passwd => @TARGET@/usr/share/base-passwd
+/usr/share/bug/apt => @TARGET@/usr/share/bug/apt
+/usr/share/bug/locales => @TARGET@/usr/share/bug/locales
+/usr/share/bug => @TARGET@/usr/share/bug
+/usr/share/common-licenses => @TARGET@/usr/share/common-licenses
+/usr/share/debconf => @TARGET@/usr/share/debconf
+/usr/share/debianutils => @TARGET@/usr/share/debianutils
+/usr/share/dict => @TARGET@/usr/share/dict
+/usr/share/doc => @TARGET@/usr/share/doc
+/usr/share/dpkg => @TARGET@/usr/share/dpkg
+/usr/share/i18n/charmaps => @TARGET@/usr/share/i18n/charmaps
+/usr/share/i18n/locales => @TARGET@/usr/share/i18n/locales
+/usr/share/i18n => @TARGET@/usr/share/i18n
+/usr/share/info => @TARGET@/usr/share/info
+/usr/share/initscripts => @TARGET@/usr/share/initscripts
+/usr/share/insserv => @TARGET@/usr/share/insserv
+/usr/share/lintian => @TARGET@/usr/share/lintian
+/usr/share/locale => @TARGET@/usr/share/locale
+/usr/share/man => @TARGET@/usr/share/man
+/usr/share/menu => @TARGET@/usr/share/menu
+/usr/share/misc => @TARGET@/usr/share/misc
+/usr/share/perl5 => @TARGET@/usr/share/perl5
+/usr/share/perl => @TARGET@/usr/share/perl
+/usr/share/pixmaps => @TARGET@/usr/share/pixmaps
+/usr/share/sysv-rc => @TARGET@/usr/share/sysv-rc
+/usr/share/tabset => @TARGET@/usr/share/tabset
+/usr/share => @TARGET@/usr/share
+/usr/share/terminfo => @TARGET@/usr/share/terminfo
+/usr/src => @TARGET@/usr/src
+/usr => @TARGET@/usr
+/var/backups => @TARGET@/var/backups
+/var/cache/apt/archives/partial => @TARGET@/var/cache/apt/archives/partial
+/var/cache/apt/archives => @TARGET@/var/cache/apt/archives
+/var/cache/apt => @TARGET@/var/cache/apt
+/var/cache/debconf => @TARGET@/var/cache/debconf
+/var/cache/ldconfig => @TARGET@/var/cache/ldconfig
+/var/cache => @TARGET@/var/cache
+/var/lib/apt/lists/partial => @TARGET@/var/lib/apt/lists/partial
+/var/lib/apt/lists => @TARGET@/var/lib/apt/lists
+/var/lib/apt/periodic => @TARGET@/var/lib/apt/periodic
+/var/lib/apt => @TARGET@/var/lib/apt
+/var/lib/dpkg/alternatives => @TARGET@/var/lib/dpkg/alternatives
+/var/lib/dpkg/info => @TARGET@/var/lib/dpkg/info
+/var/lib/dpkg/parts => @TARGET@/var/lib/dpkg/parts
+/var/lib/dpkg => @TARGET@/var/lib/dpkg
+/var/lib/dpkg/triggers => @TARGET@/var/lib/dpkg/triggers
+/var/lib/dpkg/updates => @TARGET@/var/lib/dpkg/updates
+/var/lib/initscripts => @TARGET@/var/lib/initscripts
+/var/lib/insserv => @TARGET@/var/lib/insserv
+/var/lib/libuuid => @TARGET@/var/lib/libuuid
+/var/lib/misc => @TARGET@/var/lib/misc
+/var/lib => @TARGET@/var/lib
+/var/lib/update-rc.d => @TARGET@/var/lib/update-rc.d
+/var/lib/urandom => @TARGET@/var/lib/urandom
+/var/local => @TARGET@/var/local
+/var/lock => @TARGET@/var/lock
+/var/log => @TARGET@/var/log
+/var/mail => @TARGET@/var/mail
+/var/opt => @TARGET@/var/opt
+/var/spool => @TARGET@/var/spool
+/var => @TARGET@/var
diff --git a/share/sbs/t/map/emulate-notmapped.t b/share/sbs/t/map/emulate-notmapped.t
new file mode 120000
index 0000000..c9bb2f1
--- /dev/null
+++ b/share/sbs/t/map/emulate-notmapped.t
@@ -0,0 +1 @@
+all-notmapped.tmpl \ No newline at end of file
diff --git a/share/sbs/t/map/slp2-basic.t b/share/sbs/t/map/slp2-basic.t
new file mode 100644
index 0000000..410afbe
--- /dev/null
+++ b/share/sbs/t/map/slp2-basic.t
@@ -0,0 +1,78 @@
+/bin/sh => @TOOLS@/bin/bash (readonly)
+/bin/ps => /bin/ps (readonly)
+/bin/bzip2 => @TOOLS@/bin/bzip2 (readonly)
+/bin/bunzip2 => @TOOLS@/bin/bunzip2 (readonly)
+/bin/gzip => @TOOLS@/bin/gzip (readonly)
+/bin/gunzip => @TOOLS@/bin/gunzip (readonly)
+/bin/cat => @TOOLS@/bin/cat (readonly)
+/bin/chgrp => @TOOLS@/bin/chgrp (readonly)
+/bin/chmod => @TOOLS@/bin/chmod (readonly)
+/bin/chown => @TOOLS@/bin/chown (readonly)
+/bin/cpio => @TOOLS@/bin/cpio (readonly)
+/bin/date => @TOOLS@/bin/date (readonly)
+/bin/egrep => @TOOLS@/bin/egrep (readonly)
+/bin/fgrep => @TOOLS@/bin/fgrep (readonly)
+/bin/grep => @TOOLS@/bin/grep (readonly)
+/bin/tar => @TOOLS@/bin/tar (readonly)
+/bin/rm => @TOOLS@/bin/rm (readonly)
+/bin/cp => @TOOLS@/bin/cp (readonly)
+/bin/ls => @TOOLS@/bin/ls (readonly)
+/bin/kill => @TOOLS@/bin/kill (readonly)
+/bin/sed => @TOOLS@/bin/sed (readonly)
+/usr/share/gnome-common => @TARGET@/usr/share/gnome-common (readonly)
+/usr/share/glib-2.0 => @TARGET@/usr/share/glib-2.0 (readonly)
+/usr/share/zoneinfo => @TARGET@/usr/share/zoneinfo (readonly)
+/usr/share/dbus-1 => @TARGET@/usr/share/dbus-1 (readonly)
+/usr/share/zoneinfo => @TARGET@/usr/share/zoneinfo (readonly)
+/usr/share/idl => @TARGET@/usr/share/idl (readonly)
+/usr/share/w3c-libwww => @TARGET@/usr/share/w3c-libwww (readonly)
+/usr/share/libwww => @TARGET@/usr/share/libwww (readonly)
+/usr/share/doc => @TARGET@/usr/share/doc (readonly)
+/usr/share/libtool => @TOOLS@/usr/share/libtool (readonly)
+/usr/share/octave => @TARGET@/usr/share/octave (readonly)
+/usr/share/mime => @TARGET@/usr/share/mime (readonly)
+/usr/share/pkgconfig/shared-mime-info.pc => @TARGET@/usr/share/pkgconfig/shared-mime-info.pc (readonly)
+/usr/share/icu => @TARGET@/usr/share/icu (readonly)
+/usr/share/qt => @TARGET@/usr/share/qt (readonly)
+/usr/share => @TOOLS@/usr/share (readonly)
+/usr/bin/sb2-show => /usr/bin/sb2-show (readonly)
+/usr/bin/localedef => @TARGET@/usr/bin/localedef (readonly)
+/usr/bin/chrpath => @TARGET@/usr/bin/chrpath (readonly)
+/usr/bin/localedef => @TARGET@/usr/bin/localedef (readonly)
+/usr/bin/perl => @TOOLS@/usr/bin/perl (readonly)
+/usr/bin/python => @TOOLS@/usr/bin/python (readonly)
+/usr/lib/gcc => @TOOLS@/usr/lib/gcc (readonly)
+/usr/lib/dpkg => @TOOLS@/usr/lib/dpkg (readonly)
+/usr/lib/apt => @TOOLS@/usr/lib/apt (readonly)
+/usr/lib/cdbs => @TOOLS@/usr/lib/cdbs (readonly)
+/usr/lib/libfakeroot => @TOOLS@/usr/lib/libfakeroot (readonly)
+/usr/lib/man-db => @TOOLS@/usr/lib/man-db (readonly)
+/usr/lib => @TARGET@/usr/lib (readonly)
+/usr/src => @TARGET@/usr/src (readonly)
+/usr/X11R6/lib => @TARGET@/usr/X11R6/lib (readonly)
+/usr/X11R6/include => @TARGET@/usr/X11R6/include (readonly)
+/usr/sbin/update-locale => @TARGET@/usr/sbin/update-locale (readonly)
+/usr/sbin/validlocale => @TARGET@/usr/sbin/validlocale (readonly)
+/usr/sbin/localegen => @TARGET@/usr/sbin/localegen (readonly)
+/usr => @TOOLS@/usr (readonly)
+/etc/gconf/2 => @TARGET@/etc/gconf/2 (readonly)
+/etc/dbus-1 => @TARGET@/etc/dbus-1 (readonly)
+/etc/gtk-2.0 => @TARGET@/etc/gtk-2.0 (readonly)
+/etc/apt => @TARGET@/etc/apt (readonly)
+/etc/resolvconf => /etc/resolvconf (readonly)
+/etc/passwd => /etc/passwd (readonly)
+/etc/shadow => /etc/shadow (readonly)
+/etc => @TOOLS@/etc (readonly)
+/var/run/resolvconf => /var/run/resolvconf (readonly)
+/var/lib/xkb => @TARGET@/var/lib/xkb (readonly)
+/var/lib/apt => @TARGET@/var/lib/apt (readonly)
+/var/cache/apt => @TARGET@/var/cache/apt (readonly)
+/var/lib/dpkg => @TARGET@/var/lib/dpkg (readonly)
+/var/cache/dpkg => @TARGET@/var/cache/dpkg (readonly)
+/var/cache/debconf => @TARGET@/var/cache/debconf (readonly)
+/var/lib/dbus => @TARGET@/var/lib/dbus (readonly)
+/var/log => @TARGET@/var/log (readonly)
+/var => @TOOLS@/var (readonly)
+@TOOLS@ => @TOOLS@ (readonly)
+/target_root => @TARGET@
+/ => /
diff --git a/share/sbs/t/map/slp2-notmapped.t b/share/sbs/t/map/slp2-notmapped.t
new file mode 120000
index 0000000..c9bb2f1
--- /dev/null
+++ b/share/sbs/t/map/slp2-notmapped.t
@@ -0,0 +1 @@
+all-notmapped.tmpl \ No newline at end of file
diff --git a/share/sbs/t/script/Makefile b/share/sbs/t/script/Makefile
new file mode 100644
index 0000000..9b5982a
--- /dev/null
+++ b/share/sbs/t/script/Makefile
@@ -0,0 +1,26 @@
+TEST_SCRIPT = $(shell pwd)/../../sbs
+TESTTMPL = template.t-start
+TESTPARTS = $(shell echo t-*.part)
+TESTCASES = $(TESTPARTS:part=sh)
+TESTRUN = $(TESTPARTS:part=run-test.t)
+LOGDIR := $(shell mktemp -d /tmp/sbs_t.XXXXXX)
+
+%.sh : %.part $(TESTTMPL)
+ @echo "Preparing testcase $@"
+ @rm -f $@
+ @(cat $(TESTTMPL) && printf "\n# DO NOT EDIT THIS FILE - edit $< and run make clean && make\n\n" '>' && cat $< ) >> $@
+ @chmod +x $@
+
+%.run-test.t : %.sh
+ @mkdir $(LOGDIR)/$@
+ @echo "Running testcase $< (log $(LOGDIR)/$@.LOG)"
+ @./run-test.sh "$(TEST_SCRIPT)" `pwd`/$< $(LOGDIR)/$@.LOG $(LOGDIR)/$@
+ rm -r $(LOGDIR)/$@
+
+all: $(TESTCASES) $(TESTRUN)
+
+clean:
+ rm -f $(TESTCASES)
+
+clobber: clean
+ rm -f *~
diff --git a/share/sbs/t/script/run-test.sh b/share/sbs/t/script/run-test.sh
new file mode 100755
index 0000000..603b82d
--- /dev/null
+++ b/share/sbs/t/script/run-test.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+set -e
+set -u
+
+if [ $# -lt 3 ]
+then
+ echo "$0: invoked with wrong number of parameters"
+ echo "usage: PATH_TO_PROGRAM PATH_TO_TEST LOGFILE WORKDIR"
+ exit 1
+fi
+
+PROG="$1"
+TEST="$2"
+LOG="$3"
+DIR="$4"
+shift 4
+
+mkdir -p "$DIR"
+cd "$DIR"
+
+TN="`basename $TEST`"
+
+set +e
+$TEST "$PROG" "$@" > "$LOG" 2>&1
+
+if [ $? -eq 0 ]
+then
+ echo "${TN}: passed" | tee -a "$LOG"
+else
+ echo "${TN}: failed" | tee -a "$LOG"
+fi
diff --git a/share/sbs/t/script/t-testsystem-fail.part b/share/sbs/t/script/t-testsystem-fail.part
new file mode 100644
index 0000000..12c7a32
--- /dev/null
+++ b/share/sbs/t/script/t-testsystem-fail.part
@@ -0,0 +1,2 @@
+lx echo "This test should always fail."
+lx exit 1
diff --git a/share/sbs/t/script/t-testsystem-pass.part b/share/sbs/t/script/t-testsystem-pass.part
new file mode 100644
index 0000000..bff72a2
--- /dev/null
+++ b/share/sbs/t/script/t-testsystem-pass.part
@@ -0,0 +1,2 @@
+lx echo "This test should always pass."
+lx exit 0
diff --git a/share/sbs/t/script/template.t-start b/share/sbs/t/script/template.t-start
new file mode 100644
index 0000000..58f7aef
--- /dev/null
+++ b/share/sbs/t/script/template.t-start
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -e
+set -u
+
+# ARGS:
+# 1: path to script
+
+# assumptions:
+# - we are executed in specially crafted/temporary working directory
+# - output is redirected to logfile
+
+# log exec call
+lx()
+{
+ echo ">>> T: $@"
+ "$@"
+}
+
+if [ $# -lt 1 ]
+then
+ echo "usage: $0 PATH_TO_PROG ..."
+ exit 1
+fi
+
+EXEC="$1"
+
diff --git a/share/sbs/wrappers/scp b/share/sbs/wrappers/scp
new file mode 100755
index 0000000..f6e02a0
--- /dev/null
+++ b/share/sbs/wrappers/scp
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+fileopt()
+{
+ [ -e "$HOME/.ssh/$2" ] && echo "-$1$HOME/.ssh/$2" || echo -B
+}
+
+exec /usr/bin/scp \
+"`fileopt F config`" \
+"`fileopt oUserKnownHostsFile= known_hosts`" \
+"`fileopt oIdentityFile= identity`" \
+"`fileopt oIdentityFile= id_rsa`" \
+"`fileopt oIdentityFile= id_dsa`" \
+"$@"
diff --git a/share/sbs/wrappers/wget b/share/sbs/wrappers/wget
new file mode 100755
index 0000000..769fbbb
--- /dev/null
+++ b/share/sbs/wrappers/wget
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec /usr/bin/wget --no-cache "$@"