2010年8月9日 星期一

Maemo 5 debian packaging

初次嘗試Maemo 5 hello world programing之後,將binary複製到target上就可以執行.
但這樣並不是正規的散布方式,Maemo 5支援Debian dpkg的方式包裝binary,包含icon, desktop設定等...
網路上搜尋Maemo 5 dpkg相關的資料並不多,流程也有些複雜,因此作個紀錄供往後參考用.

以下將延續之前的example_hildonprogram

1.要使用dpkg packaging需要配合autotools (據說也可以不要)
2.建立目錄及環境,之後複製example_hildonprogram.c

[sbox-FREMANTLE_ARMEL: ~/] > mkdir example_hildonprogram
[sbox-FREMANTLE_ARMEL: ~/] > cd example_hildonprogram
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > mkdir src
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > mkdir data
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > mkdir data/maemo

複製example_hildonprogram.c 到 example_hildonprogram/src

3.建立autotools所需檔案

File configure.ac

AC_INIT([example_hildonprogram], [0.1])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
PKG_CHECK_MODULES(GTK2,
          [gtk+-2.0]
          [AC_SUBST(GTK2_CFLAGS)
          AC_SUBST(GTK2_LIBS)])

PKG_CHECK_MODULES([HILDON], [hildon-1 >= 2.2])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

File Makefile.am

SUBDIRS = src
EXTRA_DIST = data/icons/example_hildonprogram.png \
        data/maemo/example_hildonprogram.desktop \
        data/maemo/com.nokia.example_hildonprogram.service

File src/Makefile.am

bin_PROGRAMS = example_hildonprogram

example_hildonprogram_SOURCES = example_hildonprogram.c

example_hildonprogram_CFLAGS = $(GTK2_CFLAGS) \
                  $(HILDON_CFLAGS)

example_hildonprogram_LDADD = $(GTK2_LIBS) \
                 $(HILDON_LIBS)

4.建立Maemo 5所需檔案

File data/maemo/example_hildonprogram.desktop

[Desktop Entry]
Encoding=UTF-8
Version=0.1
Name=example_hildonprogram
Type=Application
Exec=/usr/bin/example_hildonprogram
Icon=example_hildonprogram

File data/maemo/com.nokia.example_hildonprogram.service

[D-BUS Service]
Name=nokia.com.example_hildonprogram
Exec=/usr/bin/example_hildonprogram

5.Run autoreconf to create configure

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > autoreconf --force --install -v
autoreconf2.50: Entering directory `.'
autoreconf2.50: configure.ac: not using Gettext
autoreconf2.50: running: aclocal --force
autoreconf2.50: configure.ac: tracing
autoreconf2.50: configure.ac: not using Libtool
autoreconf2.50: running: /scratchbox/tools/autotools/autoconf2.61/bin/autoconf --force
autoreconf2.50: configure.ac: not using Autoheader
autoreconf2.50: running: automake --add-missing --copy --force-missing
src/Makefile.am: installing `./compile'
autoreconf2.50: Leaving directory `.'

6.configure

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > ./configure
checking for a BSD-compatible install... /scratchbox/tools/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for pkg-config... /scratchbox/tools/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GTK2... yes
checking for HILDON... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands

7.make

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > make
Making all in src
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/src'
if gcc -DPACKAGE_NAME=\"example_hildonprogram\" -DPACKAGE_TARNAME=\"example_hildonprogram\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"example_hildonprogram\ 0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"example_hildonprogram\" -DVERSION=\"0.1\" -I. -I.    -DMAEMO_CHANGES -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -DMAEMO_CHANGES -DMAEMO_GTK -I/usr/include/hildon-1 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -g -O2 -MT example_hildonprogram-example_hildonprogram.o -MD -MP -MF ".deps/example_hildonprogram-example_hildonprogram.Tpo" -c -o example_hildonprogram-example_hildonprogram.o `test -f 'example_hildonprogram.c' || echo './'`example_hildonprogram.c; \
    then mv -f ".deps/example_hildonprogram-example_hildonprogram.Tpo" ".deps/example_hildonprogram-example_hildonprogram.Po"; else rm -f ".deps/example_hildonprogram-example_hildonprogram.Tpo"; exit 1; fi
gcc  -g -O2   -o example_hildonprogram  example_hildonprogram-example_hildonprogram.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lhildon-1 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0  
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/src'
make[1]: Entering directory `/home/gigijoe/example_hildonprogram'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram'

