diff options
author | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2018-01-13 17:05:27 +0000 |
---|---|---|
committer | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2018-01-14 22:29:54 +0000 |
commit | 4c3460bb0e1b4886a4e90aaf33257c55f0971b50 (patch) | |
tree | c899561acdd39ddb29cbc7e36cd1d04d5e7269c9 /lib | |
parent | 70d61bc7db7211347547476c16c254df94cb737d (diff) | |
download | drakiso-4c3460bb0e1b4886a4e90aaf33257c55f0971b50.tar drakiso-4c3460bb0e1b4886a4e90aaf33257c55f0971b50.tar.gz drakiso-4c3460bb0e1b4886a4e90aaf33257c55f0971b50.tar.bz2 drakiso-4c3460bb0e1b4886a4e90aaf33257c55f0971b50.tar.xz drakiso-4c3460bb0e1b4886a4e90aaf33257c55f0971b50.zip |
Add functions to add/remove /dev/null in chroots.
Sometimes we only need /dev/null, so just create that. Check we get
passed a non-empty string for the root location, to make sure we don't
accidently delete the build system's /dev/null.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MGA/DrakISO/Utils.pm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/MGA/DrakISO/Utils.pm b/lib/MGA/DrakISO/Utils.pm index f98e46d..c283d0d 100644 --- a/lib/MGA/DrakISO/Utils.pm +++ b/lib/MGA/DrakISO/Utils.pm @@ -33,7 +33,8 @@ use IO::Select; use Exporter; our @ISA = qw(Exporter); -our @EXPORT = qw($sudo directory_usage glob__ run_ run_as_root run_in_root copy_or_link mount mount_system_fs umount_all_in_root); +our @EXPORT = qw($sudo directory_usage glob__ run_ run_as_root run_in_root copy_or_link + mk_dev_null rm_dev_null mount mount_system_fs umount_all_in_root); our $sudo = $> ? 'sudo' : ''; @@ -116,6 +117,20 @@ sub copy_or_link { or die "ERROR: couldn't link $src_file to $dst_file\n"; } +sub mk_dev_null { + my ($root) = @_; + $root or die; + return if -e $root . '/dev/null'; + run_as_root('mkdir', '-p', $root . '/dev'); + run_as_root('cp', '-a', '/dev/null', $root . '/dev'); +} + +sub rm_dev_null { + my ($root) = @_; + $root or die; + run_as_root('rm', $root . '/dev/null') if -e $root . '/dev/null'; +} + sub mount { my ($dst, $src, @o_options) = @_; mkdir_p($dst); |