Arch utility functions
use Arch::Util qw(run_tla load_file save_file setup_config_dir); my $abrowse_output = run_tla('abrowse --summary --date --creator'); my ($full_version) = run_tla('tree-version'); my @full_revisions = run_tla('logs', '-r', '-f'); my $cfg_dir = setup_config_dir(undef, "archipelago"); my $content = load_file("$cfg_dir/versions.cfg"); $content =~ s/^last_version = .*/last_version = $full_version/m; save_file("$cfg_dir/versions.cfg", $content);
A set of helper functions suitable for \s-1GNU\s0 Arch related projects in Perl.
Higher (object oriented) levels of Arch/Perl library make use of these helper functions.
The following functions are available:
run_tla, run_cmd, run_pipe_from, load_file, save_file, copy_dir, remove_dir, setup_config_dir, standardize_date, date2daysago, date2age, parse_creator_email, adjacent_revision.
The system functions die on errors.
Verify whether the system has a working arch backend installed (and possibly configured by environment variables, like \s-1TLA\s0 or \s-1ARCH_BACKEND\s0), needed for this perl library to function.
Run the given tla subcommand with optional arguments. Return the tla output in the scalar context, and a list of chomp-ed lines in the list context.
Run the given shell command (like wc or awk) with optional arguments. Return the command output in the scalar context, and a list of chomp-ed lines in the list context. run_tla is implemented using run_cmd.
Run the given shell command (like ls or tar) with optional arguments in the separate process. Return the pipe (file handle) that may be used to read the command output from. run_cmd is implemented using run_pipe_from.
Load the given file_name. Return the file content if the returning value is expected. As a side effect, may modify the scalar_ref or array_ref if given, in the last case all file lines are split and chomp-ed.
Save the given content in the given file_name. The content may be either scalar, scalar ref, or array ref (see load_file).
Copy dir1 to dir2 recursivelly, preserving as many attributes as possible.
Remove dir (or dirs) recusivelly. Please be careful.
Create (if needed) the configuration dir that defaults to either $ARCH_MAGIC_DIR or ~/.arch-magic or /tmp/.arch-magic if $HOME is unset. If one or more consecutive subdir given, repeat the same procedure for the sub-directory (including creating and diagnostics if needed). Return a name of the existing directory (including sub-directories if any).
Try to convert the given date string to \*(L"yyyy-mm-dd \s-1HH:MM:SS\s0 \s-1TMZ\s0\*(R". If failed, the original string is returned.
Convert a date string to time difference to now in full days. In list content, return (num_days_ago, unix_time, timezone_str).
Like date2daysago, but return a human readable string, like \*(L"5 days\*(R" or \*(L"-6 weeks\*(R" or \*(L"7 months\*(R" or \*(L"3 years\*(R".
Try to parse the arch my-id of the patch creator. Return a list of his/her name and email.
Given the full_revision and positive or negative offset, try to guess the full name of the adjacent revision.
Awaiting for your reports.
Mikhael Goikhman ([email protected]\*(--Perl-GPL/arch-perl\*(--devel).
For more information, see tla, Arch.