Bug 5904 - DESTDIR not completely working in Makefile (contains workaround)
Summary: DESTDIR not completely working in Makefile (contains workaround)
Status: RESOLVED DUPLICATE of bug 6131
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Building & Packaging (show other bugs)
Version: 3.2.4
Hardware: PC Linux
: P5 major
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-08 01:41 UTC by Christian Schiffler
Modified: 2009-09-27 17:39 UTC (History)
1 user (show)



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schiffler 2008-05-08 01:41:50 UTC
I discovered that the DESTDIR is not working as mentioned in the docs.

my environment:
Slackware Linux 12.0
perl: 2.8.8
ExtUtils::MakeMaker: 6.44
So there all seems to be fine.

for the following I assume:
PKG=/tmp/package-spamassassin
as the stuff is directly ripped from my build script for spamassassin.

It builds just fine when doing:
perl Makefile.PL PREFIX="/usr" DESTDIR="$PKG" < /dev/null

The "make install" will fail as it still tries to create /etc/mail/spamassassin/ and /usr/share/spamassassin for placing files there.

After twiddling for some while I found out that the variables
INSTALLDATA, INSTALLSITEDATA, INSTALLVENDORDATA are used for install destination dirs but not prefixed with DESTDIR, which therefore makes things unuseable.

I found the following workaround (yeah, I know it's pretty ugly but at least it works):

PKG=/tmp/package-spamassassin
# Configure
perl Makefile.PL PREFIX="/usr" DESTDIR="$PKG" < /dev/null
# Compile
make
# Do the tests
make disttest
# Install
INSTALLDATA=/usr/share/spamassassin
INSTALLSITEDATA=/usr/share/spamassassin
INSTALLVENDORDATA=/usr/share/spamassassin
make install \
        DESTDIR="$PKG" \
        B_CONFDIR="$PKG/etc/mail/spamassassin" \
        INSTALLDATA="$PKG/$INSTALLDATA" \
        INSTALLSITEDATA="$PKG/$INSTALLSITEDATA" \
        INSTALLVENDORDATA="$PKG/$INSTALLVENDORDATA"

Note that I only alter the vendordata stuff for "make install" as otherwise the pathes will end up in the binaries.
Doing it with above method only puts "/tmp/package-spamassassin/..." in ".packlist" and "${PKG}/usr/bin/sa-update" which I lateron filter by piping the stuff through sed.

# Fix .packlist to remove temporary package dir references.
string="`echo $PKG | sed -e 's/\//\\\\\//g'`"
echo string is $string
for file in `find $PKG -name .packlist`; do
  sed -e "s/^$string//g" $file > $file.tmp
  mv $file.tmp $file
done

# fix b0rked path containing $PKG in sa-update.
chmod o+w ${PKG}/usr/bin/sa-update
sed -e "s/$string//g" ${PKG}/usr/bin/sa-update > ${PKG}/usr/bin/sa-update.new
rm -f ${PKG}/usr/bin/sa-update
mv ${PKG}/usr/bin/sa-update.new ${PKG}/usr/bin/sa-update
chmod 555 ${PKG}/usr/bin/sa-update

Using this method, I could even build SA as non privileged user and pack together which was a nice side effect of my testing (I had to make sure the build can not write outside of it's DESTDIR and was too lazy to build a chroot for this purpose).

I hope the above information helps you guys in fixing the Makefile.pl.
If not, feel free to add this information to the install docs packaging section.
Comment 1 Mark Martinec 2009-09-18 17:14:42 UTC
Not sure, but tentatively marking it as a duplicate of Bug 6131,
(fixed in 3.3.0).

*** This bug has been marked as a duplicate of bug 6131 ***