Cross package maker. DEB/RPM generation or conversion. Derived from jordansissel/fpm.

⌈⌋ ⎇ branch:  cross package maker


Check-in [11939b22a0]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge branch 'master' of github.com:jordansissel/fpm
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 11939b22a057e85f086b2972cfcc80f7972497bd
User & Date: jls@semicomplete.com 2011-06-09 16:50:17
Context
2011-06-15
06:20
- Start working on a solaris package type. - md5sums aren't needed by most packages, disable it by default. In the future, should move the md5sums generator to the .deb package target and keep it away from other stuff. check-in: a0fa7fcf65 user: jls@semicomplete.com tags: trunk
2011-06-09
16:51
- version bump for https://github.com/jordansissel/fpm/issues/44 check-in: 08ad303f9a user: jls@semicomplete.com tags: trunk
16:50
Merge branch 'master' of github.com:jordansissel/fpm check-in: 11939b22a0 user: jls@semicomplete.com tags: trunk
16:48
- Some rpm implementations blow away %{buildroot} at the start of every %build section. That sucks and is a bug/misfeature. Work around it by unpacking the tarball in %build instead of %prep. This should fix rpm building on SLES (https://github.com/jordansissel/fpm/issues/44) Patch-like thing originally by meineerde. Tested on ubuntu it still builds rpms just fine (no behavior change, good). Hopefully works on SLES now :) check-in: a1b1c44c1b user: jls@semicomplete.com tags: trunk
01:54
- version bump check-in: 4c3e228550 user: jls@semicomplete.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added examples/fpm/Makefile.







































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
NAME=ruby
VERSION=1.9.2-p180
MAJOR_VERSION=1.9
ARCHITECTURE=x86
TARDIR=$(NAME)-$(VERSION)
TARBALL=$(TARDIR).tar.gz
DOWNLOAD=http://ftp.ruby-lang.org/pub/ruby/$(MAJOR_VERSION)/$(TARBALL)

PREFIX=/opt/fpm

PACKAGE_NAME=fpm
PACKAGE_VERSION=0.2.30

.PHONY: default
default: deb
package: deb

.PHONY: clean
clean:
	rm -f $(NAME)-* $(NAME)_* |NAME| true
	rm -fr $(TARDIR) || true
	rm -fr $(PREFIX) || true
	rm -f *.deb

$(TARBALL):
	wget "$(DOWNLOAD)"

$(TARDIR): $(TARBALL)
	tar -zxf $(TARBALL)
	cd $(TARDIR); ./configure --enable-shared=false --prefix=$(PREFIX); make; make install
	$(PREFIX)/bin/gem install fpm

.PHONY: deb
deb: $(TARDIR)
	$(PREFIX)/bin/fpm -s dir -t deb -v $(PACKAGE_VERSION) -n $(PACKAGE_NAME) -a $(ARCHITECTURE) -C $(PREFIX) .

Added examples/fpm/README.md.







































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Notes:

    You should have write permission on /opt directory

Dependencies:

    $ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libxml2-dev libxslt-dev autoconf libc6-dev

Usage:

    $ make package

Should make the package. Try installing:

    $ sudo dpkg -i fpm-0.2.30.x86.deb

Now try it:

    $ /opt/fpm/bin/fpm --help 

Changes to fpm.gemspec.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Gem::Specification.new do |spec|
  files = []
  dirs = %w{lib bin templates}
  dirs.each do |dir|
    files += Dir["#{dir}/**/*"]
  end

  files << "LICENSE"
  files << "CONTRIBUTORS"
  files << "CHANGELIST"

  spec.name = "fpm"
  spec.version = "0.2.30"
  spec.summary = "fpm - package building and mangling"
  spec.description = "Turn directories into packages. Fix broken packages. Win the package building game."
  spec.add_dependency("json")
  spec.files = files
  spec.require_paths << "lib"
  spec.bindir = "bin"
  spec.executables << "fpm"












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Gem::Specification.new do |spec|
  files = []
  dirs = %w{lib bin templates}
  dirs.each do |dir|
    files += Dir["#{dir}/**/*"]
  end

  files << "LICENSE"
  files << "CONTRIBUTORS"
  files << "CHANGELIST"

  spec.name = "fpm"
  spec.version = "0.2.31"
  spec.summary = "fpm - package building and mangling"
  spec.description = "Turn directories into packages. Fix broken packages. Win the package building game."
  spec.add_dependency("json")
  spec.files = files
  spec.require_paths << "lib"
  spec.bindir = "bin"
  spec.executables << "fpm"

Added lib/fpm/errors.rb.







>
>
>
1
2
3
require "fpm/namespace"

class FPM::InvalidPackageConfiguration < StandardError; end

Changes to lib/fpm/target/deb.rb.

1
2
3

4
5
6
7
8
9
10
require "erb"
require "fpm/namespace"
require "fpm/package"


class FPM::Target::Deb < FPM::Package
  def architecture
    if @architecture.nil? or @architecture == "native"
      # Default architecture should be 'native' which we'll need
      # to ask the system about.
      arch = %x{dpkg --print-architecture}.chomp



>







1
2
3
4
5
6
7
8
9
10
11
require "erb"
require "fpm/namespace"
require "fpm/package"
require "fpm/errors"

class FPM::Target::Deb < FPM::Package
  def architecture
    if @architecture.nil? or @architecture == "native"
      # Default architecture should be 'native' which we'll need
      # to ask the system about.
      arch = %x{dpkg --print-architecture}.chomp
22
23
24
25
26
27
28












29
30
31
32
33
34
35
    
    return @architecture
  end # def architecture

  def specfile(builddir)
    "#{builddir}/control"
  end













  def build!(params)
    control_files = [ "control", "md5sums" ]
    # place the postinst prerm files
    self.scripts.each do |name, path|
      case name
        when "pre-install"







>
>
>
>
>
>
>
>
>
>
>
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    
    return @architecture
  end # def architecture

  def specfile(builddir)
    "#{builddir}/control"
  end

  def name
    if @name =~ /[A-Z]/
      @logger.fatal("Debian tools (dpkg/apt) don't do well with packages " \
        "that use capital letters in the name. In some cases it will " \
        "automatically downcase them, in others it will not. It is confusing." \
        "Best to not use any capital letters at all.")
      raise FPM::InvalidPackageConfiguration.new(
        "package name '#{@name}' contains capital letters, bad.")
    end
    return @name
  end

  def build!(params)
    control_files = [ "control", "md5sums" ]
    # place the postinst prerm files
    self.scripts.each do |name, path|
      case name
        when "pre-install"

Added misc/pkgsrc.sh.

















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
#!/bin/sh

if [ ! -f "mk/bsd.pkg.mk" ]  ; then
  # TODO(sissel): Maybe download pkgsrc ourselves.
  echo "Current directory doesn't appear to be a pkgsrc tree. ($PWD)"
  echo "I was expecting to find file: ./mk/bsd.pkg.mk"
  exit 1
fi

if [ ! -f "build/usr/local/bin/bmake" ] ; then
  # TODO(sissel): Maybe bootstrap ourselves.
  echo "This script requires pkgsrc to be bootstrapped in a specific way."
  echo "I expected to find file: build/usr/local/bin/bmake and did not"
  echo 
  echo "Bootstrap with:"
  echo "SH=/bin/bash ./bootstrap/bootstrap --unprivileged --prefix $PWD/build/usr/local --pkgdbdir $PWD/pkgdb"
  exit 1
fi

# TODO(sissel): put some flags.

LOCALBASE="/usr/local"
DESTDIR=$PWD/build

mkdir -p "$DESTDIR"

export PATH=$DESTDIR/$LOCALBASE/bin:$DESTDIR/$LOCALBASE/sbin:$PATH

for i in "$@" ; do
  # process dependencies first before the final target.
  set -- $(bmake -C "$@" show-depends-pkgpaths) "$@"
done

TARGETS="$*"

for target in $TARGETS; do
  set --

  eval "$(bmake -C $target show-vars-eval VARS="PKGNAME PKGVERSION")"
  name="$(echo "$PKGNAME" | sed -e "s/-$PKGVERSION\$//")" 
  orig_version=${PKGVERSION}
  version=${PKGVERSION}-pkgsrc

  # Purge old package
  rm packages/All/$PKGNAME.tgz

  pkg_delete $name > /dev/null 2>&1

  bmake -C $target clean || exit 1
  bmake -C $target USE_DESTDIR=yes LOCALBASE=$LOCALBASE PREFIX=$LOCALBASE \
    DESTDIR=$DESTDIR SKIP_DEPENDS=yes \
    clean package || exit 1

  # Start building fpm args
  set -- -n "$name" -v "$version" --prefix $LOCALBASE 
  
  # Skip the pkgsrc package metadata files
  set -- "$@" --exclude '+*'

  # Handle deps
  for dep in $(bmake -C $target show-depends-pkgpaths) ; do
    eval "$(bmake -C $dep show-vars-eval VARS="PKGNAME PKGVERSION")"
    PKGNAME="$(echo "$PKGNAME" | sed -e "s/-$PKGVERSION\$//")"
    set -- "$@" -d "$PKGNAME (= $PKGVERSION-pkgsrc)"
  done

  set -- -s tar -t deb "$@" 
  set -- "$@" packages/All/$name-$orig_version.tgz 
  fpm "$@" 
done