Module: Ian

Defined in:
lib/ian.rb,
lib/ian/utils.rb,
lib/ian/control.rb,
lib/ian/version.rb,
lib/ian/packager.rb

Defined Under Namespace

Modules: Utils Classes: Control, Packager, ValidationError

Constant Summary collapse

VERSION =
"0.9.3"

Class Method Summary collapse

Class Method Details

.build_package(path, log) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/ian.rb', line 68

def build_package(path, log)
  c = control(path)
  c[:size] = Utils.determine_installed_size(path)
  Ian::Control.save(c, ctrlpath(path))

  pkgr = Ian::Packager.new(path, c, log)
  pkgr.run
end

.control(path = nil) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/ian.rb', line 59

def control(path=nil)
  if path.nil?
    return Control.default
  else
    path = ctrlpath(path) if File.basename(path) != "DEBIAN"
    return Control.load_file(path)
  end
end

.create(name, log) ⇒ Object

create a new DEBIAN package



22
23
24
25
26
27
# File 'lib/ian.rb', line 22

def create(name, log)
  path = File.expand_path(name)
  FileUtils.mkdir(path)

  init(path, log)
end

.ctrlpath(path) ⇒ Object



17
18
19
# File 'lib/ian.rb', line 17

def ctrlpath(path)
  "#{debpath(path)}/control"
end

.debpath(path) ⇒ Object



13
14
15
# File 'lib/ian.rb', line 13

def debpath(path)
  "#{path}/DEBIAN"
end

.init(path, log) ⇒ Object

initialize a new DEBIAN package



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
# File 'lib/ian.rb', line 30

def init(path, log)
  dpath = debpath(path)
  cpath = ctrlpath(path)

  FileUtils.mkdir_p(dpath)
  log.info "Created DEBIAN folder"

  c = Control.default
  c[:package] = File.basename(path)
  Control.save(c, cpath)
  log.info "Generated #{cpath}"

  pi = "#{dpath}/postinst"

  File.write(pi, "#!/bin/bash\n\n\nexit 0;")
  log.info "Generated #{pi}"

  FileUtils.chmod(0755, Dir["#{dpath}/*"])
  FileUtils.chmod(0755, dpath)

  #cfg = {}

  #File.write("#{path}/ian.yml", cfg.to_yaml)
  #log.info "Generated ian.yml"

  File.write("#{path}/.ianignore", "pkg\n.ianpush\n")
  log.info "Generated .ianignore"
end