LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2012, 04:17 AM   #1
jmenew
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Rep: Reputation: Disabled
Smile compile and installation of .tar.bz2/.tar.gz files


hii....frndzz
tell me how to compile and install .tar.bz2/.tar.gz files in fedora12 using terminal and also specify that there is any specific directory for these files to be placed in before compilation...
thanxx...
 
Old 08-09-2012, 04:34 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

it changes case to case. Generally you have two choices, /opt or /usr/local. /opt is normally used if the package will be "self contained": ie everything for package foo goes in /opt/foo. /usr/local is used when the intalled package respects the FHS eg. libs go in /usr/local/lib, executables in /usr/local/bin, man pages in /usr/local/man etc. If using /usr/local, you can put the source and do the build in /usr/local/src/foo.

The compilation and installation will vary too. Many packages use autotools, in which case you would use the ./configure, make, make isntall procedure. Some use cmake, which has a slightly different procedure, and there are others too. Most packages should contain an INSTALL and/or README file that should provide more information. Failing that look for documentation on the web site associated with the package/program.

Evo2.
 
1 members found this post helpful.
Old 08-09-2012, 04:37 AM   #3
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
Quote:
Originally Posted by evo2 View Post
it changes case to case. Generally you have two choices, /opt or /usr/local. /opt is normally used if the package will be "self contained": ie everything for package foo goes in /opt/foo. /usr/local is used when the intalled package respects the FHS eg. libs go in /usr/local/lib, executables in /usr/local/bin, man pages in /usr/local/man etc. If using /usr/local, you can put the source and do the build in /usr/local/src/foo.
I believe he was asking were to put the tarballs prior to compilation, not the usual prefixes of the install phase
To the OP: you can put tarballs wherever you want, as long as you can find them later on...
 
Old 08-09-2012, 07:08 AM   #4
RealiX
LQ Newbie
 
Registered: Aug 2012
Location: Italy
Distribution: Slackware64 13.37
Posts: 5

Rep: Reputation: Disabled
It's important, before compiling, to type ./configure --help to read the particularly compilation options of your source code. To keep order on my System, I put and extract the tarball in a directory of my home called src.

Last edited by RealiX; 08-09-2012 at 07:16 AM.
 
Old 08-09-2012, 07:38 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
jm*;

Please post follow-up in your other thread (and in this one)
 
Old 08-09-2012, 10:32 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Quote:
Originally Posted by 414N View Post
I believe he was asking were to put the tarballs prior to compilation, not the usual prefixes of the install phase
I answered that. The information about where to install is relevant in deciding where to build the source.

Evo2.
 
Old 08-10-2012, 05:54 AM   #7
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
Quote:
Originally Posted by evo2 View Post
I answered that. The information about where to install is relevant in deciding where to build the source.
Evo2.
I humbly disagree on this, the main reason being that for accessing those locations (/usr/local and /opt) one would need root privileges to copy/download the tarball, extract it and compile the sources contained.
All of those actions could be done as an unprivileged user inside a non-root-owned directory (such as a subdirectory under its $HOME) and, ultimately, perform only the install (or uninstall) phase as root.
 
1 members found this post helpful.
Old 08-13-2012, 05:36 PM   #8
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

Quote:
Originally Posted by 414N View Post
I humbly disagree on this, the main reason being that for accessing those locations (/usr/local and /opt) one would need root privileges to copy/download the tarball, extract it and compile the sources contained.
This is why I have /usr/local/src and /opt group owned and writeable by src and admin groups respectively.

Alternatively you can always just start at quick root session to mkdir and chown/chmod before doing the unpacking and compiling.
I never compile as root.

Evo2.
 
Old 08-13-2012, 07:47 PM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,825

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
slight PROBLEM
fedora dose NOT use the /usr/local folder
it is NOT in the system $PATH by default
the OP would have to add that location

fedora dose not use it !

as to /opt
???
back in fedora 12 ??? it might or might NOT be in the path
kde3 NOW uses it along with Openoffice
BUT
back in fedora 12 ?? that is an unknown

that location also might need to be added

but
Quote:
tell me how to compile and install .tar.bz2/.tar.gz files in fedora12 using terminal and also specify that there is any specific directory for these files to be placed in before compilation..
this sounds a lot like a homework question
a reworded one ... but


