3# Script to remove all files installed by the macOS pandoc installer
4# and unregister the package. Modified from a script contributed
12# The main info: this is the list of files to remove and the pkg_id.
13my $pkg_id = 'net.johnmacfarlane.pandoc';
15# Find which, if any, volume Pandoc is installed on.
18# First check /, then other volumes on the box.
19my $cur_test = `pkgutil --pkgs=$pkg_id`;
20if ( $cur_test =~ m/$pkg_id/ ) {
23 opendir( my $dh, '/Volumes' ) or die "Can't list Volumes: $!\n";
24 foreach my $dir ( readdir($dh) ) {
25 next if $dir =~ m/^\./; # Skip dotfiles.
27 my $path = File::Spec->rel2abs( $dir, '/Volumes' );
28 next if !( -d $path ); # Skip anything that isn't a directory.
30 my $cur_test = `pkgutil --pkgs=$pkg_id --volume '$path'`;
31 if ( $cur_test =~ m/$pkg_id/ ) {
38die "Pandoc not installed.\n" if !( defined($volume) );
40# Get the list of files to remove.
41my @pkg_files = `pkgutil --volume '$volume' --only-files --files '$pkg_id'`;
42@pkg_files = map { chomp; File::Spec->rel2abs($_, $volume) } @pkg_files;
44# Confirm uninistall with the user.
45print "The following files will be deleted:\n\n";
46print join("\n", @pkg_files);
48print "Do you want to proceed and uninstall pandoc (Y/N)?";
51if ($input =~ m/^[Yy]/) {
53 # Actually remove the files.
54 foreach my $file (@pkg_files) {
56 if ( system( 'sudo', 'rm', $file ) == 0 ) {
57 warn "Deleted $file\n";
59 warn "Unable to delete $file: $?\n";
60 die "Aborting Uninstall.\n";
63 warn "File $file does not exist. Skipping.\n";
67 # Clean up the install.
68 if (system('sudo', 'pkgutil', '--forget', $pkg_id, '--volume', $volume) != 0) {
69 die "Unable to clean up install: $?\n";
74 print "OK, aborting uninstall.\n";
78print "Pandoc has been successfully uninstalled.\n";
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list