nub 0.0.86 → 0.0.87

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 +22 -19
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40133749abed38dab32447b7367ffa33a4184cbffaec4d2126150eb066705329
4
- data.tar.gz: cd4b9c8fc7eeb37c20fccce0f273b9f551ecf4621bd56ed44ab036918bdf2983
3
+ metadata.gz: 7cdb80d8114aa0ed667633afab685c21bb64bdbc904d01c2eab545c9b77dccf5
4
+ data.tar.gz: a29253c340ab74854c13035ed17f03c902690b438cc0c6e1314abc4746b697d5
5
5
  SHA512:
6
- metadata.gz: 0e8fc3cafc6b1f8fea47c6b80dd4c480791e010c1f0b3077f57a2a1b93577b49f187bc562bbd4c2ad71ee0b2474566212de9cc561a34c674a5bdc820309a0038
7
- data.tar.gz: 5db3e310035c963d21d2835df541d6fddd41eb9796111e888ab1ac50cf25b8d0dd24b0a4fe088d68e000f50161e14d8655ebd925ddb2cc43a358bf7f9bdef0c7
6
+ metadata.gz: b2169fa40613694bfd24a6e81ccf043fa6491fd5904d7c48bf7fb1be2a5bb1a5ed78b466972fa81a1de8b3fca41a55e54678313c79c87b239d3181a941a8da40
7
+ data.tar.gz: 852f5eadcfa7dd9474b1556ce03a2c140865899143caec85ed53aff9395f2efba70b968404322c999c1cbe8de2730f62c3853fad4fb0d09535798ba95a0140f4
data/lib/nub/pacman.rb CHANGED
@@ -38,7 +38,8 @@ module Pacman
38
38
  # @param arch [String] capturing the pacman target architecture e.g. x86_64
39
39
  # @param sysroot [String] path to the system root to use
40
40
  # @param env [Hash] of environment variables to set for session
41
- def init(path, config, mirrors, arch:'x86_64', sysroot:nil, env:nil)
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
43
  mirrors = [mirrors] if mirrors.is_a?(String)
43
44
  self.path = path
44
45
  self.arch = arch
@@ -51,24 +52,26 @@ module Pacman
51
52
  Log.die("pacman config '#{config}' doesn't exist") unless File.exist?(config)
52
53
 
53
54
  # Copy in pacman files for use in target
54
- FileUtils.rm_rf(File.join(path, '.'))
55
- FileUtils.mkdir_p(File.join(self.path, 'db'))
56
- FileUtils.mkdir_p(self.sysroot) if self.sysroot && !Dir.exist?(self.sysroot)
57
- FileUtils.cp(config, path, preserve: true)
58
- FileUtils.cp(mirrors, path, preserve: true)
59
-
60
- # Update the given pacman config file to use the given path
61
- FileUtils.replace(self.config, /(Architecture = ).*/, "\\1#{self.arch}")
62
- FileUtils.replace(self.config, /#(DBPath\s+= ).*/, "\\1#{File.join(self.path, 'db')}")
63
- FileUtils.replace(self.config, /#(CacheDir\s+= ).*/, "\\1#{File.join(self.path, 'cache')}")
64
- FileUtils.replace(self.config, /#(LogFile\s+= ).*/, "\\1#{File.join(self.path, 'pacman.log')}")
65
- FileUtils.replace(self.config, /#(GPGDir\s+= ).*/, "\\1#{File.join(self.path, 'gnupg')}")
66
- FileUtils.replace(self.config, /#(HookDir\s+= ).*/, "\\1#{File.join(self.path, 'hooks')}")
67
- FileUtils.replace(self.config, /.*(\/.*mirrorlist).*/, "Include = #{self.path}\\1")
68
-
69
- # Initialize pacman keyring
70
- Sys.exec("pacman-key --config #{self.config} --init")
71
- Sys.exec("pacman-key --config #{self.config} --populate #{repos * ' '}")
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
72
+ Sys.exec("pacman-key --config #{self.config} --init")
73
+ Sys.exec("pacman-key --config #{self.config} --populate #{repos * ' '}")
74
+ end
72
75
  end
73
76
 
74
77
  # Update the pacman database
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.86
4
+ version: 0.0.87
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Crummett