EVERY tarbal IS DIFFERENT
some are prebuilt binaries like firefox
others use GNU auto tools
others use scons
others use cmake
others use qmake ( program.pro file )

so this question AS STATED can not be answered
 
Old 08-13-2012, 07:53 PM   #10
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

Quote:
Originally Posted by John VV View Post
slight PROBLEM
fedora dose NOT use the /usr/local folder
it is NOT in the system $PATH by default
the OP would have to add that location
I didn't know that, but there is no reason it can't be added.

Quote:
as to /opt
???
back in fedora 12 ??? it might or might NOT be in the path
Stuff in /opt always(?) needs needs to be explicitly added to the users
path since the executables and libraries sit in the their own subdirectory.
Quote:
this sounds a lot like a homework question
a reworded one ... but
You could be right here.

OP: do you have a question about a specific tar ball?

Evo2.
 
Old 08-15-2012, 02:53 PM   #11
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by John VV View Post
slight PROBLEM
fedora dose NOT use the /usr/local folder
it is NOT in the system $PATH by default
the OP would have to add that location

fedora dose not use it !
That does not appear to be true. I just fired up a Fedora 17 LiveCD and /usr/local/bin is in the $PATH just like it is on all other distros.

EDIT: I went ahead and installed Fedora 17 in a VM and /usr/local/bin is still in the $PATH. As far as I can tell all distros that comply with FHS (Filesystem Hierarchy Standard) have /usr/local/bin as FHS 2.3 (the current version as I write this) dictates that it must be present and when used it will contain binaries. Hence it would actually be quite surprising if a distro did not have /usr/local/bin in their $PATH by default since the directory should be present and since it may contain binaries there is little reason not to add it to the $PATH. Additionally it would be rather stupid anyway as the majority of source packages attempt to install binaries here by default (unless you specify different configure options). Thus not having it would only serve to make things more difficult for those who need to compile some software from source.

Last edited by ruario; 08-16-2012 at 09:35 AM.
 
1 members found this post helpful.
Old 08-16-2012, 03:41 AM   #12
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by jmenew View Post
tell me how to compile and install .tar.bz2/.tar.gz files in fedora12 using terminal and also specify that there is any specific directory for these files to be placed in before compilation...
thanxx...
The majority of source packages will include a README and/or INSTALL file. Read these for instructions on how to compile a given package. If they are not present check the website of the author, or worst case contact him/her.

Before compilation, it doesn't really matter where you unpack. I often do it in /tmp but I don't believe there is any hard and fast right or wrong. After compilation however you may wish to move the extracted directory into /usr/src. The Filesystem Hierarchy Standard states that this is an optional directory to be used to store source for reference purposes. It can be worth storing it after compilation for a number of reasons: not all install procedures install the associated documentation files, in those cases you will find any documentation here; if you are capable you may gather a better understanding of how a program works by reading its source; if you need to reinstall (perhaps with different compile options) you will already have the code to hand; and finally it makes uninstalling the software easier since many programs support the "make uninstall" target and even when they don't you can inspect the Makefile, install script or installation instructions to help you work out how to remove the program manually.

Last edited by ruario; 08-16-2012 at 09:37 AM. Reason: added another reason for saving the source
 
Old 08-16-2012, 04:00 AM   #13
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Quote:
Originally Posted by evo2 View Post
This is why I have /usr/local/src and /opt group owned and writeable by src and admin groups respectively.
F.Y.I. FHS 2.3 does not list /usr/local/src as a directory, only /usr/src. Hence I would use /usr/src rather than /usr/local/src for storing source code after compiling and installing it.

Also a further note that may be relevant to the OP, the FHS also notes:

Quote:
Generally, source should not be built within this hierarchy.
So, whilst you may wish to move your source there once you are done compiling and installing, don't extract and build it there first. This makes some logical sense as most people compile software as a regular user and only install as root. Since /usr/src is likely to be root owned, you wouldn't be able to extract the tar.{gz,bz2,xz} there in the first place anyway when using your regular user account.

P.S. When you are finished compiling and installing your software you may wish to issue the following within the extracted source package directory before moving it into /usr/src.

