Copyright (C) 2010-2023 Jason Woodward <woodwardj at jaos dot org>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Table of Contents:
 1. About
 2. Features
 3. Requirements
 4. Installation
 5. slapt-srcrc
 6. SLACKBUILDS.TXT
 7. Troubleshooting
 8. Thanks and contributions


1. About

slapt-src is a utility to make querying, retrieving, and building slackbuilds as
easy as working with binary packages with slapt-get.


2. Features

  * Remote and local SlackBuild repository support
  * fast
  * more

3. Requirements

  * slapt-get
  * curl

4. Installation

    You can install via meson or autotools (deprecated).

    * Meson

        meson setup build # or any dir of your choosing
        meson compile -C build # or `ninja -C build` for older meson releases
        meson install -C build # or `ninja -C build install`  for older meson releases

        Meson/ninja supports `DESTDIR=/path meson install -C build`

        TIP:
        slapt-src.Slackbuild will create a Slackware package.
        Run with sudo or as a privileged user.

    * autotools (deprecated)

        ./autogen.sh # if building from git
        ./configure
        make
        make install # as privileged user

        The Makefile honors DESTDIR.

        TIP:
        `make pkg` (as privileged user) will create a Slackware package.

5. slapt-srcrc

The slapt-srcrc file consists of the following keys:
  * SOURCE
  * BUILDDIR
  * PKGEXT
  * PKGTAG

Refer to the slapt-src(8) man page for more on the configuration format and options.

Source should point to a local or remote SlackBuild repository that contains
the necessary meta data.  See SLACKBUILDS.TXT below.

6. SLACKBUILDS.TXT

The following script can generate the currently supported format of SLACKBUILDS.TXT.
The filename and format are likely to change.

#!/bin/bash
set -e

for sb in $(find . -name '*.SlackBuild' | sort)
do
  name=$(basename $sb | sed -re 's/\.SlackBuild$//')
  location=$(dirname $sb)
  if [ -f $location/$name.info ]; then
    echo "SLACKBUILD NAME: $name"
    echo "SLACKBUILD LOCATION: $location"
    files=$(cd $location && find .  -type f -printf '%P\n' | sort | xargs)
    echo "SLACKBUILD FILES: $files"

    # remove those pesky multi line listings for each interesting field
    TMP=$(mktemp)
    sed ':a;N;$!ba;s/\\\n*\s*//g' $location/$name.info > $TMP

    DOWNLOAD=$(grep ^DOWNLOAD= $TMP | cut -f2 -d\" )
    DOWNLOAD_x86_64=$(grep ^DOWNLOAD_x86_64= $TMP | cut -f2 -d\" )
    MD5SUM=$(grep ^MD5SUM= $TMP | cut -f2 -d\" )
    MD5SUM_x86_64=$(grep ^MD5SUM_x86_64= $TMP | cut -f2 -d\" )
    VERSION=$(grep ^VERSION= $TMP | cut -f2 -d\" )

    echo "SLACKBUILD VERSION: $VERSION"
    echo "SLACKBUILD DOWNLOAD: $DOWNLOAD"
    echo "SLACKBUILD DOWNLOAD_x86_64: $DOWNLOAD_x86_64"
    echo "SLACKBUILD MD5SUM: $MD5SUM"
    echo "SLACKBUILD MD5SUM_x86_64: $MD5SUM_x86_64"

    if [ -f $location/slack-desc ]; then
      SHORTDESC=$(grep ^$name: $location/slack-desc | head -n 1 | sed -re "s/^$name://")
      echo "SLACKBUILD SHORT DESCRIPTION: $SHORTDESC"
    else
      echo "SLACKBUILD SHORT DESCRIPTION: "
    fi

    echo
    rm -f $TMP
  fi

done > SLACKBUILDS.TXT
gzip -9 SLACKBUILDS.TXT -c > SLACKBUILDS.TXT.gz

# END

7. Troubleshooting

There are likely a lot of bugs.  Email bug reports to me:
    Jason Woodward <woodwardj at jaos dot org>

Or create issues on Github:
    https://github.com/jaos/slapt-src/issues

8. Thanks and contributions

Thanks to the guys from #gsb on freenode for ideas and conceptual discussions.

Thanks to Darren 'Tadgy' Austin and the sponsors File-away Limited
(http://www.file-away.co.uk) and UK2.NET (http://www.uk2.net) for
mirroring slackbuilds.org.
