nub 0.0.92 → 0.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nub/pacman.rb +37 -25
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddedc14522a322323030a787748f48e55a26ae42c7626f4176a3758e8ffe8e2f
4
- data.tar.gz: a53fb22a5fdd9a51ef40b75612e6b41b6dfefd97ed73e733a8055d839e6adf1e
3
+ metadata.gz: f7a4379ba48159ccd5b38fb7df34e7a6bd42beddab3bd9e526d98f7f3edbdea4
4
+ data.tar.gz: bd737cfaa9e91f42c4ee606e6948d7f13e97da92c71bde75fea6a0f1b5106484
5
5
  SHA512:
6
- metadata.gz: 10ff65541547e6d81c303e9f014e2b6ccec19f813d45735899a07203f78b686375457a6a7fa88e192b31dded947edfdf75b348f9f91cad328728507e61bf5e34
7
- data.tar.gz: e0e518a84cf4206795394b7e27cbb0540fb96393030f441dc2ee9b292824ed580ba903c18b013e116b8becbce8e1d0ded2f490df18c6914f3a4ac6bd0428d53c
6
+ metadata.gz: 32a4ac6a461560730cee791da03a115ac3cc8f9851b25a6eecda1a5622858d777b8d30bd874a3775323d6d6e4e9257109db6885fe94facf54a38b32934d8d954
7
+ data.tar.gz: ad00aa779d1cb297a761f089444d45d72def79074c5ce14276b3f74a40d15a2071e9206862f2e6552a186142c441c4f4b527a50dcf101aa043eab99d6553bc22
data/lib/nub/pacman.rb CHANGED
@@ -28,47 +28,59 @@ require_relative 'fileutils'
28
28
  # Wrapper around system Arch Linux pacman
29
29
  module Pacman
30
30
  extend self
31
- mattr_accessor(:path, :config, :sysroot, :mirrors, :repos, :arch, :env)
31
+ mattr_accessor(:path, :sysroot, :config, :mirrors, :repos, :arch,
32
+ :env, :log, :db_path, :gpg_path, :hooks_path, :cache_path)
32
33
 
33
34
  # Configure pacman for the given root
34
- # @param path [String] path where all pacman artifacts will be (i.e. logs, cache etc...)
35
+ # @param path [String] is the path on the host for pacman
36
+ # @param sysroot [String] path to the system root to use
35
37
  # @param config [String] config file path to use, note gets copied in
36
38
  # @param mirrors [Array] of mirror paths to use, mirror file name is expected to be the
37
39
  # name of the repo e.g. archlinux.mirrorlist
38
40
  # @param arch [String] capturing the pacman target architecture e.g. x86_64
39
- # @param sysroot [String] path to the system root to use
40
41
  # @param env [Hash] of environment variables to set for session
41
- # @param clean [Bool] true triggers a clean overwrite
42
- def init(path, config, mirrors, arch:'x86_64', sysroot:nil, env:nil, clean:false)
42
+ def init(path, sysroot, config, mirrors, arch:'x86_64', env:nil)
43
+
44
+ # All configs are on the sysroot except config and cache
43
45
  mirrors = [mirrors] if mirrors.is_a?(String)
44
46
  self.path = path
45
47
  self.arch = arch
48
+ self.env = env
46
49
  self.sysroot = sysroot
47
- self.config = File.join(path, File.basename(config))
50
+ self.log = File.join(sysroot, 'var/log/pacman.log')
51
+ self.db_path = File.join(self.sysroot, 'var/lib/pacman')
52
+ self.gpg_path = File.join(self.sysroot, 'etc/pacman.d/gnupg')
53
+ self.hooks_path = File.join(self.sysroot, 'etc/pacman.d/hooks')
48
54
  self.repos = mirrors.map{|x| File.basename(x, '.mirrorlist')}
