commit
d8e4402928
1 changed files with 18 additions and 20 deletions
|
@ -12,8 +12,6 @@ use File::Spec;
|
||||||
# The main info: this is the list of files to remove and the pkg_id.
|
# The main info: this is the list of files to remove and the pkg_id.
|
||||||
my $pkg_id = 'net.johnmacfarlane.pandoc';
|
my $pkg_id = 'net.johnmacfarlane.pandoc';
|
||||||
|
|
||||||
my @pkg_info;
|
|
||||||
|
|
||||||
# Find which, if any, volume Pandoc is installed on.
|
# Find which, if any, volume Pandoc is installed on.
|
||||||
my $volume;
|
my $volume;
|
||||||
|
|
||||||
|
@ -39,12 +37,11 @@ if ( $cur_test =~ m/$pkg_id/ ) {
|
||||||
|
|
||||||
die "Pandoc not installed.\n" if !( defined($volume) );
|
die "Pandoc not installed.\n" if !( defined($volume) );
|
||||||
|
|
||||||
my @pkg_files = ();
|
# Get the list of files to remove.
|
||||||
my $f;
|
my @pkg_files = `pkgutil --volume '$volume' --only-files --files '$pkg_id'`;
|
||||||
for $f (split '\n', `pkgutil --volume '$volume' --only-files --files $pkg_id`) {
|
@pkg_files = map { chomp; File::Spec->rel2abs($_, $volume) } @pkg_files;
|
||||||
push @pkg_files, File::Spec->rel2abs($f, $volume);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
# Confirm uninistall with the user.
|
||||||
print "The following files will be deleted:\n\n";
|
print "The following files will be deleted:\n\n";
|
||||||
print join("\n", @pkg_files);
|
print join("\n", @pkg_files);
|
||||||
print "\n\n";
|
print "\n\n";
|
||||||
|
@ -54,28 +51,29 @@ my $input = <STDIN>;
|
||||||
if ($input =~ m/^[Yy]/) {
|
if ($input =~ m/^[Yy]/) {
|
||||||
|
|
||||||
# Actually remove the files.
|
# Actually remove the files.
|
||||||
foreach $f (@pkg_files) {
|
foreach my $file (@pkg_files) {
|
||||||
if (system("sudo rm $f") == 0) {
|
if ( -e $file ) {
|
||||||
warn "Deleted $f\n";
|
if ( system( 'sudo', 'rm', $file ) == 0 ) {
|
||||||
} else {
|
warn "Deleted $file\n";
|
||||||
warn "Unable to delete $f: $!\n";
|
} else {
|
||||||
warn "Aborting uninstall.\n";
|
warn "Unable to delete $file: $?\n";
|
||||||
exit 1;
|
die "Aborting Uninstall.\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
warn "File $file does not exist. Skipping.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean up the install.
|
# Clean up the install.
|
||||||
if (system("sudo pkgutil --forget $pkg_id --volume '$volume'") != 0) {
|
if (system('sudo', 'pkgutil', '--forget', $pkg_id, '--volume', $volume) != 0) {
|
||||||
warn "Unable to clean up install: $!\n";
|
die "Unable to clean up install: $?\n";
|
||||||
exit 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
print "OK, aborting uninstall.\n";
|
print "OK, aborting uninstall.\n";
|
||||||
exit 0;
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "Pandoc has been successfully uninstalled.\n";
|
print "Pandoc has been successfully uninstalled.\n";
|
||||||
exit 0;
|
exit;
|
||||||
|
|
Loading…
Add table
Reference in a new issue