From 9aba160745d4e3295a90d9befc4f01f45d991966 Mon Sep 17 00:00:00 2001
From: Manuel Traut <manut@linutronix.de>
Date: Fri, 17 Jan 2014 22:37:53 +0100
Subject: finish work on elbe example and slides

- tested with elbe from git 8c697255bd58437a1466b6d8cc46b7dbcd2a87ed

Signed-off-by: Manuel Traut <manut@linutronix.de>
---
 distribution/elbe-example/pres_elbe-example_en.tex | 208 ++++++++++++++++-----
 1 file changed, 158 insertions(+), 50 deletions(-)

(limited to 'distribution/elbe-example/pres_elbe-example_en.tex')

diff --git a/distribution/elbe-example/pres_elbe-example_en.tex b/distribution/elbe-example/pres_elbe-example_en.tex
index eb64782..db8c2d7 100644
--- a/distribution/elbe-example/pres_elbe-example_en.tex
+++ b/distribution/elbe-example/pres_elbe-example_en.tex
@@ -1,11 +1,8 @@
 \input{configpres}
 
-\lstset{language=c}
-
 \title{ELBE example}
 \maketitle
 
-
 \subsection{What will be done?}
 
 \begin{frame}
@@ -16,11 +13,13 @@
 \item build own software component inside the ELBE buildenv
 \item include own application in target RFS
 \item define a stripped target RFS
+\item setup a local debian mirror
 \end{itemize}
 \end{frame}
 
 \subsection{generate a buildenv}
 
+\lstset{language=xml}
 \begin{frame}[fragile]
 \frametitle{minimal XML file}
 \begin{lstlisting}
@@ -272,7 +271,7 @@ $ $EDITOR conf/updates
 \end{lstlisting}
 \begin{lstlisting}
 Name: myremoterepo
-Method: http://localhost/debian
+Method: http://localhost/myrepo
 Components: main
 Architectures: i386 amd64 armel source
 VerifyRelease: blindtrust
@@ -286,7 +285,7 @@ IgnoreRelease: yes
 \begin{lstlisting}
 $ reprepro include wheezy ../myapp_1.0_i386.changes
 $ sudo mkdir /var/www/
-$ sudo rsync -av --exclude=db --exclude=conf * /var/www/debian/
+$ sudo rsync -av --exclude=db --exclude=conf * /var/www/myrepo/
 \end{lstlisting}
 \end{frame}
 
@@ -296,15 +295,24 @@ $ sudo rsync -av --exclude=db --exclude=conf * /var/www/debian/
 \begin{lstlisting}
 $ cd ../buildenv
 $ make run-con
-# login into buildenv
-$ echo 'deb-src http://10.0.2.2/debian wheezy main' >> /etc/apt/sources.list
+\end{lstlisting}
+login into buildenv and configure apt to use myrepo
+\begin{lstlisting}
+$ echo 'deb-src http://10.0.2.2/myrepo wheezy main' >> /etc/apt/sources.list
 $ apt-get update
+\end{lstlisting}
+retrive myapp source package and build armel binary package
+\begin{lstlisting}
 $ apt-get source myapp
 $ cd myapp-1.0
 $ ./autogen.sh
 $ dpkg-buildpackage -b
+\end{lstlisting}
+copy the package to the host PC and install it into the buildenv
+\begin{lstlisting}
 $ scp ../myapp*.changes ../myapp*.deb 10.0.2.2:/tmp
 $ dpkg -i ../myapp*.deb
+$ myapp
 \end{lstlisting}
 \end{frame}
 
@@ -314,33 +322,21 @@ $ dpkg -i ../myapp*.deb
 \begin{lstlisting}
 $ cd ../myrepo
 $ reprepro include wheezy /tmp/myapp_1.0_armel.changes
-$ sudo rsync -av --exclude=db --exclude=conf * /var/www/debian/
+$ sudo rsync -av --exclude=db --exclude=conf * /var/www/myrepo/
 \end{lstlisting}
 \end{frame}
 
 
-\subsection{include own application in target RFS}
+\subsection{include app in target RFS}
 
 \begin{frame}[fragile]
-\frametitle{create target image and add myapp}
+\frametitle{add repo including myapp}
 \begin{lstlisting}
 $ cd ..
 $ $EDIT mini.xml
 \end{lstlisting}
 \begin{lstlisting}
