https://issues.apache.org/SpamAssassin/show_bug.cgi?id=5904

           Summary: DESTDIR not completely working in Makefile (contains
                    workaround)
           Product: Spamassassin
           Version: 3.2.4
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P5
         Component: Building & Packaging
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


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.


-- 
Configure bugmail: 
https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to