Compare commits

...

2 Commits

Author SHA1 Message Date
Nicolás A. Ortega Froysa b7e98246ad Align assignment operators.
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
2024-03-27 10:33:50 +01:00
Nicolás A. Ortega Froysa 2d4ec58a81 Get package manager variables.
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
2024-03-27 10:26:35 +01:00
1 changed files with 27 additions and 2 deletions

View File

@ -29,7 +29,7 @@ use feature qw(signatures);
use Getopt::Std;
use File::ReadBackwards;
my $VERSION = "1.0";
my $VERSION = "1.0";
my $PROG_NAME = "pacundo";
sub print_version() {
@ -136,6 +136,30 @@ $n, $tx->{action}, $tx->{pkg_name}
return @sel_undo;
}
sub get_pkgmgr() {
my $mgr = $ENV{DEFAULT_PKGMGR} // 'pacman';
my $mgr_bin = `which $mgr`;
if ($? != 0) {
print(STDERR "Failed to find pacman executable. Are you using an ArchLinux system?\n");
exit 1;
}
my $mgr_cmd_search = "$mgr_bin -Ss";
my $mgr_cmd_install_remote = "$mgr_bin -S";
my $mgr_cmd_install_local = "$mgr_bin -U";
my %pkgmgr = (
name => $mgr,
bin => $mgr_bin,
search => $mgr_cmd_search,
install_remote => $mgr_cmd_install_remote,
install_local => $mgr_cmd_install_local,
);
return \%pkgmgr;
}
getopts("irt:dvh", \my %opts);
if ($opts{'v'}) {
@ -153,10 +177,11 @@ if ($opts{'v'}) {
exit 1;
}
my $r_flag = $opts{'r'} // 0;
my $r_flag = $opts{'r'} // 0;
my $dry_run = $opts{'d'} // 0;
my $num_txs = $opts{'t'} // 1;
my $pkgmgr = &get_pkgmgr();
my @undo_txs = &read_txs($num_txs);
# Interactive mode