Fix "vargant package" for LXC 2.1+ config format

New config format would be under `lxc.rootfs.path` and be prefixed by
`dir:`.
This commit is contained in:
Virgil Dupras 2018-07-24 12:23:25 -04:00
parent a1aa60ded5
commit 2a5510b34c

View file

@ -50,20 +50,20 @@ module Vagrant
end
def rootfs_path
config_entry = config_string.match(/^lxc\.rootfs\s+=\s+(.+)$/)[1]
case config_entry
when /^overlayfs:/
pathtype, path = config_string.match(/^lxc\.rootfs(?:\.path)?\s+=\s+(.+:)?(.+)$/)[1..2]
case pathtype
when 'overlayfs:'
# Split on colon (:), ignoring any colon escaped by an escape character ( \ )
# Pays attention to when the escape character is itself escaped.
fs_type, master_path, overlay_path = config_entry.split(/(?<!\\)(?:\\\\)*:/)
_, overlay_path = config_entry.split(/(?<!\\)(?:\\\\)*:/)
if overlay_path
Pathname.new(overlay_path)
else
# Malformed: fall back to prior behaviour
Pathname.new(config_entry)
Pathname.new(path)
end
else
Pathname.new(config_entry)
Pathname.new(path)
end
end