Create Debian packs

From XApple
Jump to: navigation, search

Contents

Prepare Debian Build Environment

Install related packages on the host machine. Suggested host OS'es include Debian 8 and above, and Ubuntu 14.04 and above.

$ sudo apt-get install pbuilder build-essential debhelper devscripts fakeroot \
  live-build linaro-image-tools gdisk qemu-user-static apt-cacher-ng

Create a chroot working environment for the ARM architecture.

$ sudo pbuilder --create --basetgz /var/cache/pbuilder/debian-stable-armhf.tgz \
  --distribution stable --architecture armhf \
  --components main --debootstrap qemu-debootstrap \
  --debootstrapopts --arch=armhf \
  --mirror ftp://ftp.jp.debian.org/debian/

Before proceeding to other procedures in this document, we'll assume the top working directory is in a path named $TOP, which may, for example, be defined by 'export TOP=$HOME'.

Note:

1. Other mirror site can be used, e.g. ftp://ftp.cn.debian.org/debian/.

2. If the process failed with the "E: Release signed by unknown key (key id xxxx)" message, one solution is to add the "--debootstrapopts --no-check-gpg" option to skip the GPG checking. (This may occurs if the host OS is Ubuntu 12.04.)

Create Debian rootfs

In this section we create a Debian Stable armhf rootfs.

Install packages for live build

Use "live-build" to create Debian binary rootfs. You'll need to install "live-build" first.

sudo apt-get install live-build qemu-user-static

Apply a patch for bug 780627

Be aware of bug 780627. (As a note, this bug has been fixed in the up-to-date version of binary_tar. Thus, this step may be skipped.)

sudo sed -i.bak 's/[$][{]LIVE_IMAGE_NAME[}]-[$][{]LIVE_IMAGE_ARCHITECTURE[}][.]$/binary/' /usr/lib/live/build/binary_tar

Create a temporary work directory

Make an empty directory, for example, "/tmp/live_cd". Then, enter the created directory.

mkdir -p /tmp/live_cd
cd /tmp/live_cd

Configure for the live build process

Execute the following commands.

lb config --apt-indices none --architectures armhf \
 --binary-images tar --binary-filesystem ext3 \
 --bootloader "" --cache false --chroot-filesystem none \
 --debian-installer-gui false --distribution stable \
 --parent-distribution stable \
 --parent-debian-installer-distribution stable \
 --gzip-options '--best --rsyncable' --initramfs none \
 --linux-flavours none --linux-packages none \
 --bootstrap-qemu-arch armhf \
 --bootstrap-qemu-static /usr/bin/qemu-arm-static

Add some hook scripts for live build

Create "./config/hooks/0001-setup_user_linaro.hook.chroot" as an executable shell script:

#!/bin/sh  

echo "I: create linaro user"
adduser --gecos linaro --disabled-login linaro

echo "I: set linaro user password"
echo "linaro:linaro" | chpasswd

Create "./config/hooks/0002-add_linaro_to_groups.hook.chroot" as an executable shell script:

#!/bin/sh -x 

DEFGROUPS="sudo,adm,dialout,cdrom,audio,dip,video,plugdev,bluetooth"

echo "I: add linaro to ($DEFGROUPS) groups"
usermod -a -G ${DEFGROUPS} linaro

Create "./config/hooks/0052-remove_etc_parts.hook.binary" as an executable shell script:

#!/bin/sh  

cd binary

echo "I: rm /etc/resolv.conf"
rm -f ./etc/resolv.conf

Change mode for the created files.