8.make dist, 此時會產生example_hildonprogram-0.1.tar.gz

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > make dist
{ test ! -d example_hildonprogram-0.1 || { find example_hildonprogram-0.1 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr example_hildonprogram-0.1; }; }
mkdir example_hildonprogram-0.1
mkdir -p -- . example_hildonprogram-0.1/data/icons example_hildonprogram-0.1/data/maemo
list='src'; for subdir in $list; do \
      if test "$subdir" = .; then :; else \
        test -d "example_hildonprogram-0.1/$subdir" \
        || mkdir "example_hildonprogram-0.1/$subdir" \
        || exit 1; \
        (cd $subdir && \
          make  \
            top_distdir="../example_hildonprogram-0.1" \
            distdir="../example_hildonprogram-0.1/$subdir" \
            distdir) \
          || exit 1; \
      fi; \
    done
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/src'
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/src'
find example_hildonprogram-0.1 -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
      ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
      ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
      ! -type d ! -perm -444 -exec /bin/sh /home/gigijoe/example_hildonprogram/install-sh -c -m a+r {} {} \; \
    || chmod -R a+r example_hildonprogram-0.1
/bin/sh /home/gigijoe/example_hildonprogram/missing --run tar chof - example_hildonprogram-0.1 | GZIP=--best gzip -c >example_hildonprogram-0.1.tar.gz
{ test ! -d example_hildonprogram-0.1 || { find example_hildonprogram-0.1 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr example_hildonprogram-0.1; }; }

9.解開壓縮檔準備以此作為packaging source,這樣的作法不會影響到原來的source.

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > tar -zxvf example_hildonprogram-0.1.tar.gz
example_hildonprogram-0.1/
example_hildonprogram-0.1/compile
example_hildonprogram-0.1/configure
example_hildonprogram-0.1/missing
example_hildonprogram-0.1/install-sh
example_hildonprogram-0.1/depcomp
example_hildonprogram-0.1/configure.ac
example_hildonprogram-0.1/aclocal.m4
example_hildonprogram-0.1/Makefile.am
example_hildonprogram-0.1/Makefile.in
example_hildonprogram-0.1/src/
example_hildonprogram-0.1/src/example_hildonprogram.c
example_hildonprogram-0.1/src/Makefile.am
example_hildonprogram-0.1/src/Makefile.in
example_hildonprogram-0.1/data/
example_hildonprogram-0.1/data/icons/
example_hildonprogram-0.1/data/icons/example_hildonprogram.png
example_hildonprogram-0.1/data/maemo/
example_hildonprogram-0.1/data/maemo/com.nokia.example_hildonprogram.service
example_hildonprogram-0.1/data/maemo/example_hildonprogram.desktop



[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > cd example_hildonprogram-0.1
[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram/example_hildonprogram-0.1] > dh_make -e stevegigijoe@yahoo.com.tw --createorig -c GPL

Type of package: single binary, multiple binary, library, kernel module or cdbs?
 [s/m/l/k/b] s

Maintainer name : unknown
Email-Address   : stevegigijoe@yahoo.com.tw
Date            : Mon,  9 Aug 2010 15:47:56 +0800
Package Name    : example.hildonprogram
Version         : 0.1
License         : gpl
Type of Package : Single
Hit to confirm:
Done. Please edit the files in the debian/ subdirectory now. example.hildonprogram
uses a configure script, so you probably don't have to edit the Makefiles.


11.packaging

首先更動一下 debian/control, 這個檔案很重要.

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram/example.hildonprogram-0.1] > vi debian/control

-Build-Depends: debhelper (>= 5), autotools-dev
+Build-Depends: debhelper (>= 5), autotools-dev, libhildon1 (>= 2.2)
 
OK,go packaging

以下兩者都可以
dpkg-buildpackage -i -rfakeroot -D
dpkg-buildpackage -sa -rfakeroot -kstevegigijoe@yahoo.com.tw