Code:
chown -R root:root .
 
Old 08-16-2012, 04:57 AM   #14
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Here is an extra tip to make uninstalling software compiled from source a little easier.

After switching to root to begin installing (but before issuing the actually install command) run the following:

Code:
find /etc /opt /usr ! -type d -print > dir_list_before_install
This will create a listing of all the files (including symlinks) currently present in within /etc /opt /usr (including subdirectories like /usr/local). These are the most likely directories where the program will install new files (add further top level directories if you like, e.g. /bin).

Next run the install command, in many cases that will be:

Code:
make install
(Note: Refer to the README/INSTALL file or authors website to confirm the actual install command)

Next repeat the find command, this time outputting to a different file:

Code:
find /etc /opt /usr ! -type d -print > dir_list_after_install
Now with diff and a bit of cleanup via sed you can create a log of all newly installed files, like so:

Code:
diff dir_list_before_install dir_list_after_install | sed -n 's/^> //p' > application-name_install.log
You should then inspect application-name_install.log in a text editor to satisfy yourself that it only lists files associated with the program you just installed. It is possible that if you had some other software installation process running in the background (e.g. your distro's native update mechanism), then some extra, unrelated files could have been included in the log. If you see anything listed that you know shouldn't be there, remove it from log manually and save the file (you can keep it within the extracted application source directory you store in within /usr/src/).

Later if you need to remove the software and no adequate uninstall method is provided, you can use the application-name_install.log to do the uninstall, e.g. as root cd into the directory where application-name_install.log is stored and issue:

Code:
cat application-name_install.log | xargs -d'\n' -n1 rm -v
(Tip: Even if an uninstall method is provided and you decide to use that, you can still use the log to confirm that everything was actually removed.)

Before removing you might want to backup the software for potential reinstall later, like so:
Code:
cat application-name_install.log | tar cvaPf application-name_backup.tar.bz2 -T-
You can then reinstall (without having to compile again) via:
Code:
tar xvPf application-name_backup.tar.bz2
You can also use a "package" like this to copy the software to another similarly configured (same distro, distro version, arch) machine. This saves you from having to compile again.

Some extra points on this method. You will note that I only log files (including symlinks) that are created, not directories. This is done for several reasons. It keeps the logs less bloated, it allows for simple "one liner" uninstall commands like the one above and finally most directories end up being shared among many packages, making it trickier to work out which to remove. Furthermore for the most part empty directories have little effect on your system and are safe to simply ignore. If it ever bothers you you can always construct a find command using the "-empty" option to track down old empty directories that you might want to consider removing or manually inspect the parent directories of the files within your application-name_install.log. To remove a directory structure that only contains several empty nested directories read up on the '-p' option in the rmdir man page or look for examples online. The other problem with this method is it only tracks new files, not altered files. Usually this is not a problem but it could be with more complex applications, so this is worth bearing in mind. Personally, I don't think this is a reason not to log the install as it is always better than nothing.

For a more comprehensive solution to tracking source code installations, a number of great tools are readily available e.g. paco, src2pkg, checkinstall, slacktrack, etc. Read up on them and see which one best suites your workflow. Better yet, read the documentation provided by your distro on creating native packages. This will take more effort initially but allows you to use native tools not only to install and remove but also to run query commands against the contents of the packages you create.

Last edited by ruario; 08-16-2012 at 06:38 AM. Reason: changed one instance of install to uninstall and added a comma; added comments on how to backup locally compiled software
 
Old 01-04-2013, 03:53 AM   #15
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,175

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
deleted, posted in the wrong location, sorry for the bump

Last edited by ruario; 01-04-2013 at 03:54 AM. Reason: posted in the wrong location, sorry for the bump
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile firefox.tar.bz2 into RPM rexus Linux - Software 4 04-16-2010 05:54 PM
[SOLVED] Regarding installation of .tar.bz2 files mohitdaksh Linux - Newbie 12 10-04-2009 08:18 AM
.tar.gz and .tar.bz2 software installation thriver1 Linux - Software 2 03-27-2007 01:11 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM
how to compile a file of .tar.bz2 zameer_india Linux - Software 7 12-21-2004 01:15 AM


All times are GMT -5. The time now is 10:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration