jedsoft / slxfig

Xfig-based publication quality plotting package for the S-Lang interpreter
GNU General Public License v2.0
1 stars 0 forks source link

Installation fails, probably because `src/Makefile.in` nullifies `$DESTDIR` #1

Closed kseistrup closed 10 months ago

kseistrup commented 10 months ago

I am packaging slxfig for ArchLinux User Repository (AUR): slxfig-snapshot

The packaging probably fails because $DESTDIR is set to an empty string in src/Makefile.in, which carries over to src/Makefile, as far as I can see.

Building and packaging is done by the tool makepkg via PKBUILD (attached). The latter is essentially a bash script that cds into the directory created by the exploded tarball, and then:

# build
./configure --prefix=/usr
make  # ← this succeeds

# package
make DESTDIR="$pkgdir" install  # ← this fails

The variable $pkgdir is provided by makepkg with the intention that everything installs in $pkgdir$prefix. This fails whenever the Makefile uses MKINSDIR = ../autoconf/mkinsdir.sh, and succeeds when the latter variable is set to mkdir -p by inserting:

sed -i '/^MKINSDIR/c\MKINSDIR = mkdir -p' src/Makefile

between the configure and the make commands in the build() function, which is the “solution” I am using. I have attached interleaved stdout/stderr from the makepkg command as err.txt.

I am using the

./configure --prefix=/usr
make
make DESTDIR="$pkgdir" install 

method when packaging slang-snapshot, slrn-snapshot, most-snapshot and jed-git, but it doesn't seem to work in the case of slxfig.

Am I doing something wrong?


:link: PKGBUILD.txt :link: err.txt

jedsoft commented 10 months ago

Hi Klaus,

I am not sure that I follow. What commands get generated when you run make with the -n flag? For example, I just tried this:

grep MKINSDIR src/Makefile

MKINSDIR= ../autoconf/mkinsdir.sh $(MKINSDIR) $(DEST_MODULE_INSTALL_DIR) $(MKINSDIR) $(DEST_SL_FILES_INSTALL_DIR)/xfig $(MKINSDIR) $(DEST_HLP_FILES_INSTALL_DIR)

grep DESTDIR src/Makefile

DESTDIR is designed to facilitate making packages. Normally it is empty

DESTDIR = DEST_MODULE_INSTALL_DIR = $(DESTDIR)$(MODULE_INSTALL_DIR) DEST_SL_FILES_INSTALL_DIR = $(DESTDIR)$(SL_FILES_INSTALL_DIR) DEST_HLP_FILES_INSTALL_DIR = $(DESTDIR)$(HLP_FILES_INSTALL_DIR)

make -n DESTDIR=/tmp/foo install

cd src; make install make[1]: Entering directory '/aluche/d1/home/jedavis/src/slxfig/src' ../autoconf/mkinsdir.sh /tmp/foo/home/jedavis/sys/linux-x86_64/lib/slang/v2/modules ../autoconf/mkinsdir.sh /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages/xfig ../autoconf/mkinsdir.sh /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages/help for X in gcontour-module.so; \ do \ Y=$X../mkversion.sh; \ YDEST=/tmp/foo/home/jedavis/sys/linux-x86_64/lib/slang/v2/modules/$Y; \ echo /usr/bin/install -c -m 644 $X $YDEST; \ /usr/bin/install -c -m 644 $X $YDEST; \ if [ "$?" != "0" ]; then \ exit 1; \ fi; \ rm -f /tmp/foo/home/jedavis/sys/linux-x86_64/lib/slang/v2/modules/$X; \ ln -s $Y /tmp/foo/home/jedavis/sys/linux-x86_64/lib/slang/v2/modules/$X; \ done for X in gcontour.sl xfig.sl vector.sl; \ do \ echo /usr/bin/install -c -m 644 $X /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages; \ /usr/bin/install -c -m 644 $X /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages; \ if [ "$?" != "0" ]; then \ exit 1; \ fi; \ done for X in xfig/*.sl xfig/w3ccolors.txt; \ do \ echo /usr/bin/install -c -m 644 $X /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages/xfig/; \ /usr/bin/install -c -m 644 $X /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages/xfig/; \ if [ "$?" != "0" ]; then \ exit 1; \ fi; \ done for X in ../doc/help/slxfig.hlp ../doc/help/gcontour.hlp ../doc/help/vector.hlp; \ do \ echo /usr/bin/install -c -m 644 $X /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages/help; \ /usr/bin/install -c -m 644 $X /tmp/foo/home/jedavis/sys/linux-x86_64/share/slsh/local-packages/help; \ if [ "$?" != "0" ]; then \ exit 1; \ fi; \ done make[1]: Leaving directory '/aluche/d1/home/jedavis/src/slxfig/src'

Note that it generated commands to install under /tmp/foo.

Thanks, --John

On Sat, 13 Jan 2024 01:13:28 -0800, Klaus Alexander Seistrup @.***> said:

I am packaging slxfig for ArchLinux User Repository (AUR): slxfig-snapshot

The packaging probably fails because $DESTDIR is set to an empty string in src/Makefile.in, which carries over to src/Makefile, as far as I can see.

Building and packaging is done by the tool makepkg via PKBUILD (attached). The latter is essentially a bash script that cds into the directory created by the exploded tarball, and then:

# build
./configure --prefix=/usr
make  # ← this succeeds

# package
make DESTDIR="$pkgdir" install  # ← this fails

The variable $pkgdir is provided by makepkg with the intention that everything installs in $pkgdir$prefix. This fails whenever the Makefile uses MKINSDIR = ../autoconf/mkinsdir.sh, and succeeds when the latter variable is set to mkdir -p by inserting:

sed -i '/^MKINSDIR/c\MKINSDIR = mkdir -p' src/Makefile

between the configure and the make commands in the build() function, which is the “solution” I am using. I have attached interleaved stdout/stderr from the makepkg command as err.txt.

I am using the

./configure --prefix=/usr
make
make DESTDIR="$pkgdir" install

method when packaging slang-snapshot, slrn-snapshot, most-snapshot and jed-git, but it doesn't seem to work in the case of slxfig.

Am I doing something wrong?


:link: PKGBUILD.txt :link: err.txt

-- Reply to this email directly or view it on GitHub: https://github.com/jedsoft/slxfig/issues/1 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

----next-part-6B0D29BD65A44A61F08A757C94BCB--

kseistrup commented 10 months ago

I'm awfully sorry for my confusing bug report.

TL;DR: Problem solved by unsetting $MAKEFLAGS such that make do not run any jobs in parallel.

Let me shortly recap:

I repeatedly failed to build and install slxfig with:

./configure --prefix=/usr
make
make DESTDIR="$pkgdir" install

The install step kept barfing over a missing file or directory (as was seen in the err.txt file that I attached to my original post), and I wrongly assumed it was because there was this empty assignment of “DESTDIR =” in one of the makefiles.

However, when I substituted the makefile's use of autoconf/mkinsdir.sh with mkdir -p the install step never failed.

Back to now:

I have kept unpacking, configuring, making and installing, and once every umpteenth attempt the install step would actually succeed. I strongly believe I have now found the real culprit: I have $MAKEFLAGS=-j2 in my environment, and even when building on a ram disk, the mkinsdir.sh script (with its repeated calls to mkdir for every element in the path) will be significantly slower than mkdir -p, and so the install step will — at least on my machine — attempt to install a file before its destination directory has been created because more than one shell job is working in parallel.

By unsetting $MAKEFLAGS, make will not use parallel jobs, and so all necessary directories will be created before any files are copied into them.

In the actual PKGBUILD file that ArchLinux' pacman uses to build a package this is achieved with options=('!makeflags'), and when I introduce that option I can consistently build the package, even on a spinning disk.

I'm sorry if I have wasted your time.

jedsoft commented 10 months ago

I updated src/Makefile.in to avoid a race condition in parallel installs. My feeling is that you encountered the race condition. Please try the latest commit. Thanks, --John

On Mon, 15 Jan 2024 01:10:30 -0800, Klaus Alexander Seistrup @.***> said:

Closed #1 as completed.

-- Reply to this email directly or view it on GitHub: https://github.com/jedsoft/slxfig/issues/1#event-11485529084 You are receiving this because you commented.

Message ID: @.***> ----==_mimepart_65a4f686da88c_d91734302956 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

<p dir=3D"auto">Closed <a class=3D"issue-link js-issue-link" data-error-t= ext=3D"Failed to load title" data-id=3D"2080197749" data-permission-text=3D= "Title is private" data-url=3D"https://github.com/jedsoft/slxfig/issues/1= " data-hovercard-type=3D"issue" data-hovercard-url=3D"/jedsoft/slxfig/iss= ues/1/hovercard" href=3D"https://github.com/jedsoft/slxfig/issues/1">#1</= a> as completed.

<p style=3D"font-size:small;-webkit-text-size-adjust:none;color:#666;">&m= dash;
Reply to this email directly, <a href=3D"https://github.com/je= dsoft/slxfig/issues/1#event-11485529084">view it on GitHub, or <a hre= f=3D"https://github.com/notifications/unsubscribe-auth/ABDACBRW7PKKNYI6TL= RXEEDYOTXANAVCNFSM6AAAAABBZF3H6KVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZX= XI2LGNFRWC5DJN5XDWMJRGQ4DKNJSHEYDQNA">unsubscribe.
You are recei= ving this because you commented.<img src=3D"https://github.com/notificati= ons/beacon/ABDACBVSXMYE4K672XTIR3TYOTXANA5CNFSM6AAAAABBZF3H6KWGG33NNVSW45= C7OR4XAZNWJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XKUY3PNVWWK3TUL5UWJTYAAAAAFLE= XIP6A.gif" height=3D"1" width=3D"1" alt=3D"" /><span style=3D"color: tran= sparent; font-size: 0; display: none; visibility: hidden; overflow: hidde= n; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide= : all">Message ID: <jedsoft/slxfig/issue/1/issue_event/114855290= 84/span><span>@</spangithub.com></sp= an>

<script type=3D"application/ld+json">[ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.***": "ViewAction", "target": "https://github.com/jedsoft/slxfig/issues/1#event-11485529084",=

"url": "https://github.com/jedsoft/slxfig/issues/1#event-11485529084", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]=

----==_mimepart_65a4f686da88c_d91734302956--

----next-part-4AD3F81465A5962FF3803BF7CB9D9--

kseistrup commented 10 months ago

Works like a charm. Thank you so much. :pray: