prepare a tar package

I have installed apache2 on Solaris machine with the binary. So i dont want to install the same binary across all the systems but only want to copy the lib files and the files which have been updated in this installation process.

So in order to get those lib files and then prepare a tar package it will be easier to extract this tar on all machines.

Can you please guide me on how to proceed further.

So in the installation process, i have run the below.

So if we go to /usr/local/apache2 you can see

Btw i dont want to copy any source files and i just want to make a tar package with the files involved with the installation (i.e) lib files and binaries.

Please assist.

Thanks

tar c tar_file_name.tar relative_path_to_executables relative_path_to_dynamic_libs/*.so relative_path_to_any_other_files_like_starter_config_or_info_or_doc_or_man

Thank you for the reply. an you guide me in gathering all of these required files. I mean the best procedure to gather the files and i dont want any files to be missing.

Thanks

Well, 'ldd -rsv' will tell you every library used by an executable, and 'strace' can tell you every file a running app opens (very educational). Usually, libraries go in a 'lib' dir and that dir is in the LD_LIBRARY_PATH, and executables, script or compiled, go in a 'bin' dir that is in the $PATH variable. Throwing everything in /bin and /lib is a bad practice. Directories /usr/local/bin and /usr/local/lib are popular, but it is ok to keep every app separate. If you create the desired relative path on the tar end, it will create the relative directories wherever untarred. You can write and include a little script to move them from the untar directory, if that feels more comfortable.

Packaging like an rpm is a bit past me, and I prefer simple archives. Compression is nice, too. New tar has that, or you can use zip, or gzip the tar (.tar.gz or .tgz).

So i need to go under /usr/local/apache2 and run the command ldd -rss for all the directories under /usr/local/apache2?

Can you briefly explain as i am new to unix?

---------- Post updated 09-25-12 at 11:20 AM ---------- Previous update was 09-24-12 at 04:09 PM ----------

If we want to copy only selected files as shown in the below eg how can we write the tar command? So as below there are several other directories that we need to tar up. Btw if i am installing for apache do i need to look for only apache dependencies or all the lib files under /usr/local/lib?

for each executable you need to trace all the libraries it uses and include those not already on the destination host. Locations can vary as long as they are in the ld() ENV variable dir:dir list (usually $LD_LIBRARY_PATH). This bit runs ldd -rsv on my hp-ux java an lists the libraries it uses.

$ find ... -type f | xargs -r file | sed -n '
    s/:.*executable dynamically linked.*//p
  ' | while read f
do
  ldd -rsv $f
done 2>&1 | sed -n '
    s/.*=>[ \t]*//p
  ' | sed '
    s/[^/]*\/\.\.\///g
  ' | sort -u
/home/myhome/myroot/usr/local/jre/lib/PA_RISC2.0/jli/libjli.sl
/usr/lib/libc.2
/usr/lib/libdld.2
/usr/lib/libpthread.1
 .
 .
 .
 .
$

Narrative: find all files in package trees that might be executable compiled objects, run file on them to find just executables dynamically linked (your file messages may vary), run ldd on each, capture libraries located, remove any parent dir zigzag references, e.g., "xxx/bin/../lib/libxxx.sl" and sort unique. Turn the '\t' into a real tab.

If you build your app in a dir with dirs under it like /usr/local// (bin,lib,man), you run itin place using PATH, LD_LIBRARY_PATH, MANPATH or copy your_dir/ into /usr/local/.