Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
267370d425 | |||
f941a14dc4 | |||
17eb2b9ad1 | |||
3eb87b5907 | |||
c78f9a36d9 | |||
5fd6da816f | |||
d9d807b754 | |||
7c5f748791 | |||
2bda4e6d7c | |||
795a06f4be | |||
e9e2737bd4 | |||
d4f0f15341 | |||
962c54b8e0 | |||
ebdf36d3c0 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
|||||||
pacundo
|
|
||||||
pacundo.1.gz
|
pacundo.1.gz
|
||||||
|
20
Makefile
20
Makefile
@ -24,20 +24,20 @@ ifeq ($(PREFIX),)
|
|||||||
PREFIX := /usr/local
|
PREFIX := /usr/local
|
||||||
endif
|
endif
|
||||||
|
|
||||||
pacundo: pacundo.pl
|
|
||||||
pp -o $@ $^
|
|
||||||
|
|
||||||
pacundo.1.gz: pacundo.1
|
pacundo.1.gz: pacundo.1
|
||||||
gzip -c $^ > $@
|
gzip -c $^ > $@
|
||||||
|
|
||||||
.PHONY: install clean
|
.PHONY: clean doc install uninstall
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) pacundo
|
|
||||||
$(RM) pacundo.1.gz
|
$(RM) pacundo.1.gz
|
||||||
|
|
||||||
install: pacundo pacundo.1.gz
|
doc: pacundo.1.gz
|
||||||
install -d $(PREFIX)/bin
|
|
||||||
install -m 755 pacundo $(PREFIX)/bin/
|
install: pacundo.1.gz
|
||||||
install -d $(PREFIX)/share/man/man1
|
install -Dm755 pacundo.pl $(PREFIX)/bin/pacundo
|
||||||
install -m 644 pacundo.1.gz $(PREFIX)/share/man/man1/
|
install -Dm644 pacundo.1.gz $(PREFIX)/share/man/man1/
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
$(RM) $(PREFIX)/bin/pacundo
|
||||||
|
$(RM) $(PREFIX)/share/man/man1/pacundo.1.gz
|
||||||
|
26
README.md
26
README.md
@ -11,13 +11,13 @@ to boot from a USB depending on just how broken it is).
|
|||||||
|
|
||||||
- Perl 5
|
- Perl 5
|
||||||
- `File::ReadBackwards` module
|
- `File::ReadBackwards` module
|
||||||
- PAR Packager (for compiling)
|
- cURL
|
||||||
- GNU Makefile
|
- GNU Make
|
||||||
|
|
||||||
You can install these packages with the following command:
|
You can install these packages with the following command:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
# pacman -S perl perl-file-readbackwards perl-par-packer
|
# pacman -S perl perl-file-readbackwards curl
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compiling & Installing
|
### Compiling & Installing
|
||||||
@ -49,6 +49,26 @@ Look at the man-page (`man pacundo`) for more information.
|
|||||||
|
|
||||||
- [yay](https://github.com/Jguer/yay)
|
- [yay](https://github.com/Jguer/yay)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
If you find any issues, feel free to report them on GitHub or send me an E-Mail
|
||||||
|
(see my website/profile for the address). I will add these issues to my personal
|
||||||
|
Gitea page and (unless specified otherwise) mention you as the person who found
|
||||||
|
the issue.
|
||||||
|
|
||||||
|
For patches/pull requests, if you open a PR on GitHub I will likely not merge
|
||||||
|
directly but instead apply the patches locally (via Git patches, conserving
|
||||||
|
authorship), push them to my Gitea repository, which will finally be mirrored to
|
||||||
|
GitHub. However, you can save me a bit of work by just sending me the Git
|
||||||
|
patches directly (via E-Mail).
|
||||||
|
|
||||||
|
If you're looking for a way to contribute, there are a few to-do items within
|
||||||
|
the code which you can find using `grep`:
|
||||||
|
|
||||||
|
```console
|
||||||
|
# grep -n "TODO" pacundo.pl
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is licensed under the terms & conditions of the Zlib license.
|
This project is licensed under the terms & conditions of the Zlib license.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
.TH PACUNDO "1" "April 2024" "pacundo 1.0.1" "User Commands"
|
.TH PACUNDO "1" "April 2024" "pacundo 1.1.1" "User Commands"
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
pacundo - A time machine to return your ArchLinux machine back to a working state.
|
pacundo - A time machine to roll back your ArchLinux machine to a working state.
|
||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
.B pacundo
|
.B pacundo
|
||||||
[\fI\-i\fR|\fI\-r\fR] [\fI\-t\fR <\fInum\fR>] [\fI\-d\fR]
|
[\fI\-i\fR|\fI\-r\fR] [\fI\-t\fR <\fInum\fR>] [\fI\-d\fR]
|
||||||
|
61
pacundo.pl
61
pacundo.pl
@ -29,7 +29,7 @@ use feature qw(signatures);
|
|||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use File::ReadBackwards;
|
use File::ReadBackwards;
|
||||||
|
|
||||||
my $VERSION = '1.0.1';
|
my $VERSION = '1.1.1';
|
||||||
my $PROG_NAME = 'pacundo';
|
my $PROG_NAME = 'pacundo';
|
||||||
|
|
||||||
sub print_version() {
|
sub print_version() {
|
||||||
@ -39,7 +39,7 @@ sub print_version() {
|
|||||||
|
|
||||||
sub print_help() {
|
sub print_help() {
|
||||||
&print_version();
|
&print_version();
|
||||||
print("A time machine to return your ArchLinux machine back to a working state.
|
print("A time machine to roll back your ArchLinux machine to a working state.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
$PROG_NAME [-i|-r] [-t <num>] [-d]
|
$PROG_NAME [-i|-r] [-t <num>] [-d]
|
||||||
@ -183,6 +183,7 @@ sub find_local_pkg($pkgmgr, $pkg_name, $pkg_ver='') {
|
|||||||
my $pkg_file = '';
|
my $pkg_file = '';
|
||||||
my $pkg_pat;
|
my $pkg_pat;
|
||||||
my $repo = `$pkgmgr->{info} $pkg_name | awk '{ if (\$1 == "Repository") print \$3; }'`;;
|
my $repo = `$pkgmgr->{info} $pkg_name | awk '{ if (\$1 == "Repository") print \$3; }'`;;
|
||||||
|
chomp($repo);
|
||||||
|
|
||||||
if ($pkg_ver ne '') {
|
if ($pkg_ver ne '') {
|
||||||
$pkg_pat = "$pkg_name-$pkg_ver-*.pkg.tar.zst";
|
$pkg_pat = "$pkg_name-$pkg_ver-*.pkg.tar.zst";
|
||||||
@ -194,14 +195,18 @@ sub find_local_pkg($pkgmgr, $pkg_name, $pkg_ver='') {
|
|||||||
my $aur_dir;
|
my $aur_dir;
|
||||||
|
|
||||||
if ($pkgmgr->{name} eq 'yay') {
|
if ($pkgmgr->{name} eq 'yay') {
|
||||||
$aur_dir = "$ENV{'XDG_CACHE_HOME'}/yay/$pkg_name";
|
if ($ENV{'XDG_CACHE_HOME'} ne '') {
|
||||||
|
$aur_dir = "$ENV{'XDG_CACHE_HOME'}/yay/$pkg_name";
|
||||||
|
} else {
|
||||||
|
$aur_dir = "$ENV{'HOME'}/.cache/yay/$pkg_name";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$pkg_file = `ls $aur_dir/$pkg_pat | tail -n1`;
|
$pkg_file = `ls $aur_dir/$pkg_pat 2> /dev/null | tail -n1`;
|
||||||
} else {
|
} else {
|
||||||
$pkg_file = `ls /var/cache/pacman/pkg/$pkg_pat | tail -n1`;
|
$pkg_file = `ls /var/cache/pacman/pkg/$pkg_pat 2> /dev/null | tail -n1`;
|
||||||
}
|
}
|
||||||
|
|
||||||
chomp($pkg_file);
|
chomp($pkg_file);
|
||||||
@ -209,6 +214,44 @@ sub find_local_pkg($pkgmgr, $pkg_name, $pkg_ver='') {
|
|||||||
return $pkg_file;
|
return $pkg_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub find_remote_archive($pkgmgr, $pkg_name, $pkg_ver) {
|
||||||
|
my $repo = `$pkgmgr->{info} $pkg_name | awk '{ if (\$1 == "Repository") print \$3; }'`;;
|
||||||
|
chomp($repo);
|
||||||
|
# TODO: look through git history for version.
|
||||||
|
if ($repo eq 'aur') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: Probably a better way of managing architectures. There should be a
|
||||||
|
# way of getting the architecture of the package.
|
||||||
|
my @archs = (`uname -m`, 'any');
|
||||||
|
my $ala_url = "https://archive.archlinux.org/packages/" .
|
||||||
|
substr($pkg_name,0,1) . "/" . $pkg_name;
|
||||||
|
my $pkg_file = '';
|
||||||
|
|
||||||
|
foreach my $arch (@archs) {
|
||||||
|
chomp($arch);
|
||||||
|
my $filename = "$pkg_name-$pkg_ver-$arch.pkg.tar.zst";
|
||||||
|
my $pkg_url = "$ala_url/$filename";
|
||||||
|
my $output_file = "/tmp/$filename";
|
||||||
|
|
||||||
|
my $resp = `curl -Lo $output_file -s -w '%{http_code}\n' $pkg_url`;
|
||||||
|
chomp($resp);
|
||||||
|
if ($resp eq '200') {
|
||||||
|
system("curl -Lo $output_file.sig -s $pkg_url.sig");
|
||||||
|
$pkg_file = $output_file;
|
||||||
|
last;
|
||||||
|
} else {
|
||||||
|
unlink $output_file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pkg_file ne '') {
|
||||||
|
print("Downloaded from archive: $pkg_file\n");
|
||||||
|
}
|
||||||
|
return $pkg_file;
|
||||||
|
}
|
||||||
|
|
||||||
getopts("irt:dvh", \my %opts);
|
getopts("irt:dvh", \my %opts);
|
||||||
|
|
||||||
if ($opts{'v'}) {
|
if ($opts{'v'}) {
|
||||||
@ -252,10 +295,12 @@ foreach my $tx (@undo_txs) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
my $pkg_file = &find_local_pkg($pkgmgr, $tx->{pkg_name}, $tx->{oldver});
|
my $pkg_file = &find_local_pkg($pkgmgr, $tx->{pkg_name}, $tx->{oldver});
|
||||||
if ($pkg_file eq '') {
|
$pkg_file = &find_remote_archive($pkgmgr, $tx->{pkg_name}, $tx->{oldver}) if ($pkg_file eq '');
|
||||||
$remote_install_pkgs .= "$tx->{pkg_name} ";
|
|
||||||
} else {
|
if ($pkg_file ne '') {
|
||||||
$local_install_pkgs .= "$pkg_file ";
|
$local_install_pkgs .= "$pkg_file ";
|
||||||
|
} else {
|
||||||
|
print(STDERR "Unable to find $tx->{pkg_name} $tx->{pkg_ver}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user