Class: Packager

Inherits:
Object
  • Object
show all
Defined in:
lib/makeconf/packager.rb

Overview

A packager produces a package in the preferred OS format (e.g. RPM, DEB)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Packager

Returns a new instance of Packager.



6
7
8
9
# File 'lib/makeconf/packager.rb', line 6

def initialize(project)
  @project = project
  @makefile = Makefile.new
end

Instance Attribute Details

#makefileObject (readonly)

Returns the value of attribute makefile.



4
5
6
# File 'lib/makeconf/packager.rb', line 4

def makefile
  @makefile
end

Instance Method Details

#finalizeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/makeconf/packager.rb', line 11

def finalize
  make_rpm_spec
  @makefile.add_target(
          'package',
          ['clean', @project.distfile],
   		['rm -rf rpm *.rpm',
           'mkdir -p rpm/BUILD rpm/RPMS rpm/SOURCES rpm/SPECS rpm/SRPMS',
           'mkdir -p rpm/RPMS/i386 rpm/RPMS/x86_64',
     "cp #{@project.distfile} rpm/SOURCES",
		     'rpmbuild --define "_topdir ./rpm" -bs rpm.spec',
	   	     'mv ./rpm/SRPMS/* .',
    		 'rm -rf rpm',
   		])
  @makefile.add_rule('clean', Platform.rm('*.rpm')) # FIXME: wildcard is bad
  @makefile.add_rule('distclean', Platform.rm('rpm.spec'))
end

#make_rpm_specObject

Generate an RPM spec file



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/makeconf/packager.rb', line 29

def make_rpm_spec
  puts 'creating rpm.spec'
  f = File.open('rpm.spec', 'w')
  f.puts <<EOF
# DO NOT EDIT -- automatically generated by ./configure
Name:       #{@project.id}
Summary:    #{@project.summary}
Version:    #{@project.version}
Release:    1
License:    #{@project.license}
Vendor:     #{@project.author}
Group:      System Environment/Libraries
Source0:    %{name}-%version.tar.gz

%description
#{@project.description}

%package devel
Summary: Header files, libraries and development documentation for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
This package contains the header files, static libraries and development
documentation for %{name}. If you like to develop programs using %{name},
you will need to install %{name}-devel.

%prep
%setup -q -n PROGRAM-VERSION

%build
./configure --prefix=/usr
make

%install
make DESTDIR=%{buildroot} install

%clean
[ %{buildroot} != "/" ] && rm -rf %{buildroot}

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%defattr(-,root,root)

/usr/lib/*.so.*

%files devel
%defattr(-,root,root)

/usr/lib/*.so
/usr/include/*
/usr/share/man/man3/*

%changelog
* Thu Jan 01 2011 Some Person <[email protected]> - #{@project.version}-1
- automatically generated spec file
EOF
f.close()
end