NAME
Sys::Export::Linux - Export subsets of a Linux system
SYNOPSIS
use Sys::Export::Linux;
my $exporter= Sys::Export::Linux->new(
src => '/', dst => '/initrd'
);
$exporter->add('bin/busybox');
$exporter->add_passwd;
$exporter->add_localtime("UTC");
DESCRIPTION
This object extends Sys::Export::Unix with Linux-specific helpers and special cases.
See Sys::Export::Unix
for the list of core attributes and methods.
METHODS
add_passwd
$exporter->add_passwd(%options)
This method writes the Linux password files ( /etc/passwd
, /etc/group
, /etc/shadow
) either according to the contents of "dst_userdb" in Sys::Export::Unix (if you used name-based exports) or according to "src_userdb" in Sys::Export::Unix filtered by "dst_uid_used" in Sys::Export::Unix if dst_userdb
is not defined.
In the first pattern, you've either pre-specified the dst_userdb
users, or built it lazily as you exported files. The dst_userdb
contains the complete contents of passwd
, group
, and shadow
and this method simply generates and adds those files.
In the second pattern, you want the destination userdb to be a subset of the source userdb according to which UIDs and GIDs were actually used.
If you actually just want to copy the entire source user database files, you could just call
$exporter->add(qw( /etc/passwd /etc/group /etc/shadow ));
so that pattern doesn't need a special helper method.
Options:
- etc_path
-
Specify an alternative directory to '/etc' to write the files
add_localtime
$exporter->add_localtime($tz_name);
Generate the symlink in /etc/localtime
, *or* export the timezone file directly to that path if the system image lacks /usr/share/zoneinfo
.
Linux uses a symlink at /etc/localtime
to point to a compiled zoneinfo file describing the current time zone. You can simply export this symlink, but if you are building a minimal system image (like initrd) you might not be exporting the timezone database at /usr/share/zoneinfo
. In that case, you want the single timezone file copied to /etc/localtime
.
This method looks for the zone file in your destination filesystem, and if not found there, it looks in the source filesystem, and if not there either, it checks the host filesystem. If it can't find this timezone in any of those locations, it dies.
VERSION
version 0.003
AUTHOR
Michael Conrad <mike@nrdvana.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2025 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.