49
- self.mirrors = mirrors.map{|x| File.join(path, File.basename(x))}
55
+ mirrors_path = File.join(self.sysroot, 'etc/pacman.d')
56
+ self.mirrors = mirrors.map{|x| File.join(mirrors_path, File.basename(x))}
57
+
58
+ # Config and cache are kept separate from the sysroot
59
+ self.config = File.join(self.path, File.basename(config))
60
+ self.cache_path = File.join(self.path, 'cache')
50
61
 
51
62
  # Validate incoming params
52
63
  Log.die("pacman config '#{config}' doesn't exist") unless File.exist?(config)
53
64
 
54
65
  # Copy in pacman files for use in target
55
- if clean || !File.exist?(self.config)
56
- FileUtils.rm_rf(File.join(path, '.'))
57
- FileUtils.mkdir_p(File.join(self.path, 'db'))
58
- FileUtils.mkdir_p(self.sysroot) if self.sysroot && !Dir.exist?(self.sysroot)
59
- FileUtils.cp(config, path, preserve: true)
60
- FileUtils.cp(mirrors, path, preserve: true)
61
-
62
- # Update the given pacman config file to use the given path
63
- FileUtils.replace(self.config, /(Architecture = ).*/, "\\1#{self.arch}")
64
- FileUtils.replace(self.config, /#(DBPath\s+= ).*/, "\\1#{File.join(self.path, 'db')}")
65
- FileUtils.replace(self.config, /#(CacheDir\s+= ).*/, "\\1#{File.join(self.path, 'cache')}")
66
- FileUtils.replace(self.config, /#(LogFile\s+= ).*/, "\\1#{File.join(self.path, 'pacman.log')}")
67
- FileUtils.replace(self.config, /#(GPGDir\s+= ).*/, "\\1#{File.join(self.path, 'gnupg')}")
68
- FileUtils.replace(self.config, /#(HookDir\s+= ).*/, "\\1#{File.join(self.path, 'hooks')}")
69
- FileUtils.replace(self.config, /.*(\/.*mirrorlist).*/, "Include = #{self.path}\\1")
70
-
71
- # Initialize pacman keyring
66
+ FileUtils.mkdir_p(self.db_path)
67
+ FileUtils.mkdir_p(self.gpg_path)
68
+ FileUtils.mkdir_p(self.hooks_path)
69
+ FileUtils.mkdir_p(self.cache_path)
70
+ FileUtils.cp(config, self.config, preserve: true)
71
+ FileUtils.cp(mirrors, mirrors_path, preserve: true)
72
+
73
+ # Update the given pacman config file to use the given path
74
+ FileUtils.replace(self.config, /(Architecture = ).*/, "\\1#{self.arch}")
75
+ FileUtils.replace(self.config, /#(DBPath\s+= ).*/, "\\1#{self.db_path}")
76
+ FileUtils.replace(self.config, /#(CacheDir\s+= ).*/, "\\1#{self.cache_path}")
77
+ FileUtils.replace(self.config, /#(LogFile\s+= ).*/, "\\1#{self.log}")
78
+ FileUtils.replace(self.config, /#(GPGDir\s+= ).*/, "\\1#{self.gpg_path}")
79
+ FileUtils.replace(self.config, /#(HookDir\s+= ).*/, "\\1#{self.hooks_path}")
80
+ FileUtils.replace(self.config, /.*(\/.*mirrorlist).*/, "Include = #{mirrors_path}\\1")
81
+
82
+ # Initialize pacman keyring
83
+ if !File.exist?(self.config)
72
84
  Sys.exec("pacman-key --config #{self.config} --init")
73
85
  Sys.exec("pacman-key --config #{self.config} --populate #{repos * ' '}")
74
86
  end
@@ -89,7 +101,7 @@ module Pacman
89
101
  cmd = []
90
102
 
91
103
  if self.sysroot
92
- cmd += ["pacstrap", "-Mc", self.sysroot, '--config', self.config]
104
+ cmd += ["pacstrap", "-c", self.sysroot, '--config', self.config]
93
105
  else
94
106
  cmd += ["pacman", "-S"]
95
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.92
4
+ version: 0.0.93
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Crummett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-16 00:00:00.000000000 Z
11
+ date: 2018-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize