nub 0.0.92 → 0.0.93
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nub/pacman.rb +37 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7a4379ba48159ccd5b38fb7df34e7a6bd42beddab3bd9e526d98f7f3edbdea4
|
4
|
+
data.tar.gz: bd737cfaa9e91f42c4ee606e6948d7f13e97da92c71bde75fea6a0f1b5106484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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, :
|
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]
|
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
|
-
|
42
|
-
|
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.
|
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
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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", "-
|
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.
|
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-
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|