Skip to content

Commit 11cc4de

Browse files
author
qount25
committed
Pgpm::Deb::Buider#cleanup stops & removes podman container, removes tmp dir
1 parent 676ac4d commit 11cc4de

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/pgpm/deb/builder.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ def build
1414
puts "build()"
1515
prepare
1616
generate_deb_src_files
17-
#create_container
17+
create_container
1818
#run_pbuilder
1919
#copy_build_from_container
20-
#cleanup
20+
cleanup
2121
end
2222

2323
private
@@ -73,6 +73,24 @@ def run_container_command(cmd)
7373
end
7474

7575
def cleanup
76+
puts "Cleaning up..."
77+
78+
# Stop and destroy podman container
79+
puts " Stopping podman container: #{@container_name}"
80+
system("podman stop #{@container_name}")
81+
puts " Destroying podman container: #{@container_name}"
82+
system("podman container rm #{@container_name}")
83+
84+
# Remove temporary files
85+
#
86+
# Make sure @pgpm_dir starts with "/tmp/" or we may accidentally
87+
# delete something everything! You can never be sure!
88+
if @pgpm_dir.start_with?("/tmp/")
89+
puts " Removing temporary files in #{@pgpm_dir}"
90+
FileUtils.rm_rf(@pgpm_dir)
91+
else
92+
puts "WARNING: will not remove temporary files, strange path: \"#{@pgpm_dir}\""
93+
end
7694
end
7795

7896
# Needed because SELinux requires :z suffix for mounted directories to

0 commit comments

Comments
 (0)