### this file is sourced not run
PKGVER=17.04
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS 11.3
TARBALL=p7zip-$PKGVER.tar.gz
MD5SUM=00acfd6be87848231722d2d53f89e4a5
SRC_URL=https://github.com/p7zip-project/p7zip/archive/v17.04/$TARBALL
BUNDLE=

SLACKREQ=
SLACKDESC="p7zip: p7zip $PKGVER (Command-line archiver)  
p7zip:  
p7zip: p7zip is the Unix command-line port of 7-Zip, a file archiver that 
p7zip: archives with high compression ratios. It handles 7z, ZIP, GZIP, BZIP2, 
p7zip: XZ, TAR, APM, ARJ, CAB, CHM, CPIO, CramFS, DEB, DMG, FAT, HFS, ISO, 
p7zip: LZH, LZMA, LZMA2, MBR, MSI, MSLZ, NSIS, NTFS, RAR RPM, SquashFS, UDF, 
p7zip: VHD, WIM, XAR and Z formats.  
p7zip: 
p7zip: https://github.com/p7zip-project/p7zip
p7zip: 
p7zip:
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/p7zip* &&
	# patch
	true
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/p7zip*

	# BLFS 11.3 prevent compressed manpages
	sed '/^gzip/d' -i install.sh &&

	# BLFS 11.3 security vulnerability
	sed -i '160a if(_buffer == nullptr || _size == _pos) return E_FAIL;' CPP/7zip/Common/StreamObjects.cpp &&
	
	# we only build 7z
	make $MAKEFLAGS 7z sfx &&
	make DEST_HOME=/usr DEST_SHARE=/usr/$LIBDIR/pz7ip \
		DEST_MAN=/usr/share/man \
		DEST_SHARE_DOC=/usr/share/doc/p7zip-$PKGVER install	&&
	pkg_build_slackdesc &&
	
	# emulate 7za with 7z
	ln -s 7z /usr/bin/7za &&
	
	# remove not-applicable manpages
	rm /usr/share/man/man1/{7zr,7za}.1
}


