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

⌈⌋ branch:  cross package maker


Check-in [006fa58cfa]

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

Overview
Comment:New `-t arch` output package module. (Arch Linux binary tarballs with .PKGINFO and .MTREE meta files.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:006fa58cfaff17a57363f8a8e91807dbeea08e9b
User & Date: mario 2015-04-30 23:54:53
Context
2015-05-01
02:17
Add architecture mapping, limit mode per & 07777. check-in: 32632f2a8d user: mario tags: trunk
2015-04-30
23:54
New `-t arch` output package module. (Arch Linux binary tarballs with .PKGINFO and .MTREE meta files.) check-in: 006fa58cfa user: mario tags: trunk
2015-04-17
22:14
Add --zip-shebang option, useful for making Python zip apps (pyz). check-in: 11e5c12d1d user: mario tags: trunk
Changes

Added lib/fpm/package/arch.rb.

























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# encoding: utf-8
# api: fpm
# title: arch tarball
# description: xzipped tarball with meta .PKGINFO and .MTREE files
# version: 0.1
#
# Arch binary packages are just .tar.xz archives with an
# extra .PKGINFO and .MTREE top-level.
#
# Care must be taken with dependencies. They're mostly
# literal upstream release basenames, but there's also
# some variance with version numbers embedded still.
# Python packages for example are named `python2-xyz`
# usually.


require "backports" # gem backports
require "fpm/package"
require "fpm/package/dir"
require "fpm/version"
require "fpm/util"
require "time"
require "fileutils"
require "zlib"


# Output only
class FPM::Package::Arch < FPM::Package

  # Craft .PKGINFO and .MTREE (gzipped),
  # then generate a tarball (always .xz compressed).
  #
  def output(output_path)
    output_check(output_path)

    # Convert meta
    pkginfo()
    mtree()

    # Generate tarball
    tarfn = File.absolute_path(output_path)
    ::Dir::chdir(staging_path) do
      args = ["tar", "-c", "-J", "--owner=0", "--group=0", "--xform", "s:./::", "--exclude", "./", "-f", tarfn, "."]
      safesystem(*args)
    end
  end # def output
  
  def pkginfo()
    File.open(staging_path + "/.PKGINFO", "w") do |f|
      f.write template("arch/PKGINFO.erb").result(binding)
    end
  end

  def mtree()
    Zlib::GzipWriter.open(staging_path + "/.MTREE") do |f|
      f.write template("arch/MTREEgz.erb").result(binding)
    end
  end

end # class FPM::Package::Arch

Added templates/arch/MTREEgz.erb.





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#mtree
<%
 lines = ""
 lasth = ""

 ::Dir.chdir(staging_path) do
   ::Dir.glob("./**/*") do |fn|

     #-- per file/directory
     stat = File.stat(fn)
     f_mode = stat.mode.to_s(8)
     if File.directory? fn
       head = "/set uid=0 gid=0 mode=#{f_mode}\n"
       line = "#{fn} time=#{stat.mtime.to_f} type=dir\n"
     else
       f_md5 = Digest::MD5.file(fn).hexdigest
       f_sha = Digest::SHA256.file(fn).hexdigest
       head = "/set type=file uid=0 gid=0 mode=#{f_mode}\n"
       line = "#{fn} time=#{stat.mtime.to_f} size=#{stat.size} md5digest=#{f_md5} sha256digest=#{f_sha}\n"
     end

     #-- collect output
     if head != lasth
       lines += head
       lasth = head
     end
     lines += line
   end
 end
%><%=lines%>

Added templates/arch/PKGINFO.erb.































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Generated by fpm/xpm <%= FPM::VERSION %>
# <%= Time.now.utc.iso8601 %>
pkgname = <%= name %>
pkgver = <%= version %>
pkgdesc = <%= (description or "no desc").split("\n")[0] %>
url = <%= url or "http://nourlgiven.example.com/" %>
builddate = <%= Time.now.to_i %>
packager = <%= maintainer %>
size = <%= `du -b -s -c .`.split("\t")[0] %>
arch = <%= architecture %>
license = custom
<%= dependencies.collect { |d| "depend = #{d}" }.flatten.join("\n") %>
makepkgopt = docs
makepkgopt = emptydirs
makepkgopt = zipman