[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram/example.hildonprogram-0.1] > dpkg-buildpackage -sa -rfakeroot -kstevegigijoe@yahoo.com.tw
dpkg-buildpackage: source package is example.hildonprogram
dpkg-buildpackage: source version is 0.1-1
dpkg-buildpackage: source changed by unknown
dpkg-buildpackage: host architecture armel
dpkg-buildpackage: source version without epoch 0.1-1
: Using Scratchbox tools to satisfy builddeps
: Dependency provided by Scratchbox: autotools-dev
 fakeroot debian/rules clean
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
/scratchbox/tools/bin/make distclean
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[1]: *** No rule to make target `distclean'.  Stop.
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make: [clean] Error 2 (ignored)
cp -f /usr/share/misc/config.sub config.sub
cp -f /usr/share/misc/config.guess config.guess
dh_clean
 dpkg-source -b example.hildonprogram-0.1
dpkg-source: building example.hildonprogram using existing example.hildonprogram_0.1.orig.tar.gz
dpkg-source: building example.hildonprogram in example.hildonprogram_0.1-1.diff.gz
dpkg-source: building example.hildonprogram in example.hildonprogram_0.1-1.dsc
 debian/rules build
dh_testdir
# Add here commands to configure the package.
./configure --host=arm-linux-gnueabi --build=arm-linux-gnueabi --prefix=/usr --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info CFLAGS="-Wall -g -O2" LDFLAGS="-Wl,-z,defs"
checking for a BSD-compatible install... /scratchbox/tools/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for arm-linux-gnueabi-gcc... arm-linux-gnueabi-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-gnueabi-gcc accepts -g... yes
checking for arm-linux-gnueabi-gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of arm-linux-gnueabi-gcc... gcc3
checking for arm-linux-gnueabi-pkg-config... no
checking for pkg-config... /scratchbox/tools/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GTK2... yes
checking for HILDON... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands
dh_testdir
# Add here commands to compile the package.
/scratchbox/tools/bin/make
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
Making all in src
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
if arm-linux-gnueabi-gcc -DPACKAGE_NAME=\"example_hildonprogram\" -DPACKAGE_TARNAME=\"example_hildonprogram\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"example_hildonprogram\ 0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"example_hildonprogram\" -DVERSION=\"0.1\" -I. -I.    -DMAEMO_CHANGES -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -DMAEMO_CHANGES -DMAEMO_GTK -I/usr/include/hildon-1 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -Wall -g -O2 -MT example_hildonprogram-example_hildonprogram.o -MD -MP -MF ".deps/example_hildonprogram-example_hildonprogram.Tpo" -c -o example_hildonprogram-example_hildonprogram.o `test -f 'example_hildonprogram.c' || echo './'`example_hildonprogram.c; \
    then mv -f ".deps/example_hildonprogram-example_hildonprogram.Tpo" ".deps/example_hildonprogram-example_hildonprogram.Po"; else rm -f ".deps/example_hildonprogram-example_hildonprogram.Tpo"; exit 1; fi
arm-linux-gnueabi-gcc  -Wall -g -O2  -Wl,-z,defs -o example_hildonprogram  example_hildonprogram-example_hildonprogram.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lhildon-1 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0  
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
#docbook-to-man debian/example.hildonprogram.sgml > example.hildonprogram.1
touch build-stamp
 fakeroot debian/rules binary
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/example.hildonprogram.
/scratchbox/tools/bin/make DESTDIR=/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/debian/example.hildonprogram install
make[1]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
Making install in src
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[3]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
test -z "/usr/bin" || mkdir -p -- . "/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/debian/example.hildonprogram/usr/bin"
  /scratchbox/tools/bin/install -c 'example_hildonprogram' '/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/debian/example.hildonprogram/usr/bin/example_hildonprogram'
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1/src'
make[2]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[3]: Entering directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[2]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
make[1]: Leaving directory `/home/gigijoe/example_hildonprogram/example.hildonprogram-0.1'
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps
dh_gencontrol
dpkg-gencontrol: warning: unknown substitution variable ${misc:Depends}
dh_md5sums
dh_builddeb
dpkg-deb: building package `example.hildonprogram' in `../example.hildonprogram_0.1-1_armel.deb'.
 dpkg-genchanges -sa
dpkg-genchanges: including full source code in upload
dpkg-buildpackage: full upload (original source is included)

到這邊就已經完成囉

[sbox-FREMANTLE_ARMEL: ~/example_hildonprogram] > ls
Makefile     autom4te.cache  configure     example.hildonprogram-0.1            example.hildonprogram_0.1-1_armel.changes  missing
Makefile.am  compile         configure.ac  example.hildonprogram-0.1.tar.gz     example.hildonprogram_0.1-1_armel.deb      packaging
Makefile.in  config.log      data          example.hildonprogram_0.1-1.diff.gz  example.hildonprogram_0.1.orig.tar.gz      src
aclocal.m4   config.status   depcomp       example.hildonprogram_0.1-1.dsc      install-sh


沒有留言:

張貼留言