Install unix binary in applescript application package

Hi all,

I would like to create an applescript application that uses a unix binary called pdftotext. I believe pdftotext is installed as part of the Xpdf tools, I used macports to install it.

So is it possible to create an application and install the pdftotext binary and all of its dependencies in the applications resources folder?

I would like to create an app that I can use on multiple macs without having to install macports and then install Xpdf.

Thanks,
Nik

Hello

I guess this is the package you want then, and that you have rejected other alternatives, like Applescript/Skim, which is by far easier to get up and running on a combo of machines?

You could try to resemble the structure for what the tool needs within the resouce folder, and then set the path to that resources folder at the start of your do shell script. It may not work, but it is at least worht a try.

If it is so that the references to the resources within the package are hardcoded, then you’r out of luck. But there may be some documentation somewhere, (at least you have the portfile, and the maybe the source/build directories on your machine, then maybe there are some build documentation there, and maybe there are variables documented that you may use to override any hardcoded paths with.

But hopefully, any paths are relative, and you should succeed by just copying everything into the resources folder as I suggested first.

You really don’t know if it will work out before you have tried. :slight_smile:

And it will be most practical to run the commandline, with the resources folder as the working directory of a Terminal window, so that you can see the any errormessages that pops up.

Hi,

Thanks for the reply.

I have managed to copy the odd binary file into a package and reference that as the environment with some success before, but these have all been stand alone binaries that don’t have any dependencies.

Maybe another question would be, Is there a way to find out what dependencies a binary file uses?
If I find out what the dependencies are and if they where all located in say /usr/local/bin then hopefully, as you say I should be able to copy all of the required dependencies and the ‘pdftotext’ binary into my package.

I’ve seen some mention of the command ldd that returns what dependencies a binary file uses but this doesn’t seem to be a valid command on the mac! can anybody recommend a command that will tell me?

Thanks again,
Nik

Hello.

I think the easiest way is to shove the binaries into the resources folder, then launch a shell, totally without any profile, -extranous environment variables, and then set the path to just the resourcesfolder, and the try to simulate usage, like you would from a do shell script.

You should get error messages passing by quicker than deadlines then. :slight_smile:

If you really want to know what the full package consists of, then you should find a Portfile to read. locate Portfile

There’s a stand-alone version of pdftotext.

http://www.bluem.net/en/mac/packages/

Hi,

thanks Chris for the link. I think I’ll install the stand alone app and see if I can tell if it installs any other files. Maybe then I might be able to work out what I need copy into my package, if not I could always just use the installer and maybe install it on multiple machines using Remote Desktop.

Thanks a lot guys,
Nik

Hey Nik,

While this version worked fine as a stand-alone to export text, I had to install Ghostscript to export a complex document (-c).

Helo.

I want ot elaborate a little further on how to build it yourself, That XtoPDF package, and ghost script.

When you read the portfile, then you’ll download the packages yourself, and unzip them into source trees.

Then you can specify new destroot variables, for simulating another bin directory when doing an install. ( I think you must create the directory, and your destroot, will be one level above the bin directory, ala /usr or /opt.)

If you have developert tools installed, then you can change some directories, by specifying them when running the confiugre script, that you should be able to execute from the root of the unzipped source trees. It is enough if one of the packages supports configure ”help, since the variable names, and conventions are the same.

The usual sequence of commands is

configure ”help

configure (with your settings )

make install

You have what you need of compilers, and such already since you have installed macports packages.

This is the usual way to do this, maybe it is smart to start with a smaller “guinea-pig” package, to see that you got everything right. There are also some pages about “autotools” out there on the net, -which is what is primarily used for building such packages, but they may also have been built with cmake.

First of all, I’d look around for the log file for the installation, which should be inside the port-tree somewhere, and see what files have been installed, which dependencies, and if you can figure that out, do a search and replace in a copy of the log file, and create a copy script, that dumps all you need into a “bin” folder you can drag into your applet.

Hi McUsr,

I need to do something similar. Would you demonstrate this method with jpegoptim http://www.kokkonen.net/tjko/projects.html. It requires both jpegoptim and the jpeg library to be installed. However, if you simply drag them into the app’s contents, jpegoptim does not locate jpeg because it is looking for it in the default install location.

Thanks

Hello.

You’ll find some good videos on Autotools on youtube, and some written tutorials as well, stuff like this takes a little bit more than 5 minutes to fix. I’ll advice you to read up on autotools, try, and then contact the developers, if you can’t figure it out.

Autotools: a practitioner’s guide to Autoconf, Automake and Libtool

Autoconf, Automake, and Libtool: Table of Contents

The variables you are really after to set is destdir, you’ll most probably set that variable with something like:

configure ”DESTROOT=/pathto the folder above where it will be installed

I think you’ll end up finding the stuff in a bin folder below that folder.

One circumvention, could be to install the stuff on a dmg image, and the mount the image, if you can’t make relative paths work at all.

I edited the variable name of the previous post. (from ”destdir to --DESTROOT

Usually you can get some hints with ./configure ”help
for which variables, the configure script supports.

Hello.

It may also be more than this, than mere installing, because libraries may be installed in the appropriate library folder after all, no matter where the executable binaries goes. And then you’ll have to provide environment variables for telling dyld (the dynamic linker for where you have put those libraries.) (It might be advantageous to specify statical linking, if you can that via the configure script.

I’m sorry that I can’t help you more than that at the moment, adyazdone, but I am in the middle of something. :slight_smile:

Hello.

I may be wrong, but I seem to recollect, that there are tools within macports, that you can download, or some other means by what you have already installed, to make standalone binary installers of a package. I don’t know if you then would have to make separate binary installers for the dependencies, or if it (port) will take care of that for you, but it is at least worth looking into.

When facing trouble, with access to source-code, then you can grep for “getenv” and any hardcoded paths, even try to understand the config.h file.