### this file is sourced not run
PKGVER=0.38.1.2018.08
PKGBUILD=1_wsr
PKGARCH=noarch

### source: james - repackage sbopkg to tbz, with some directory changes
#TARBALL=sbopkg-$PKGVER-$PKGARCH-$PKGBUILD.tgz
#MD5SUM=3a63fe433e165ba3fa5b7d4ccaa39cd8
#SRC_URL=https://github.com/sbopkg/sbopkg/releases/download/0.38.1/$TARBALL
TARBALL=sbopkg-20180801.tar.bz2
MD5SUM=3235f248fa9137990849bb5ba3bc91f8
SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$TARBALL
BUNDLE=

SLACKREQ=
SLACKDESC="sbopkg: sbopkg $PKGVER (SlackBuilds.org Package Browser)
sbopkg:
sbopkg: Sbopkg is a command-line and dialog-based tool to interact with the
sbopkg: SlackBuilds.org repository, a collection of third-party SlackBuild
sbopkg: scripts to build Slackware packages.
sbopkg:
sbopkg: Homepage:  http://www.sbopkg.org
sbopkg:
sbopkg:
sbopkg:
sbopkg:
"

### standard pkg_download

pkg_prepare() {
	pkg_check $SRC_DIR $TARBALL $MD5SUM &&
	mkdir -p tmp/sbopkg
	tar -xf $SRC_DIR/$TARBALL -C tmp/sbopkg
}

# default pkg_prepare
# build
pkg_build() {
	cd /tmp/sbopkg &&
	
	### this acrobatics only required for git build
	cd sbopkg-git &&
	sed -i -e "s|VERSION=.*|VERSION=$PKGVER|" \
		-e "s|^repo=.*|repo=$PWD|" tools/sspm &&
	
	# this will fail with missing makepkg, but we don't need that
	sh ./tools/sspm -b 
	cd /tmp/build/package-sbopkg &&
	### end git build

	# this acrobatics to change slackware's dirs to Fatdog dirs
	mkdir -p /usr/share/{doc,man} /install &&
	find . -type f -exec chmod 0644 '{}' \; &&
	find . -type d -exec chmod 0755 '{}' \; &&

	cp -a usr/doc /usr/share &&
	cp -a usr/man /usr/share &&
	#cp -a usr/sbin/* /usr/sbin &&
	install -m755 usr/sbin/* /usr/sbin &&
	cp -a etc/* /etc &&
	cp -a install/* /install &&
	sed -i -e 's|/usr/doc|/usr/share/doc|' /install/doinst.sh &&
	pkg_build_slackdesc
}
