LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Building Binary LFS (https://www.linuxquestions.org/questions/linux-from-scratch-13/building-binary-lfs-280487/)

Tuvok 01-21-2005 08:31 AM

Building Binary LFS
 
I have searched LQ any thread/post relating to what I am inquiring about, but couldn't find. If there're any such thread/post, let me know.

OK, what I am thinking about is building the LFS packages (gcc, glibc, binutils and etc) in binary format (like Slackware's .tgz) and install (untar) it on a partition. Is this possible?

320mb 01-21-2005 11:14 AM

I would just build the base LFS system and then install
the need programs for .tgz package management..........
this is the easiest way........

jong357 01-22-2005 01:14 AM

Yes, you can. I just finished with the 6.0 book using makepkg the whole way through. It's VERY slick. Made a hint of sorts to submit to the LFS hints. The only one they have concerning Slackwares pkgtools is ancient. Needs some final tweaking/formating but for the most part, it's done. I guess I'll post it here for now. As long as you download all the required packages listed below into /sources/pkgtool, you can copy/paste all the commands. I went thru it a few times just to make sure you could copy/paste or make a script from the commands.


Using the latest Slackware pkgtool with LFS 6.0:

I got pkgtools up and running imediately after Chapter 6, Populating /dev. I wanted every single package on my system to be documented under the pkgtool list. That means I used the command of "make install DESTDIR=/tmp/packagename" and then did a "makepkg packagename.tgz" and finally an "installpkg packagename.tgz" for every package. Very time consuming but well worth the effort. :-) A few packages won't conform to the DESTDIR switch but can be dealt with one way or another. eg - make install prefix=/tmp/packagename, or as a last result for the 2 or 3 packages that flat out refuse to install elsewhere, edit the make file or do a pre-run with ./configure --prefix=/tmp/test; make; make install. Then do a "make clean" and build/install normally, then hand move everything to a build directory. Make sure everything gets placed where it should be. Like I say, Theres only really 2 packages that do this. Not a big deal really.


All these instructions assume that you will be making a pkgtool binary out of the source code below. It's the easiest way to work it right now. And if you want to build another system, you'll have all the work done already with pkgtools.

First download all of the following items into /sources/pkgtool.

-----------
ftp://ftp.slackware.com/pub/slackwar...ce/a/pkgtools/

explodepkg.8
installpkg.8
makepkg.8
pkgtool.8
removepkg.8
upgradepkg.8
slack-desc
_pkgtools.tar.gz
dialog-0.9b-20031207.tar.gz
dialog.textbox.noarrows.diff.gz

ftp://ftp.slackware.com/pub/slackwar.../source/a/tar/

tar-1.13.tar.gz
bzip2-tar.diff.gz
-----------

What better explanation than the commands themselves? I removed a few things from the package such as xwmconfig and makebootdisk.
Code:

mkdir -p /sources/pkgtool-build
cd /sources/pkgtool-build
tar -xzvf ../pkgtool/_pkgtools.tar.gz
rm -rf etc/*
rm -rf var/
rm -rf usr/{X11R6,bin,lib}
rm -rf sbin/makebootdisk

* Use a text editor to open install/doinst.sh. Remove the first 8 lines. Now edit the second line so it reads "( cd usr/lib ; ln -sf ../share/terminfo terminfo )". Save and then remove any backup ~ that might have been left behind. Alternatively, the following sed commands will acomplish the same thing. Thanks shudde!
Code:

sed -i '1,8d' install/doinst.sh
sed -i 's@/usr/share@../share@g' install/doinst.sh

Now take the oportunity to edit any/all of the scripts in sbin. I spent (more than) a few minutes editing these scripts to suit my own needs. For instance, in pkgtool, I removed the main menu options of:

"Floppy" "Install packages from floppy disks" \
"Setup" "Choose Slackware installation scripts to run again" \

You can also remove the associated:

if [ "$REPLY" = "<REMOVEDOPTION>" ]; then
blah
blah
exit
fi

parts from the script as well. It won't do any harm leaving it there though. If you want to, you can also change the main title to say something other than "Slackware Package Tool (pkgtool version 10.0)". Since everything is entirely composed of scripts, you can edit to your hearts content with relative ease.

I also changed the file "slack-desc" to "desc" as you'll notice later on. Doing that means that you need to do a find/replace in all of the sbin scripts to match. You will also need to edit the very bottom of "installpkg". Where it says "slack-*", put in "desc". There are 2 places where it needs to be changed. I purposefully tried to break compatability as much as possible with the original pkgtools. I also just didn't like the descriptions being named "slack-desc" if they are going to be used on this system.*
Code:

cp ../pkgtool/*.8 usr/man/man8/
gzip -9 usr/man/man8/*
cp ../pkgtool/slack-desc install/desc
cd ../pkgtool
tar -xzvf dialog-0.9b-20031207.tar.gz
cd dialog-0.9b-20031207
find . -perm 444 -exec chmod 644 {} \;
chown -R root.root .
zcat ../dialog.textbox.noarrows.diff.gz | patch -p1
./configure \
  --prefix=/usr \
  --enable-nls
make
cat dialog > ../../pkgtool-build/bin/dialog
cat dialog.1 | gzip -9 > ../../pkgtool-build/usr/man/man1/dialog.1.gz
cat samples/slackware.rc > ../../pkgtool-build/etc/dialogrc

* The dialogrc defines the color set that is used for pkgtool. See the very bottom NOTE: at the end of this file *
Code:

cd po
make
make install DESTDIR=/sources/pkgtool-build/
cd ../../

* Apparently, tar-1.14 can't handle symlinks very well with pkgtools. We need to build and install just the binary from tar-1.13 for use with pkgtools. pkgtool and all associated scripts are hard coded to look for a file called "tar-1.13". This will keep it isolated and thus will only be used by pkgtool. *
Code:

tar -xzvf tar-1.13.tar.gz
cd tar-1.13
zcat ../bzip2-tar.diff.gz | patch -p1 --verbose
chown -R root.root .
./configure \
  --prefix=/usr \
  --bindir=/bin \
  --disable-nls
make
mkdir -p ../tmp
make install DESTDIR=/sources/pkgtool/tmp
cd ../
mv tmp/bin/tar ../pkgtool-build/bin/tar-1.13
chmod 755 ../pkgtool-build/bin/tar-1.13

* We need mktemp now if we are going to be building binaries with makepkg. If your not going to be building binaries for all of chapter 6, it kind of defeats the purpose in doing this now. This will also be a temporary mktemp seeing as how we are building it again in just a little bit, so we won't build it "proper". We wont include this mktemp in the pkgtool binary since it will be a seperate package. We will move it to /tools/bin after installing because this is a package that chokes on DESTDIR. Luckily, it only installs 2 things. *
Code:

tar -xjvf ../mktemp-1.5.tar.bz2
cd mktemp-1.5
./configure --prefix=/usr
make
make install
rm -rf /usr/man/man1/mktemp.1
mv /usr/bin/mktemp /tools/bin/mktemp

* Now, lets make our pkgtool binary package by hand since we don't have pkgtools installed yet. Make sure you replace "arch" with whatever arch you compiled it for. *
Code:

cd /sources/pkgtool-build
tar cvf pkgtools-10.0-arch-1.tar *
gzip -9 pkgtools-10.0-arch-1.tar
mv pkgtools-10.0-arch-1.tar.gz /sources/pkgtools-10.0-arch-1.tgz
cd /
tar -xzvf /sources/pkgtools-10.0-arch-1.tgz
rm -rf install
installpkg /sources/pkgtools-10.0-arch-1.tgz

* That's it. Now pkgtools is installed. We untared it first in our / Directory to get the files in place so it would work. Then we installed it through pkgtools so it would be cataloged and also to execute the install script to create it's symlinks. Just don't uninstall it. pkgtool doesn't like trying to remove itself while running :-)

If your done with the /sources/{pkgtool,pkgtool-build} directories, you can go ahead and delete them.

I use this script right before I run "makepkg" on all my binaries. *
Code:

#!/bin/sh
#
# This script is used for the final stage of
# preparing the binary package, right before
# a "makepkg" is issued. Don't put this in your
# PATH as there is another file called 'strip'.
##################################################

# Let's strip the libraries and binaries
/tools/bin/find /tmp/build/{,usr/}{bin,lib,sbin} -type f \
  -exec /tools/bin/strip --strip-debug '{}' ';'

# Now compress the man pages
/tools/bin/gzip -f -9 /tmp/build/usr/man/man?/*

# For the shadow package, use this line along with the above
#/tools/bin/gzip -f -9 /tmp/build/usr/man/*?/*?/*

Note the man directory as being /usr/man. When I created my base directory structure in 6.5 of the book, I changed quite a few things. It's pretty much a Slackware layout. /usr/share/man is a symlink to /usr/man. So, before I issue a makepkg, I make sure the man pages are in /usr/man and not /usr/share/man. There are about 3-4 packages in the LFS book that still install the man pages to /usr/share/man/man?
-----------

NOTE: For some reason yet unexplained, tar-1.13 was hardcoded to something in my toolchain. Once I removed /tools and tried to use "makepkg", my tar-1.13 binary broke, giving me the pkgtools error of having a tar greater than 1.13, because it could now only use tar-1.14.... I re-did ALL of the above steps except for mktemp after removing the /tools directory and all is well now... :-( The colors for package tools now work as expected too.... I plan on looking into it.

1-28-2005
*Edited mktemp install location*
*Added SED command*
*Shortened the cp man command*

__J 01-22-2005 05:34 AM

I used checkinstall, IMO much easier ( make sure you have either the which script in the BLFS book or the which program itself and mktemp).

jong357 01-22-2005 10:18 AM

Yea, I'm not a big fan of checkinstall. I used it for a year or so tho. It always louses up the doinst.sh's symlinks and then corrupts your hostname. Pretty much renders your entire system useless until you reboot. Even when chrooted in LFS, it will affect your host. Pat's checkinstall usually doesn't do that but it did this time around with LFS. Extremely buggy program IMO. I'd rather make em by hand so I know everything is correct. You could try it tho and see if you have any luck with it. It will make the whole process easier for sure as long as it decides it wants to actually work as advertised. Pat even makes mention of it needing quite a bit of work and I tend to agree with him... ;)

__J 01-22-2005 10:56 PM

I used it with LFS 6.0 and it worked pretty well. it did botch some symlinks, making them in the root directory for some reason, but it must have made the correct ones also cause i never had to manually create one. But I agree with you, it may be easier IMO, but a little on the buggy side also.

shudde 01-28-2005 07:57 AM

slack pkgtools
 
Jong, I'm in the process of implementing your pkgtools hint. Just a couple of suggestions:

- Since the editing of "install/doinst.sh" is a necessary change (not just a cosmetic one like the menu options and title) maybe sed instructions would be more appropriate? Same logic could apply to the slack-desc reference I guess.

sed -i '1,8d' install/doinst.sh
sed -i 's@/usr/share@../share@g' install/doinst.sh

- After the mktemp installation into /tools/usr/bin should "export PATH=$PATH:/tools/usr/bin" be added? Unless I've missed something it's not a default path upon entering the chroot in chapter 6. Alternatively sedding the references in the pkgtools scripts to properly reference the location of mktemp?

- Regarding the strip script, it refers to /tmp/build for stripping. I've changed it to /tmp/$1 since from what I understand you build each package in a specific directory (ie. /tmp/linux-libc-headers-2.6.8.1-i686).

Anyway I'm having fun playing with the pkgtools scripts atm & look forward to seeing your hint on the lfs site, thanks for getting me started.

jong357 01-28-2005 08:51 PM

Thats a good idea with the sed command. Thanks for bringing it up. I don't know if everyone would want to change their 'slack-desc' to 'desc' tho.... Personally, I don't see why you would want to leave it as slack-desc... ;) I will implement sed in the hint. Thanks again.

As for the install path of our pkgtools mktemp, it should be /tools/bin.... 6.3. Entering the Chroot Environment still has /tools/bin at the very end of our $PATH.... Thanks again. Altho, I had no problems with mktemp being in /tools/usr/bin for sections 6.9 through 6.16... That makes me scratch my head a little. 6.17 is where we install mktemp for good which should render our temporary mktemp binary inactive. If we were to sed a new path into pkgtools, we would have to keep the /tools directory around forever... I don't know about you, but I can't wait to do a rm -rf on that bad boy at the end of Chapter 6...... Unless of course the sed command would just add a secondary location to look for the mktemp. I just wouldn't want any refrences to /tools at all in my pkgtool scripts.

You can change the 'strip' script to point to where ever you want for the build location. Actually, I used the same directory for every package. That being /tmp/build.... eg -
make install DESTDIR=/tmp/build

Obviously, you'll have to rm -rf /tmp/build/* AFTER you build your package and move your new binary some where for safe keeping. You need a fresh build directory for each package (for all the noobs out there :D )

Then I placed the script into /tmp. So then after I built the source code and the binary was ready, I'd just:
Code:

cd /tmp
sh strip
cd build
makepkg blah-1.2.3-i686-1.tgz
installpkg blah-1.2.3-i686-1.tgz

Something like that anyway... You could also name the script something unique, like 'godzilla', and then just drop it into /bin or something. That way you could just:
Code:

cd /tmp/build
godzilla
makepkg blah-1.2.3-i686-1.tgz
installpkg blah-1.2.3-i686-1.tgz

I did build EVERYTHING with "-march=i686 -pipe -O2" and I'm a good ways into BLFS... I was worried about Binutils, GCC and Glibc being i686 but she runs GREAT. This is my 3rd time building LFS and I haven't had this much fun with it previously. pkgtools really makes it nice. Actually, I think it's just the fact that your handling everything more this way, versus doing a COPY/PASTE type of thing from the book and then moving on to the next package. How boring is that? :rolleyes: Much, Much more interactive this way and I love Slackware SOOOOOOO much that it's hard to use anything else. This route kind of makes it a home away from home type of deal... I also looked at how Pat builds his code and incorporated some things if I thought it would benefit functionality in any way... Took me a couple weeks to do LFS this time versus the standard 2-3 days of just following the book.

I went thru the slackware FTP site and snagged all the "slack-desc" files that I needed. That way you already have those ready. Just rename them to desc (if you go that route) when your ready to place them into your install directory before you build the package. You do have to make a few of them by hand tho. I also edited ALOT of Pat's slack-desc files. It irks me that the descriptions in the parenthesis are cut off in pkgtool. Now when I browse my packages in pkgtool under the 'remove' option, you see the full package name and the full description, however short it may be.

ALSO: If your package contains any libs, don't forget to append

( /sbin/ldconfig )

to the end of your doinst.sh... What I did was to issue makepkg, say YES to removing the symlinks, say YES to making an instalation script and then I'd use gedit from my host to add that line really quick. Delete the ~backup and then jump back to my terminal to say NO to changing the permissions. Then it builds the binary. Then your library database gets updated with each package that contains libraries. I don't think Pat does this by default because he has ldconfig set to run at every boot. Thats my guess anyway. I rarely see him running ldconfig in his install scripts.

I'll try to finish up the hint and submit it soon. Needs some nice formatting and, as you have pointed out, some tweaking. I also really want to figure out why I had to rebuild and install pkgtools after I removed the /tools directory. I'd really like to know if you run into the same problem with the tar-1.13 binary breaking and the dialogrc file not being read as well.

Like I say, I rebuilt the package after removing the /tools directory and pkgtool works like a charm now. That bugs the hell out of me not knowing what happened there. Think I need to figure it out before I submit it to HINTS.

shudde 01-29-2005 04:06 AM

tar breakage
 
I encountered the same problem you did with tar breaking upon removal of the tools directory, currently trying again with...
...
export LDFLAGS="-static"
configure/make/makeinstall stuff
unset LDFLAGS
...
Might end up breaking something else but when I get to the end of chapter 6 (doing an optimized build atm) I'll edit this post to let you know how it went.
Forum posting in lynx is not fun.

jong357 01-29-2005 01:35 PM

Yea, you may be on to something there. Obviously, isn't finding any shared libs. If we configured for /usr, I'm not sure why it's trying to look in /tools anyway.... Thanks for taking an interest. I kind of put it on the back burner and have been tweaking out my bootscripts and installing packages from BLFS the past week. I'm at a good stopping point, and I still have my toolchain tarballed. I'll mess with it some as well.

Allthough, 6.12 is where we readjust our toolchain to point to /lib, /usr/lib and we built pkgtools in 6.8.....

Maybe you should try building pkgtools after your done with 6.12... Install 6.9 thru 6.11 as per the book but keep the source around so you can still make and install the binaries after 6.12.... Don't know. I just think I'm too far along to try and help you out on this one... I don't see how I can revert back to that state completely without starting over.... Don't think I have the patience for that....

You shouldn't have to wait till the end of Chapter 6. I assume you just did a 'mv /tools /blah' to see if tar would break or not? That might be the best way to do it right now if you want to track the problem down. Otherwise, you might be too far downstream like myself... Just thinking out loud...

jong357 03-20-2005 07:09 PM

Well, I think I've wrapped this up as much as I'm going to for now. I'll figure out the broken tar/dialogrc problem next time around. Here's my completed hint. I just went ahead and wrote it in script fashion. My old one was basically a script anyway...

Code:

#!/bin/sh
#
# Using Slackware pkgtools 10.0 with LFS 6.0:
#
# jgrosshart@gmail.com
#
# NOTE: The only thing you need to edit in this script is the
# ARCH variable on line 93. Adjust it accordingly to whatever
# personal/global CFLAGS you might have defined.
#
# I decided to write this hint in script fashion. If your interested
# in using pkgtools, you're probably already familiar with Slackware
# scripts. If you don't want to simpily 'sh' this script, extrapolating
# the necessary commands is easy enough.
#
# I got pkgtools up and running after 'Chapter 6.8 Populating /dev'.
# I wanted every single package on my system to be documented under
# the pkgtool list. It's probably worth mentioning right now that
# after I removed the /tools directory, pkgtools broke on me. The
# tar-1.13 binary will not work. The dialogrc file also isn't read from
# the get-go. I've had someone else mention that this happened to them
# as well. The only thing I can think of, is to install pkgtools after
# '6.12 Re-adjusting the Toolchain'. If you can come up with a diffinitive
# solution, please let me know and I'll update this hint. As it stands now,
# at the end of the LFS book, after you have removed the /tools directory,
# you'll have to re-build pkgtools. That will fix everything and pkgtools
# will work as expected.

# So, for all of Chapter 6, I used the command of
# "make install DESTDIR=/tmp/package", "cd /tmp/package",
# "makepkg packagename.tgz" and finally, an "installpkg packagename.tgz"
# for every package. Very time consuming but well worth the effort. :-)
# You'll also want to strip the libs/binaries and compress the man pages
# before you make the package. Thats covered later in this hint/script.
#
# VERY few packages won't conform to the DESTDIR switch but can be dealt
# with one way or another. eg - "make install prefix=/tmp/packagename",
# or edit the makefile. As a last resort, for the 2 or 3 packages that flat
# out refuse to install elsewhere, do a pre-run with
# "./configure --prefix=/tmp; make; make install". Look in /tmp
# and see what files it installed. Then do a "make clean" and install
# normally. Then hand move everything to a build directory. You can also
# just 'cat' directly out of the source tree. Make sure everything gets
# placed where it should be with the proper permissions. It may sound like
# a pain, but there are only 2-3 packages at most that do this for the
# entire LFS book. There is also the option of 'checkinstall' but I tend
# not to trust packages made by this program because of past expierences.

# First, you have to download all of the following items into $CWD.
# $CWD is the Current Working Directory, or the directory that this
# script will reside in. As per the books instructions, We'll have $CWD as
# /sources/pkgtool. So, make the directory /sources/pkgtool and download
# all of the below into it, including this script.

# ftp://ftp.slackware.com/pub/slackwar...ce/a/pkgtools/
#
# explodepkg.8
# installpkg.8
# makepkg.8
# pkgtool.8
# removepkg.8
# upgradepkg.8
# xwmconfig.1
# slack-desc
# _pkgtools.tar.gz
# dialog-0.9b-20031207.tar.gz
# dialog.textbox.noarrows.diff.gz

# ftp://ftp.slackware.com/pub/slackwar.../source/a/tar/
#
# tar-1.13.tar.gz
# bzip2-tar.diff.gz

# ftp://ftp.mktemp.org/pub/mktemp/
#
# mktemp-1.5.tar.gz

# http://www.angelfire.com/linux/madpenguin1/pkgtools.htm
#
# pkgtools-10.0-lfs-1.patch

#########################
# Lets start the script #
#########################

# Theres no need to re-invent the wheel. Most of this stuff
# is taken from the Slackware build script for pkgtools.

# User defined variables:
# leave $PKG alone if your using the patch
CWD=`pwd`
ARCH=i686
BUILD=1
VERSION=10.0
TMP=/tmp/pkgtools-build
SAVE=/sources/Xorg-pkgtools-stuff
PKG=/tmp/pkgtools-package
DIALOG=0.9b-20031207
TAR=1.13
MKTEMP=1.5

rm -rf $TMP
rm -rf $PKG
mkdir -p $TMP
mkdir -p $PKG

cd $PKG
tar xzvf $CWD/_pkgtools.tar.gz
# I hate doc's. Nothing but clutter...
rm -rf usr/doc
# Don't need em'
rm -rf etc/*
rm -rf usr/{bin,lib}
rm -rf sbin/makebootdisk

# I also like to remove the X related things and make
# them a part of my Xorg package. So as to not make
# this anymore confusing, we'll just leave them here.
#mkdir -p $SAVE/var/log/setup
#mkdir -p $SAVE/usr/X11R6/bin
#mkdir -p $SAVE/usr/X11R6/man/man1
#cp -a var/log/setup/setup.xwmconfig $SAVE/var/log/setup
#cp -a usr/X11R6/bin/* $SAVE/usr/X11R6/bin
#cat $CWD/xwmconfig.1 | gzip -9 > $SAVE/usr/X11R6/man/man1/xwmconfig.1.gz
#rm -rf usr/X11R6
#rm -rf var/log/setup/*
#mkdir -p var/log/setup/tmp

# If you decide to remove the X stuff by uncommenting
# the above commands, comment the following 8 lines:
mkdir -p $PKG/usr/X11R6/man/man1
cat $CWD/xwmconfig.1 | gzip -9 > $PKG/usr/X11R6/man/man1/xwmconfig.1.gz
( cd var/log/setup
    rm -f setup.70.install-kernel
    rm -f setup.80.make-bootdisk
    rm -f setup.90.modem-device
    rm -f setup.services
)

# Some sed commands to fix our doinst.sh
sed -i '1,8d' install/doinst.sh
sed -i 's@/usr/share@../share@g' install/doinst.sh

# Move our package description into place:
cat $CWD/slack-desc > $PKG/install/slack-desc

# I'm not very proficent with sed commands and found
# it easier to make a patch that makes all the
# desired changes to the pkgtools scripts...
#
# Technically speaking, no changes are required at
# all to our pkgtool scripts, but I think we should
# make some cosmetic changes since it's going to be
# used on LFS and not Slackware. So, the patch is
# optional. If you do decide to use this patch, you
# have to change the 'slack-desc' files to 'desc'
# before you build each package.
#
# If your not using the patch, comment the next 2 lines:
patch -Np1 -i $CWD/pkgtools-10.0-lfs-1.patch
mv $PKG/install/slack-desc $PKG/install/desc

# Get the pkgtool man pages in place:
cp $CWD/*.8 $PKG/usr/man/man8
gzip -9 $PKG/usr/man/man8/*

# Lets build Dialog:
cd $TMP
tar xzvf $CWD/dialog-$DIALOG.tar.gz
cd dialog-$DIALOG
find . -perm 444 -exec chmod 644 {} \;
chown -R root.root .
zcat $CWD/dialog.textbox.noarrows.diff.gz | patch -p1
./configure \
  --prefix=/usr \
  --enable-nls
make
strip --strip-unneeded dialog
cat dialog > $PKG/bin/dialog
cat dialog.1 | gzip -9 > $PKG/usr/man/man1/dialog.1.gz
cd po
make
make install DESTDIR=$PKG
# The dialogrc file is what defines the color set for pkgtools.
# If your interested, try out some different sample files
# other than the Slackware one...
cd ../samples
cat slackware.rc > $PKG/etc/dialogrc

# Apparently, tar-1.14 can't handle symlinks very well with pkgtools.
# We need to build and install just the binary from tar-1.13 for use
# with pkgtools. pkgtool and all associated scripts are hard coded to
# look for a file called "tar-1.13". This will keep it isolated and
# thus will only be used by pkgtool.

cd $TMP
tar xzvf $CWD/tar-$TAR.tar.gz
cd tar-$TAR
zcat $CWD/bzip2-tar.diff.gz | patch -p1 --verbose
chown -R root.root .
./configure \
  --prefix=/usr \
  --bindir=/bin \
  --disable-nls
make
strip --strip-unneeded src/tar
cat src/tar > $PKG/bin/tar-1.13
chmod 755 $PKG/bin/tar-1.13

# We need mktemp now if we are going to be building binaries with
# makepkg. This will be a temporary mktemp seeing as how we are
# building it again in just a little bit, so we won't build it "proper".
# Lets move it to the tail-end of our $PATH, so once we do install
# mktemp in Chapter 6.17, this one will no longer be used.
#
# Also, if/when you rebuild pkgtools after removing the /tools directory,
# this section of the script will do nothing other than waste a few seconds.

cd $TMP
tar xjvf $CWD/mktemp-$MKTEMP.tar.bz2
cd mktemp-$MKTEMP
./configure --prefix=/usr
make
cat mktemp > /tools/bin/mktemp

# Now, lets make our pkgtool binary package 'by hand' since we don't
# have pkgtools installed yet. Make sure you've adjusted the ARCH
# variable on line 93.

cd $PKG
tar cvf pkgtools-$VERSION-$ARCH-$BUILD.tar *
gzip -9 pkgtools-$VERSION-$ARCH-$BUILD.tar
mv pkgtools-$VERSION-$ARCH-$BUILD.tar.gz /tmp/pkgtools-$VERSION-$ARCH-$BUILD.tgz
cd /
tar -xzvf /tmp/pkgtools-$VERSION-$ARCH-$BUILD.tgz
rm -rf /install
installpkg /tmp/pkgtools-$VERSION-$ARCH-$BUILD.tgz

cat << EOF > /tmp/strip
#!/bin/sh
#
# This script is used for the final stage of
# preparing the binary package, right before
# a "makepkg" is issued. Don't put this in your
# PATH as there is another file called 'strip'.
# You can rename it to something unique and then
# place it into your PATH.
#
# This removes the debugging symbols from the libs
# and completely strips the binaries. It also uses
# a static build directory. So, you'll have to use
# DESTDIR=/tmp/package for each package. Taken from
# Chapter 6.60 and slightly modifed. I haven't
# actually used this script tho... :-)
##################################################

# Strip the binaries
/tools/bin/find /tmp/package/{,usr/}{bin,sbin} -type f -exec /tools/bin/strip --strip-unneeded '{}' ';'

# Strip the libraries
/tools/bin/find /tmp/package/{,usr/}{lib} -type f -exec /tools/bin/strip --strip-debug '{}' ';'

# Now compress the man pages
/tools/bin/gzip -f -9 /tmp/package/usr/man/man?/*

# For the shadow package, use this line along with the above
#/tools/bin/gzip -f -9 /tmp/build/usr/man/*?/*?/*
EOF

echo
echo "PKGTOOLS IS NOW INSTALLED."
echo
echo "The binary is located in /tmp if you want to save it."
echo
echo "I've also placed a sample script for stripping binaries"
echo "and compressing man pages into /tmp."
echo

# We untared it first in our / Directory to get the files in place
# so it would work. Then we installed it through pkgtools so it
# would be cataloged and also to execute the install script to create
# it's symlinks.



All times are GMT -5. The time now is 12:21 PM.