Home » Featured, How-to

Compiling slocate on Solaris 10

paan 25 March 2008 Featured, How-to 462 views One CommentPrint This Post Print This Post Email This Post Email This Post

The gnu secure locate utility or more commonly known as slocate is a very usefull utility to have. Not only does it index the drive so that seaches are done to a compressed database instead of the filesystem to speed it up, slocate also apply security restriction to searches so that you can only see the files you have access to.

slocate

I have grown fond of it from my ussage of slocate in linux. When working in Solaris 10, however, there was no slocate utility.Browsing through the Sun Freeeware site I was surprise to see that is it not among the available download. The alternative is to compile it from source. I will show you how.

Getting the packages

First thing to do is to get the source distributuion from the official slocate site. Get the version 2.7 distribution. Version 3 is a little better overall, a complete rewrite of the old codes and some fixes. But it doesn’t use the ./configure script for compilation but a hard coded Makefile so it’s a little cumbersome to (re)configure. So I figured we go with the 2.7 release. Here a  direct link to slocate v2.7 source.

slocate v2.7 also require automake-1.4. I had success with v1.4-p1 but I suppose any revision from v1.4-p1 untill v1.4-p6 will do. Get them all at the gnu automake ftp site.

Compile

Compilation of automake is very straight foward. After extracting everything, use the standard

  • ./configure
  • make
  • make check (optional)
  • make install

There is one caveat though, the configure script for slocate will look for automake-1.4 instead of the default automake. So rename it manually afterwords. Or alternatively you can use the –program-suffix=-1.4 argument for ./configure

Ok, now we can start compiling slocate.

Start by extracting the archive. And then

  • ./configure
  • make

There are a few things that you have to change maually in the Makefile before running the make install command. This because the different way the Solaris 10 handle the parameter of the “install” and “chmod” command as oppose to how linux handles them and also because of the subtle diffrence of the way both OS handles command line parameters (linux allows parameter after command arguments e.g. cp dir1 dir2 -R, Solaris doesn’t e.g. cp -r dir1 dir2).

These are my changes in diff format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
161,162c161,162
<           echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
<            $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
---
>           echo "  $(INSTALL_PROGRAM)  $(DESTDIR)$(bindir) $$p"; \
>            $(INSTALL_PROGRAM) $(DESTDIR)$(bindir) $$p ; \
393,395c393,396
<       $(INSTALL) -d $(DESTDIR)$(datadir)/slocate
<       chown root.slocate $(DESTDIR)$(bindir)/slocate
<       chown root.slocate $(DESTDIR)$(datadir)/slocate
---
> #     $(INSTALL) -d $(DESTDIR)$(datadir)/slocate
>       $(mkinstalldirs) $(DESTDIR)$(datadir)/slocate
>       chown root:slocate $(DESTDIR)$(bindir)/slocate
>       chown root:slocate $(DESTDIR)$(datadir)/slocate
404,405c405,409
<       $(INSTALL) -m 644 doc/slocate.1.linux.gz $(DESTDIR)$(mandir)/man1/slocate.1.gz
<       $(INSTALL) -m 644 doc/updatedb.1.gz $(DESTDIR)$(mandir)/man1/updatedb.1.gz
---
>       $(mkinstalldirs) $(DESTDIR)$(mandir)/man1/slocate.1.gz
>       $(mkinstalldirs) $(DESTDIR)$(mandir)/man1/updatedb.1.gz
>
>       $(INSTALL)  $(DESTDIR)$(mandir)/man1/slocate.1.gz -m 644 doc/slocate.1.linux.gz
>       $(INSTALL)  $(DESTDIR)$(mandir)/man1/updatedb.1.gz -m 644 doc/updatedb.1.gz

Your makefile might be generated a little differently but you can use this as a general guideline as to what to look for to change.

Finally, run

  • make install

And there you have it, you installation of slocate. run updatedb to update your database. Then run slocate $filename to seach for $filename effectively.

Updates

update: nick was working on the same issue on opensolaris and provide a simpler solution here. It involves using the autogen.sh script to bypass the autoconf-1.4 prerequisite. And uses cp in substitute for the install command.

Digg!
Rate this:
2.5

One Comment »

  1. [...] bit more googling finds me this article, which recommends installing slocate version 2.7 which comes with a configure script. So I tried, [...]

Have your say!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>