MDK::Common::System - system-related useful functions
use MDK::Common::System qw(:all);
architecture compatibility mapping (eg: k6 => i586, k7 => k6 ...)
7 bit ascii characters
sizeof(int)
$sizeof_int * 8
return the architecture (eg: i686, ppc, ia64, k7...)
find the first corresponding magic in FILENAME. eg of LIST:
[ 'empty', 0, "\0\0\0\0" ], [ 'grub', 0, "\xEBG", 0x17d, "stage1 \0" ], [ 'lilo', 0x2, "LILO" ], sub { my ($F) = @_; #- standard grub has no good magic (Mageia's grub is patched to have "GRUB" at offset 6) #- so scanning a range of possible places where grub can have its string my ($min, $max, $magic) = (0x176, 0x181, "GRUB \0"); my $tmp; sysseek($F, 0, 0) && sysread($F, $tmp, $max + length($magic)) or return; substr($tmp, 0, 2) eq "\xEBH" or return; index($tmp, $magic, $min) >= 0 && "grub"; },
where each entry is [ magic_name, offset, string, offset, string, ... ].
return the list of users as given by getpwent (see perlfunc)
getpwent
checks whether or not the user is a system user or a real user
checks whether or not the group is a system group or a real group
return the list of home (eg: /home/foo, /home/pixel, ...)
return the directories where we can find dot files: homes, /root and /etc/skel
return the list of unprivilegied users (uses the is_real_user function to filter out system users from the full list)
calls the syscall NAME
useful to know the length of a pack format string.
pack
psizeof("I I I C C S") = 4 + 4 + 4 + 1 + 1 + 2 = 16
size of swap + memory
size of RAM as reported by the BIOS (it is a round number that can be displayed or given as "mem=128M" to the kernel)
returns the epoch in microseconds
takes care of CR/LF translation
return the first absolute file in $PATH (similar to which(1) and whereis(1))
returns a hash associating shell variables to their value. useful for config files such as /etc/sysconfig files
write file in shell format association a shell variable + value for each key/value
restrict the fields that will be printed to LIST
like setVarsInSh with INT being the chmod value for the config file
like setVarsInSh but keeping the entries in the file
like addVarsInShMode but keeping the entries in the file
same as setExportedVarsInSh for csh format
setExportedVarsInSh
read in a template file, replace keys @@@key@@@ with value, save it in out file
read in a template file, replace keys @@@key@@@ with value, save it in every homes. If BOOL is true, overwrite existing files. FILENAME_OUT must be a relative filename
reads GNOME-like and KDE-like config files (aka windows-like). You must give a category. eg:
read_gnomekderc("/etc/skels/.kderc", 'KDE')
modifies GNOME-like and KDE-like config files (aka windows-like). If the category doesn't exist, it creates it. eg:
update_gnomekderc("/etc/skels/.kderc", 'KDE', kfmIconStyle => "Large")
return the list of process ids matching the regexp
is ARCH1 compatible with ARCH2?
better_arch('i386', 'ia64') and better_arch('ia64', 'i386') are false
better_arch('k7', 'k6') is true and better_arch('k6', 'k7') is false
test the architecture compatibility. eg:
compat_arch('i386') is false on a ia64
compat_arch('k6') is true on a k6 and k7 but false on a i386 and i686
MDK::Common
To install MDK::Common, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MDK::Common
CPAN shell
perl -MCPAN -e shell install MDK::Common
For more information on module installation, please visit the detailed CPAN module installation guide.