I am trying to build pdftk, which apparently requires gcj. Since it is not already in my path, I can either add the directory holding gcj to my path or define the path in the pre-made Makefile.
The problem is that I have no idea:
a) where gcj is, and b) whether it exists on the server at all (at least in such a way I can add to path).
This problem has come up more than once in my previous attempts to build binaries from source, so I'm hoping I can ask two questions at once to fix my current issue and avoid this issue in the future...
Is there a way to add EVERYTHING I have read/execute permission into my path? Sub-question, is this a bad idea?
Does
whereis
only search my path? Is there some equivalent for finding files/directories I need without having to search the ENTIRE host and getting access-denied for every other directory?Is there a way I can know for sure if a library/binary is definitely not available vs. just not in my path?
Is there a way to tell, specifically for
gcc
ifgcj
is available?Can I compile gcj to my user directory without having to compile all of gcc with it?
Is there a (universal) way, when building a binary, to flag the compile or make file to deal with any dependencies as it finds them rather than simply failing?
Does a typical user on a shared-host situation have the ability to use the OS package library to get packages at the user-level?
...it's a bad idea for security reasons.
You could use locate (or glocate available in findutils from OpenCSW) with the -r option which allows to use regular expressions:
glocate -r /gcj$
glocate can tell you that, assuming that
gupdatedb
has been recently run.The best way of going about it is to scan the installed packages. The list of installed files is in
/var/sadm/install/contents
.Haven't tried, but you would still need to go through a lot of hassle. It's probably best to grab an already available gcj binary. If you have to compile it yourself, then it's best to use existing build descriptions, such as this one.
I assume you're thinking of something along the lines of Gentoo's emerge, which downloads and installs the dependent packages before it compiles the one you wanted. It's not easily done; especially if you compile everything as a regular user, because you need then to use a chroot environment. It's a good idea, but not trivial to do.
What do you mean by get packages? If what you want is to extract the contents of a .pkg file, you can use the pkgtrans command, like this:
pkgtrans foo.pkg ./ all
However, there's also a possibility of doing something like pbuilder which creates a chroot environment, in which you do your compilation as well as package installations, all in the home directory.
Back to the gcj question, I think you need to specify the build time dependencies of your makefile and depend on a package that contains gcj, in a known path, and then you can use that path in your build description.
Generally, if you're in a shared hosting, compiling packages is going to be a pain, it's much better to find a system when you can install and remove packages, and write to /usr.
It's also a good idea to use some kind of a build framework, such as GAR, which does all the right things and removes lots of annoyances: it checks the build time dependencies, downloads tarballs, verified checksums, extracts, applies patches if any, configures, builds, installs, and makes a package, and you can specify everything in a single Makefile. Learning to use such a framework requires a bit of time, but if you tend to build packages yourself, the time spend on learning will pay off quickly.
Yes, it's a bad idea for security reasons. A malicious script or program, or a simple mistake could be a real problem.
whereis
searches the obvious places like/bin
,/usr/bin
and others. See the man page FILES sectionYou can use
locate
if it's available orfind
otherwise:or
1: Nobody does that -> bad idea.
2 + 3: The sure way is:
4: Don't know.
5: Probably, and it is obviously a lot of manual work.
6: No. In Makefile, you can just append to PATH any directories that usually hold gcj (your educated guess). This will not hurt anyone.
7: No, it is up to admin to install a package. But you don't need to be an admin to extract the files contained in the package to your home directory:
The software will rarely be usable after such substraction (bad ownership, bad path, bad library paths, bad config file paths, no installation script executed, no pre-requisites checked, ...). Such operation is also possible not only on Solaris, but on most other Unix/Linux flavors - using their packaging tools.