SUMMARY="Text-mode tools for GUID Partition Table (GPT) disks"
DESCRIPTION="GPT fdisk (consisting of the gdisk, cgdisk, sgdisk, and fixparts \
programs) is a set of text-mode partitioning tools loosely modeled on Linux \
fdisk. The gdisk, cgdisk and sgdisk programs work on Globally Unique \
Identifier (GUID) Partition Table (GPT) disks, rather than on Master Boot \
Record (MBR) partition tables, but may also be used on MBR disks to convert \
them to GPT. The fixparts program repairs certain types of damage to MBR disks \
and enables changing partition types from primary to logical and vice-versa."
HOMEPAGE="http://www.rodsbooks.com/gdisk/"
COPYRIGHT="2013-2018 Rod Smith"
LICENSE="GNU GPL v2"
REVISION="3"
SOURCE_URI="https://downloads.sf.net/gptfdisk/gptfdisk-$portVersion.tar.gz"
CHECKSUM_SHA256="b663391a6876f19a3cd901d862423a16e2b5ceaa2f4a3b9bb681e64b9c7ba78d"
PATCHES="gptfdisk-$portVersion.patchset"

ARCHITECTURES="all ?x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
# Comment out this block if you wish to co-install gptfdisk & gptfdisk_x86.
	commandSuffix=
	commandBinDir=$prefix/bin
fi

# 1.3.1 is the "fixed" non util_linux version of libuuid
libuuidMinimumVersion=1.3.1

PROVIDES="
	gptfdisk$secondaryArchSuffix = $portVersion
	cmd:cgdisk$commandSuffix = $portVersion
	cmd:fixparts$commandSuffix = $portVersion
	cmd:gdisk$commandSuffix = $portVersion
	cmd:sgdisk$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libuuid$secondaryArchSuffix >= $libuuidMinimumVersion
	lib:libncursesw$secondaryArchSuffix
	lib:libpopt$secondaryArchSuffix
	"

if [ -n "$secondaryArchSuffix" -a "$commandBinDir" != "$binDir" ]; then
CONFLICTS="
	gptfdisk
	"
fi

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libuuid$secondaryArchSuffix >= $libuuidMinimumVersion
	devel:libncursesw$secondaryArchSuffix
	devel:libpopt$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:install
	cmd:make
	"

TEST_REQUIRES="
	cmd:awk
	cmd:dd
	cmd:grep
	cmd:head
	cmd:mktemp
	cmd:tail
	cmd:tr
	"

BUILD()
{
	make $jobArgs
}

INSTALL()
{
	install -m 0755 -d "$commandBinDir" "$docDir" "$manDir"/man8
	install -m 0755 -t "$commandBinDir" -s cgdisk gdisk sgdisk fixparts
	install -m 0644 -t "$docDir" README
	install -m 0644 -t "$manDir"/man8 *.8
}

TEST()
{
	make test
}