-<ns0:RootFileSystem
- xmlns:ns0="https://www.linutronix.de/projects/Elbe"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- created="2009-05-20T08:50:56" revision="6"
- xsi:schemaLocation="https://www.linutronix.de/projects/Elbe dbsfed.xsd">
-  <project>
-    <name>mini xml</name>
-    <version>1</version>
-    <description>
-      minimal target rfs including a simple app
-      buildenv to build the simple app
-    </description>
-    <buildtype>armel</buildtype>
+...
     <mirror>
       <primary_host>ftp.debian.org</primary_host>
       <primary_path>/debian</primary_path>
@@ -350,29 +346,20 @@ $ $EDIT mini.xml
           <binary>http://debian.linutronix.de/elbe wheezy main</binary>
         </url>
         <url>
-          <binary>http://LOCALMACHINE/debian wheezy main</binary>
-          <source>http://LOCALMACHINE/debian wheezy main</source>
+          <binary>http://LOCALMACHINE/myrepo wheezy main</binary>
+          <source>http://LOCALMACHINE/myrepo wheezy main</source>
         </url>
       </url-list>
     </mirror>
+    <noauth/>
+...
 \end{lstlisting}
 \end{frame}
 
 \begin{frame}[fragile]
-\frametitle{create target image and add myapp}
+\frametitle{add myapp}
 \begin{lstlisting}
-    <suite>wheezy</suite>
-    <buildimage>
-      <kinitrd>elbe-bootstrap</kinitrd>
-      <pkg-list>
-        <pkg>build-essential</pkg>
-        <pkg>debhelper</pkg>
-        <pkg>devscripts</pkg>
-        <pkg>autotools-dev</pkg>
-        <pkg>automake</pkg>
-      </pkg-list>
-    </buildimage>
-  </project>
+...
   <target>
     <hostname>mini</hostname>
     <domain>linutronix</domain>
@@ -391,7 +378,7 @@ $ $EDIT mini.xml
 
 \subsection{define a striped target RFS}
 \begin{frame}[fragile]
-\frametitle{set elbe mode and define images}
+\frametitle{define sdcard image}
 \begin{lstlisting}
 ...
   <target>
@@ -407,19 +394,28 @@ $ $EDIT mini.xml
     <images>
       <msdoshd>
         <name>my.img</name>
-        <size>200MiB</size>
+        <size>64MiB</size>
         <partition>
           <size>remain</size>
           <label>rfs</label>
         </partition>
       </msdoshd>
     </images>
+...
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{create fstab and set elbe mode}
+\begin{lstlisting}
+...
+    </images>
     <fstab>
       <bylabel>
         <label>rfs</label>
         <mountpoint>/</mountpoint>
         <fs>
-          <type>ext4</type>
+          <type>ext2</type>
           <tune2fs>-i 0</tune2fs>
         </fs>
       </bylabel>
@@ -427,22 +423,134 @@ $ $EDIT mini.xml
     <diet />
     <norecommend />
     <finetuning>