chmod a+rx ./config/hooks/*

Create the package list

Create "./config/package-lists/lxde-desktop.list.chroot" as below:

task-lxde-desktop
task-chinese-s-desktop
aptitude
kernel-package
cpio
u-boot-tools
lzop
device-tree-compiler
initramfs-tools
lzma
patchutils
kernel-wedge
python
python-six
network-manager-gnome
ntp
ntpdate
fcitx
im-config
bluez

Build and create the rootfs image

Re-run "lb config" and "lb build". (This step may costs more than two hours.)

lb config
env http_proxy="http://127.0.0.1:3142" sudo -E lb build

Compress the created rootfs

We should have a "live-image-armhf.tar.tar" generated now. Use "xz" to convert it to "live-image-armhf.tar.tar.xz".

xz -9e live-image-armhf.tar.tar

Get the final rootfs image

Rename it to the final rootfs image "debian-8.0-live-lxde-image-armhf.tar.tar.xz"

mv live-image-armhf.tar.tar.xz debian-8.0-live-lxde-image-armhf.tar.tar.xz

Build bootloader Debian package

Start the work in the $TOP directory defined above.

Clone the owl project from github

The owl project contains the bootloader blob (mbrec).

git clone https://github.com/xapp-le/owl.git

Check out the needed version

Checkout and rebase a branch for debuild.

cd owl
git checkout debian1
git rebase master

Perform 'debuild'

Create the debian package for the boodloader.

debuild

Build bootloader Debian package

Start the work in the $TOP directory defined above.

Clone the u-boot project from github

The u-boot project contains the u-boot source.

git clone https://github.com/xapp-le/u-boot.git

Check out the needed version

Checkout and rebase a branch for debuild.

cd owl
git checkout debian1
git rebase master

Perform 'debuild'

Create the debian package for u-boot.

pdebuild --buildresult .. -- --basetgz /var/cache/pbuilder/debian-stable-armhf.tgz

Build kernel Debian package

Login into the armhf chroot environment

mkdir -p /tmp/pb001; sudo pbuilder --login --basetgz /var/cache/pbuilder/debian-stable-armhf.tgz --bindmounts /tmp/pb001

Install build dependencies

apt-get install kernel-package cpio libncurses-dev u-boot-tools lzop device-tree-compiler docbook-utils \
                initramfs-tools fakeroot debhelper devscripts lzma quilt patchutils kernel-wedge \
                python python-six git wget less

Apply patch for bug #782759

wget --no-check-certificate -O /tmp/bug782759.patch -c 'https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=782759;filename=add_dtbs.patch;msg=10;att=1'
patch /usr/share/kernel-package/ruleset/targets/image.mk /tmp/bug782759.patch

Enter kernel directory

cd /tmp/pb001/kernel

Fix an issue in the kernel make file

There may be a bug on executing xargs rm in qemu. We need to modify every xargs rm in the kernel Makefile.

sed -i.bak 's/xargs rm -f/xargs -s 122880 rm -f/' Makefile

Select the kernel config file

make ARCH=arm actduino_bubble_gum_linux_defconfig

Build the kernel

DEB_HOST_ARCH=armhf make-kpkg --initrd --append-to-version .xapple-1-atm7059a --overlay-dir /tmp/pb001/kernel-package --revision 3.10.37-1 --arch arm buildpackage

You might encounter some compiler errors here. But don't worry, continue with the next step.

DEB_HOST_ARCH=armhf make-kpkg --initrd --append-to-version .xapple-1-atm7059a --overlay-dir /tmp/pb001/kernel-package --revision 3.10.37-1 --arch arm binary

Build hwpack

Install tools

sudo apt-get install linaro-image-tools gdisk qemu-user-static

Create the hwpack config file

vim linaro-debian-atm7059a

Enter the following contents and save it.

[hwpack]
format=2.0
name=linaro-debian-atm7059a
architectures=armhf
origin=Linaro
maintainer=Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
support=unsupported
packages=linux-image-armmp linux-image-3.10.37.xapple-1-atm7059a
mmc_id=0:2
u_boot_package=u-boot-atm7059a
u_boot_file=usr/lib/u-boot-atm7059a/u-boot-dtb.img
u_boot_in_boot_part=Yes
u_boot_dd=6144
serial_tty=ttyS2
kernel_addr=0x00008000
initrd_addr=0x01ffffc0
load_addr=0x00008000
partition_layout=reserved_bootfs_rootfs
kernel_file=boot/vmlinuz-*-atm7059a
initrd_file=boot/initrd.img-*-atm7059a
dtb_file=usr/lib/linux-image-*-atm7059a/actduino_bubble_gum_sdboot_linux.dtb
dtb_addr=0x04000000
boot_script=boot.scr
extra_serial_options=console=tty0 console=ttyS2,115200n8
loader_start=34
loader_min_size=12
spl_package=bootloader-atm7059a
spl_file=usr/lib/bootloader-atm7059a/bootloader.bin
spl_dd=4097

[debian]
sources-entry=http://ftp.us.debian.org/debian/ stable main

Create the hwpack file

linaro-hwpack-create \
  --local-deb bootloader-atm7059a_0.20150803_all.deb \
  --local-deb u-boot-atm7059a_2015.04.atm7059a_armhf.deb \
  --local-deb linux-image-3.10.37.xapple-1-atm7059a_3.10.37-1_armhf.deb \
  linaro-debian-atm7059a 1
Personal tools
Namespaces

Variants
Actions
Navigation
Tools