[sbopkg-users] Using sbopkg with Slackbuilds that pull tarballs from Github, Sourcehut, etc.

B Watson yalhcru at gmail.com
Tue Jun 9 18:24:27 UTC 2020


Hi, welcome to the mailing list. This ended up longer than I expected,
but hopefully it's helpful.

On 6/9/20, Matthew Graybosch <hello at matthewgraybosch.com> wrote:
>
> Is this a problem I can safely resolve by adding "-o
> ${NAME}-${VERSION}.tar.gz" to WGETFLAGS in sbopkg.conf, or is there a
> better way to go about ensuring that the source file gets downloaded
> ${NAME}-${VERSION}.tar.gz?

That would work for sbopkg, but not everyone uses sbopkg... you have
no way to ensure anything about how the source file gets downloaded
(some people even use a browser).

> Is this even something I should be worrying about when prepping a new
> slackbuild for submission to slackbuilds.org?

Yes. The issue is the same one that happens with github: the server is
sending a Content-disposition header, which sets the filename to save
as. You have no way to know what the user's going to use to download
the file, so you don't know if it'll obey the header...

For github, there's a way to rewrite the URL so it ends up saving the
file with the same name, whether or not Content-disposition is honored.
For this git.sr.ht server, it doesn't look like that's going to work.

The thing to do here is make the SlackBuild handle either filename. One
way to do it:

  tar xvf $VERSION.tar.gz || tar xvf $PRGNAM-$VERSION.tar.gz
  cd $PRGNAM-$VERSION
  # rest of script proceeds normally

This works, but if $VERSION.tar.gz didn't exist, the user might notice
a scary-looking but harmless "tar: 0.8.14.tar.gz: Cannot open: No such
file or directory" message in the build output.

Another way to do it:

  if [ -e $CWD/$VERSION.tar.gz ]; then
    TARBALL=$CWD/$VERSION.tar.gz
  else
    TARBALL=$CWD/$PRGNAM-$VERSION.tar.gz
  fi

  tar xvf $TARBALL
  cd $PRGNAM-$VERSION   # etc etc.

You could write the "if" clause more compactly:

  TARBALL=$CWD/$PRGNAM-$VERSION.tar.gz
  [ -e $CWD/$VERSION.tar.gz ] && TARBALL=$CWD/$VERSION.tar.gz

YMMV on whether that's easier or harder to read.


More information about the sbopkg-users mailing list