Meego Wiki
Views

SDK/Docs/1.0/Packaging/Tutorial

From MeeGo wiki
< SDK | Docs | 1.0
Revision as of 04:56, 24 May 2010 by Wwhbuaa (Talk | contribs)
Jump to: navigation, search

Contents

Introduction

MeeGo uses RPM as the package format. After you finish your application development work, you need to make a RPM package to publish it. This page will introduce a tutorial to create RPM package with MeeGo SDK and tools. To generate MeeGo adapted RPM packages, the MeeGo Packaging Guideline should be followed. This page will provides a simple tutorial to create a MeeGo rpm package for the "spectacle".

Create spec file

MeeGo recommends to use Spectacle to either create MeeGo spec file or convert existing spec file to MeeGo spec file.

Install Spectacle

  • On MeeGo platform or MeeGo chroot environment, you can install it directly.
yum install spectacle

Create YAML package meta-data file

Spectacle uses a package meta-data file as the input to generate MeeGo spec file. The meta-data file is in YAML format. Spectacle defines specific Syntax of Spectacle YAML.

  • A simple YAML file - spectacle.yaml to create spectacle rpm package:
Name: spectacle
Summary: RPM Spec file generator and management tool
Version: 0.17
Release: 1
SCM: git@git.moblin.org:spectacle
Group: Development/Tools
License: GPLv2+
URL: http://www.moblin.org
BuildArch: noarch
Description: |
    A tool for managing and creating RPM spec files
Sources:
    - spectacle-%{version}.tar.gz
Requires:
    - PyYAML
    - python-urlgrabber
    - python-cheetah
PkgBR:
    - python-devel
    - python-cheetah
Builder: python
SupportOtherDistros: yes
  • An YAML file can also be created from an existing spec file:
spec2spectacle package_name.spec

Generate spec file from YAML meta-data file

With the YAML file, the spec file can be easily generated. With above simple yaml file, a file named "spectacle.spec" will be created:

specify spectacle.yaml

The generated spec file is:

# 
# Do not Edit! Generated by:
# spectacle version 0.15
# 
# >> macros
# << macros

%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
Name:       spectacle
Summary:    RPM Spec file generator and management tool
Version:    0.17
Release:    1
Group:      Development/Tools
License:    GPLv2+
BuildArch:  noarch
URL:        http://www.moblin.org
Source0:    spectacle-%{version}.tar.gz
Source100:  spectacle.yaml
Requires:   PyYAML
Requires:   python-urlgrabber
Requires:   python-cheetah
BuildRequires:  python-devel
BuildRequires:  python-cheetah

%description
A tool for managing and creating RPM spec files




%prep
%setup -q -n %{name}-%{version}

# >> setup
# << setup

%build
# >> build pre
# << build pre

CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build

# >> build post
# << build post
%install
rm -rf %{buildroot}
# >> install pre
# << install pre
%if 0%{?suse_version}
%{__python} setup.py install --root=%{buildroot} --prefix=%{_prefix}
%else
%{__python} setup.py install --root=%{buildroot} -O1
%endif

# >> install post
# << install post






%files
%defattr(-,root,root,-)
# >> files
# << files
  • Modify the generated spec file to add customized build procedures.

Note: Normally, if all related information has been provided in .yaml file, then the spec file does not need any change.

# >> install post
make install-data DESTDIR=${RPM_BUILD_ROOT}
# << install post
# >> files
%doc README AUTHORS COPYING TODO
%doc examples/
%dir %{_datadir}/spectacle
%{_datadir}/spectacle/*
%{_bindir}/*
%{python_sitelib}/*
# << files

Build rpm in MeeGo SDK chroot

For application developers, they may want to create package directly from the MeeGo SDK chroot environment. It's quite easy to use rpmbuild to do that.

  • Install rpmbuild
yum install rpmbuild
  • Copy source code and spec file to right place
cp spectacle-0.17.tar.gz ~/rpmbuild/SOURCES/
cp spectacle.yaml ~/rpmbuild/SOURCES/
cp spectacle.spec ~/rpmbuild/SPECS/
  • Generate rpm package with above "spectacle.spec"
cd ~/rpmbuild/SPECS
rpmbuild -ba spectacle.spec

Then the rpm packages will be generated and put at ~/rpmbuild/RPMS/ and ~/rpmbuild/SRPMS/.

  • More about rpmbuild can be found at rpmbuild

Build rpm without chroot or OBS

For people who do build or release, they may just want to build packages without the MeeGo SDK chroot environment. The following steps are useful for them.

Linux

Under Linux, a tool called "build" is used to create rpm packages directly from spec file.

  • Install build on your Linux host machine. You can find the repo link and packages at MeeGo Tools Repo. Following Lnux distributions are supported
   * MeeGo
   * Fedora 10,11,12
   * openSUSE(s)    
   * xUbuntu 8.10/9.04/9.10
   * Debian 5.0   
  • Create rpm package with build and spec file
sudo build --repository http://repo.meego.com/MeeGo/release/1.0/core/repo/ia32/os/ --arch i686 spectacle.spec

The packages will be generated at /var/tmp/build-root/home/abuild/rpmbuild/RPMS/ and /var/tmp/build-root/home/abuild/rpmbuild/SRPMS/ You may configure your http_proxy to make sure the repo can be accessed.

export http_proxy=http://proxy_server:port
Personal tools