summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xosx/make_osx_package.sh (renamed from make_osx_package.sh)1
-rwxr-xr-xosx/osx-resources/InstallationCheck (renamed from osx-resources/InstallationCheck)0
-rw-r--r--osx/osx-resources/InstallationCheck.strings (renamed from osx-resources/InstallationCheck.strings)0
-rwxr-xr-xosx/uninstall-pandoc.pl81
4 files changed, 82 insertions, 0 deletions
diff --git a/make_osx_package.sh b/osx/make_osx_package.sh
index 3119f140e..c28f8fe5f 100755
--- a/make_osx_package.sh
+++ b/osx/make_osx_package.sh
@@ -39,6 +39,7 @@ for f in $EXES; do
cp $SANDBOX/share/man/man1/$f.1 $DEST/share/man/man1/
done
cp $SANDBOX/share/man/man5/pandoc_markdown.5 $DEST/share/man/man5/
+cp $SCRIPTS/uninstall-pandoc.pl $DEST/bin/
chown -R $ME:staff $DIST
# gzip $DEST/share/man/man?/*.*
diff --git a/osx-resources/InstallationCheck b/osx/osx-resources/InstallationCheck
index 2bd691f5c..2bd691f5c 100755
--- a/osx-resources/InstallationCheck
+++ b/osx/osx-resources/InstallationCheck
diff --git a/osx-resources/InstallationCheck.strings b/osx/osx-resources/InstallationCheck.strings
index 6c8efe0d4..6c8efe0d4 100644
--- a/osx-resources/InstallationCheck.strings
+++ b/osx/osx-resources/InstallationCheck.strings
diff --git a/osx/uninstall-pandoc.pl b/osx/uninstall-pandoc.pl
new file mode 100755
index 000000000..292bcfd96
--- /dev/null
+++ b/osx/uninstall-pandoc.pl
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+
+# Script to remove all files installed by the OSX pandoc installer
+# and unregister the package. Modified from a script contributed
+# by Daniel T. Staal.
+
+use warnings;
+use strict;
+
+use File::Spec;
+
+# The main info: this is the list of files to remove and the pkg_id.
+my $pkg_id = 'net.johnmacfarlane.pandoc';
+
+my @pkg_info;
+
+# Find which, if any, volume Pandoc is installed on.
+my $volume;
+
+# First check /, then other volumes on the box.
+my $cur_test = `pkgutil --pkgs=$pkg_id`;
+if ( $cur_test =~ m/$pkg_id/ ) {
+ $volume = '/';
+} else {
+ opendir( my $dh, '/Volumes' ) or die "Can't list Volumes: $!\n";
+ foreach my $dir ( readdir($dh) ) {
+ next if $dir =~ m/^\./; # Skip dotfiles.
+
+ my $path = File::Spec->rel2abs( $dir, '/Volumes' );
+ next if !( -d $path ); # Skip anything that isn't a directory.
+
+ my $cur_test = `pkgutil --pkgs=$pkg_id --volume '$path'`;
+ if ( $cur_test =~ m/$pkg_id/ ) {
+ $volume = $path;
+ last;
+ }
+ }
+}
+
+die "Pandoc not installed.\n" if !( defined($volume) );
+
+my @pkg_files = ();
+my $f;
+for $f (split '\n', `pkgutil --volume '$volume' --only-files --files $pkg_id`) {
+ push @pkg_files, File::Spec->rel2abs($f, $volume);
+};
+
+print "The following files will be deleted:\n\n";
+print join("\n", @pkg_files);
+print "\n\n";
+print "Do you want to proceed and uninstall pandoc (Y/N)?";
+my $input = <STDIN>;
+
+if ($input =~ m/^[Yy]/) {
+
+ # Actually remove the files.
+ foreach $f (@pkg_files) {
+ if (system("sudo rm $f") == 0) {
+ warn "Deleted $f\n";
+ } else {
+ warn "Unable to delete $f: $!\n";
+ warn "Aborting uninstall.\n";
+ exit 1;
+ }
+ }
+
+ # Clean up the install.
+ if (system("sudo pkgutil --forget $pkg_id --volume '$volume'") != 0) {
+ warn "Unable to clean up install: $!\n";
+ exit 1;
+ }
+
+} else {
+
+ print "OK, aborting uninstall.\n";
+ exit 0;
+
+}
+
+print "Pandoc has been successfully uninstalled.\n";
+exit 0;