#!/bin/bash

#Config
user=`id -un`
group=`id -gn`
processor=`uname -p`
kernel=`uname -s`
release=`uname -r`

#Creation of known directories and filenames
name="mediainfo"
version="26.05.20260627"
Home=`pwd`
install_prefix=${Home}/mk_package
packagecreation_prefix=${Home}/create_package
if test -z "${basedir}"; then
    basedir="/"
fi

#Common code
. ./mkpkg.sub

#Compile and install
cd ../GNU/CLI
./autogen.sh
./configure --prefix="${install_prefix}" --enable-shared --disable-static $*
make
if test -e mediainfo; then
    echo "Compilation OK"
else
    echo "Compilation problem"
    exit 1
fi

#****************************************************************************
# Release
#****************************************************************************

cd "${Home}"
mkdir -p "${install_prefix}"

#Copying useful files
#bin
install -d -m 755 "${install_prefix}/bin"
cp -rP ../GNU/CLI/mediainfo "${install_prefix}/bin"
cp -rPf ../GNU/CLI/.libs/mediainfo "${install_prefix}/bin"
install -d -m 755 "${install_prefix}/share/doc/${name}"
cp ../../*.txt "${install_prefix}/share/doc/${name}"
cp ../../Release/ReadMe_CLI_Linux.txt "${install_prefix}/share/doc/${name}/ReadMe.txt"
mv "${install_prefix}/share/doc/${name}/History_CLI.txt" "${install_prefix}/share/doc/${name}/History.txt"
cp ../../License.html "${install_prefix}/share/doc/${name}/"
chmod 644 "${install_prefix}/share/doc/${name}/"*

#Creation of package
pkgname="${name}"
PackageCreate


exit 0

#hints
#install: pkgadd -d./ mediainfo
#remove: pkgrm mediainfo, remove /var/spool/pkg/mediainfo
