lib/kiwi_config.rb in machinery-tool-1.8.2 vs lib/kiwi_config.rb in machinery-tool-1.9.0
- old
+ new
@@ -27,11 +27,11 @@
@system_description.assert_scopes(
"repositories",
"packages",
"os"
)
- check_existance_of_extraced_files
+ check_existance_of_extracted_files
generate_config
end
def write(output_location)
@@ -93,39 +93,60 @@
@sh << "perl /tmp/#{merge_script_name} /etc/passwd /etc/shadow /etc/group\n"
@sh << "rm /tmp/#{merge_script_name}\n"
end
def inject_extracted_files(output_location)
- ["config_files", "changed_managed_files"].each do |dir|
- path = @system_description.scope_file_store(dir).path
- if path
- output_root_path = File.join(output_location, "root")
- FileUtils.mkdir_p(output_root_path)
- FileUtils.cp_r(Dir.glob("#{path}/*"), output_root_path)
+ ["changed_managed_files", "config_files"].each do |scope|
+ next if !@system_description.scope_extracted?(scope)
+
+ output_root_path = File.join(output_location, "root")
+ FileUtils.mkdir_p(output_root_path)
+
+ @system_description[scope].files.each do |file|
+ if file.deleted?
+ @sh << "rm -rf '#{quote(file.name)}'\n"
+ elsif file.directory?
+ @sh << <<EOF
+chmod #{file.mode} '#{quote(file.name)}'
+chown #{file.user}:#{file.group} '#{quote(file.name)}'
+EOF
+ elsif file.file?
+ @system_description[scope].write_file(file, output_root_path)
+ @sh << <<EOF
+chmod #{file.mode} '#{quote(file.name)}'
+chown #{file.user}:#{file.group} '#{quote(file.name)}'
+EOF
+ elsif file.link?
+ @sh << <<EOF
+rm -rf '#{quote(file.name)}'
+ln -s '#{quote(file.target)}' '#{quote(file.name)}'
+chown --no-dereference #{file.user}:#{file.group} '#{quote(file.name)}'
+EOF
+ end
end
end
- unmanaged_files_path = @system_description.
- scope_file_store("unmanaged_files").path
- if unmanaged_files_path
- filter = "unmanaged_files_#{@name}_excludes"
- destination = File.join(output_location, "root", "tmp")
+ if @system_description.scope_extracted?("unmanaged_files")
+ destination = File.join(output_location, "root", "tmp", "unmanaged_files")
FileUtils.mkdir_p(destination, mode: 01777)
- FileUtils.cp_r(unmanaged_files_path, destination)
+ filter = "unmanaged_files_#{@name}_excludes"
+
+ @system_description.unmanaged_files.export_files_as_tarballs(destination)
+
FileUtils.cp(
File.join(Machinery::ROOT, "export_helpers/#{filter}"),
- destination
+ File.join(output_location, "root", "tmp")
)
@sh << "# Apply the extracted unmanaged files\n"
@sh << "find /tmp/unmanaged_files -name *.tgz -exec " \
"tar -C / -X '/tmp/#{filter}' -xf {} \\;\n"
@sh << "rm -rf '/tmp/unmanaged_files' '/tmp/#{filter}'\n"
end
end
- def check_existance_of_extraced_files
+ def check_existance_of_extracted_files
missing_scopes = []
["config_files", "changed_managed_files", "unmanaged_files"].each do |scope|
if @system_description[scope] &&
!@system_description.scope_file_store(scope).path
@@ -188,11 +209,10 @@
end
apply_repositories(xml)
apply_packages(xml)
- apply_extracted_files_attributes
apply_services
end
end
pre_process_config
@@ -255,28 +275,9 @@
"The system description doesn't contain any enabled or network reachable repository." \
" Please make sure that there is at least one accessible repository with all the" \
" required packages."
)
)
- end
- end
- end
-
- def apply_extracted_files_attributes
- ["config_files", "changed_managed_files"].each do |scope|
- if @system_description[scope]
- deleted, files = @system_description[scope].files.partition do |f|
- f.changes == Machinery::Array.new(["deleted"])
- end
-
- files.each do |file|
- @sh << "chmod #{file.mode} '#{file.name}'\n"
- @sh << "chown #{file.user}:#{file.group} '#{file.name}'\n"
- end
-
- deleted.each do |file|
- @sh << "rm -rf '#{file.name}'\n"
- end
end
end
end
def apply_services