-      <rm>var/cache/apt/archives/*.deb</rm>
-      <command>echo "T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" &gt;&gt; etc/inittab</command>
-    </finetuning>
-    <pkg-list>
-      <pkg>bash</pkg>
-      <pkg>myapp</pkg>
-    </pkg-list>
-  </target>
+...
 \end{lstlisting}
 \end{frame}
 
 \begin{frame}[fragile]
-\frametitle{build target rfs}
+\frametitle{build and extract target as nfsroot}
 \begin{lstlisting}
 $ elbe create mini.xml --directory=./target
 $ cd target
 $ make
+\end{lstlisting}
+hint: it is possible to generate a html page from the elbe-report.txt:
+\begin{lstlisting}
+$ asciidoc elbe-report.txt
+\end{lstlisting}
+host the nfs root filesystem
+\begin{lstlisting}
+$ sudo mkdir -p /nfs/elbe-armel
+$ sudo tar xzf rootfs.tar.gz -C /nfs/elbe-armel
+$ su -c 'echo "/nfs *(rw,sync,no_subtree_check,insecure) >> /etc/exports"'
+$ sudo /etc/init.d/nfs-kernel-server restart
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{build current kernel for qemu armel boot}
+\begin{lstlisting}
+$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
+$ cd linux
+$ mkdir ../linux-qemu-arm
+$ ARCH=arm CROSS_COMPILE=arm-none-eabi- make O=../linux-qemu-arm versatile_defconfig
+$ # enable Kernel Features / Use the ARM EABI to compile the kernel
+$ #                  Allow old ABI binaries to run with this kernel
+$ #        Networking support / Networking options / TCP/IP networking /
+$ #           IP: kernel level autoconfiguration / IP: DHCP Support
+$ ARCH=arm CROSS_COMPILE=arm-none-eabi- make O=../linux-qemu-arm menuconfig
+$ ARCH=arm CROSS_COMPILE=arm-none-eabi- make O=../linux-qemu-arm -j5 
+$ cd ..
+\end{lstlisting}
+\end{frame}
+
+
+\begin{frame}[fragile]
+\frametitle{boot nfsroot with qemu}
+\begin{lstlisting}
+qemu-system-arm -M versatilepb -no-reboot \
+  -m 256 -usb \
+  -kernel linux-qemu-arm/arch/arm/boot/zImage \
+  -append 'root=/dev/nfs nfsroot=10.0.2.2:/nfs/elbe-armel ip=dhcp init=/usr/bin/myapp'
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{strip the nfsroot}
+\begin{lstlisting}
+$ sudo rm -rf /nfs/elbe-armel/etc
+$ sudo rm -rf /nfs/elbe-armel/sbin
+$ sudo rm -rf /nfs/elbe-armel/var
+$ sudo rm -rf /nfs/elbe-armel/usr/share
+$ sudo rm -rf /nfs/elbe-armel/usr/lib
+$ sudo rm -rf /nfs/elbe-armel/usr/sbin
+$ sudo cp /nfs/elbe-armel/usr/bin/myapp .
+$ sudo rm -rf /nfs/elbe-armel/usr/bin/*
+$ sudo mv myapp /nfs/elbe-armel/usr/bin/
+$ sudo cp -a /nfs/elbe-armel/lib/arm-linux-gnueabi/ld-* .
+$ sudo cp -a /nfs/elbe-armel/lib/arm-linux-gnueabi/libc-2.13.so .
+$ sudo cp -a /nfs/elbe-armel/lib/arm-linux-gnueabi/libc.so.6 .
+$ sudo rm /nfs/elbe-armel/lib/arm-linux-gnueabi/*
+$ sudo mv libc-2.13.so /nfs/elbe-armel/lib/arm-linux-gnueabi/
+$ sudo mv libc.so.6 /nfs/elbe-armel/lib/arm-linux-gnueabi/
+$ sudo mv ld-* /nfs/elbe-armel/lib/arm-linux-gnueabi/
+\end{lstlisting}
+\end{frame}
+
+
+\begin{frame}[fragile]
+\frametitle{update the ELBE XML file}
+\begin{lstlisting}
+$ sudo mkdir /nfs/elbe-armel-orig
+$ sudo tar xzf rootfs.tar.gz -C /nfs/elbe-armel-orig/
+$ elbe pkgdiff
+$ sudo elbe diff /nfs/elbe-armel-orig /nfs/elbe-armel > diff.txt
+$ cd ..
+\end{lstlisting}
+\begin{lstlisting}
+$ vim mini.xml
+$ # place cursor in finetuning section
+$ <ESC>:read target/diff.txt<RETURN>
+$ # remove everything until 'suggesting:'
+$ <ESC>:x<RETURN>
+\end{lstlisting}
+\begin{lstlisting}
+$ elbe create --directory=target-stripped mini.xml
+$ cd target-stripped
+$ make
+$ # get debian kernel and initrd from the buildenv:
+$ make .elbe-vm/vmkernel .elbe-vm/vminitrd
+$ # boot the image
+$ qemu-system-arm -M versatilepb \
+-kernel .elbe-vm/vmkernel -initrd .elbe-vm/vminitrd \
+-append 'root=/dev/sda1 init=/usr/bin/myapp' my.img
+\end{lstlisting}
+\end{frame}
+
+\subsection{setup own debian mirror}
+
+\begin{frame}[fragile]
+\frametitle{partial clone a remote debian mirror}
+\begin{lstlisting}
+$ mkdir -p /mirrors/debian
+$ cd debian
+$ debmirror -p -d wheezy, -a i386,amd64,armel,armhf --di-dist=wheezy \
+--method=http --no-check-gpg -h ftp.de.debian.org .
+$ cd /var/www/html
+$ ln -s  /mirrors/debian
+\end{lstlisting}
+\end{frame}
+
+\subsection{Conclusion}
+\begin{frame}
+\begin{itemize}
+\item generate an ELBE buildenv with a minimal XML file
+\item manage software components with autotools, dpkg and reprepro
+\item build own software component inside the ELBE buildenv
+\item include own debian packages in the target RFS
+\item edit a running rootfs and make it reproducable
+\item setup a partial, local debian mirror
+\end{itemize}
+\end{frame}
 
 \input{tailpres}
-- 
cgit v1.2.3

