RPM Community Forums

Mailing List Message of <rpm-devel>

Re: Converting *.spec to Makefiles

From: Anders F Björklund <afb@rpm5.org>
Date: Mon 08 Sep 2008 - 00:01:58 CEST
Message-Id: <1074B30B-7092-42FE-A54C-36BCD51B7E94@rpm5.org>
Jeff Johnson wrote:

> Here is a rather simple popt alias for a --queryformat that starts  
> to convert a specfile
> into Makefile rules.
>
> Put this in /etc/popt:
> ==============================================================
> rpm     alias --spec:makefile --qf '\
> # Display spec file scriptlets as Makefile targets \
> \n# (indentation of sections not yet implemented) \
> \n\
> \nall:  %{NAME}.prep %{NAME}.build %{NAME}.install %{NAME}.clean\
> \n\
> \n.PHONY:       %{NAME}.prep\
> \n%{NAME}.prep:\
> \n%{Buildprep}\
> \n\
> \n.PHONY:       %{NAME}.build\
> \n%{NAME}.build:\
> \n%{Buildbuild}\
> \n\
> \n.PHONY:       %{NAME}.install\
> \n%{NAME}.install:\
> \n%{Buildinstall}\
> \n\
> \n.PHONY:       %{NAME}.clean\
> \n%{NAME}.clean:\
> \n%{Buildclean}\
> \n' \
>         --POPTdesc=$"display spec file scriptlets as Makefile rules"
> ==============================================================
>
> (aside) Yes, I haven't attempted Makefile indentation nor filtering  
> the tag content, not impossibly hard.
>
> Then create a Makefile from any *.spec by doing
>
>     rpm -q --spec:makefile --specsrpm foo.spec



Here's the same thing, for Bee: (bee.rubyforge.org)
==============================================================
rpm     alias --spec:bee --qf '\
\n - properties:\
\n   - Name: "%{Name:yaml}"\
\n   - Version: "%{Version:yaml}"\
\n   - Release: "%{Release:yaml}"\
\n\
\n - target: all\
\n   description: run all targets\
\n   depends: \[prep, build, install, clean\]\
\n\
\n - target: prep\
\n   script: %{Buildprep:yaml}\
\n\
\n - target: build\
\n   script: %{Buildbuild:yaml}\
\n\
\n - target: install\
\n   script: %{Buildinstall:yaml}\
\n\
\n - target: clean\
\n   script: %{Buildclean:yaml}\
\n' \
         --POPTdesc=$"display spec file as bee ruby"
==============================================================

It creates a build.yml file, that can be run with bee.

That is, the trivial rpm spec file:

Summary:   Test
Name:      test
Version:   1.0
Release:   1
License:   Public Domain
Group:     Development/Tools

%description
Trivial test package

%prep
echo prep

%build
echo build

%install
echo install

%clean
echo clean

%files

becomes the trivial bee build file:

  - properties:
    - Name: "test"
    - Version: "1.0"
    - Release: "1"

  - target: all
    description: run all targets
    depends: [prep, build, install, clean]

  - target: prep
    script: |-
       echo prep

  - target: build
    script: |-
       echo build

  - target: install
    script: |-

       echo install

  - target: clean
    script: |-
       /bin/rm -rf '/var/local/tmp/test-root'

With #{Name} and friends being all set...

--anders
Received on Mon Sep 8 00:01:59 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.