Ticket #12255: 0001-hvif2png-packaging.patch

File 0001-hvif2png-packaging.patch, 6.5 KB (added by apl-haiku, 9 years ago)
  • new file uild/scripts/build_hvif2png_rpm

    From 795c5e70190bf12574f91cc0b49bb084e2ec2568 Mon Sep 17 00:00:00 2001
    From: Andrew Lindesay <apl@lindesay.co.nz>
    Date: Wed, 29 Jul 2015 21:38:33 +1200
    Subject: [PATCH] hvif2png: packaging - builds an rpm for use with linux -
     builds a tarball for use with *nix systems
    
    ---
     build/scripts/build_hvif2png_rpm     | 101 +++++++++++++++++++++++++++++++++++
     build/scripts/build_hvif2png_tarball |  80 +++++++++++++++++++++++++++
     2 files changed, 181 insertions(+)
     create mode 100755 build/scripts/build_hvif2png_rpm
     create mode 100755 build/scripts/build_hvif2png_tarball
    
    diff --git a/build/scripts/build_hvif2png_rpm b/build/scripts/build_hvif2png_rpm
    new file mode 100755
    index 0000000..051f449
    - +  
     1#!/bin/sh
     2
     3# --------------------------------------------
     4# This script will create an RPM file for installing the hvif2png tool into a
     5# suitable RPM-based linux environment.  This was build in order to support
     6# deployment along side the Haiku Depot Web application server.  Note that
     7# The RPM will require libpng to be installed.  A full build of Haiku may be
     8# required in order that the version 'href' is populated properly.
     9# The only argument to this script is the top of the build-products directory
     10# which is typically ".../haiku/generated".
     11# -------------------------------------------
     12
     13syntax() {
     14    echo "build_hvif2png_rpm <generated-directory>"
     15    exit 1
     16}
     17
     18if [ $# -lt 1 ]; then
     19    syntax
     20fi
     21
     22if ! command -v rpmbuild > /dev/null; then
     23    echo "unable to find the rpmbuild command to produce an rpm"
     24    exit 1
     25fi
     26
     27osName="$(echo `uname`| tr [:upper:] [:lower:])"
     28archName="$(uname -m)"
     29genDir="$1"
     30tmpDir="${genDir}/tmp/hvif2png_rpm"
     31version=`cat "${genDir}/build/haiku-revision" | sed -e "s/[^0-9]//g"`
     32
     33if [ -z "${version}" ]; then
     34        echo "the version was not able to be determined - it may be necessary to undertake a full build to get the version populated"
     35    exit 1
     36fi
     37
     38prepLeaf="hvif2png-${version}.1-1.${archName}"
     39
     40echo "generating rpm from '${genDir}' for version '${version}'"
     41
     42# create the RPM directories
     43
     44for d in BUILD RPMS SOURCES SPECS SRPMS "BUILDROOT/${prepLeaf}/opt/hvif2png/bin" "BUILDROOT/${prepLeaf}/opt/hvif2png/lib" ; do
     45    if ! mkdir -p "${tmpDir}/${d}" ; then
     46        echo "unable to create the rpm working directory; ${tmpDir}/${d}"
     47        exit 1
     48    fi
     49done
     50
     51# copy the necessary files into the right source directory
     52
     53cp "${genDir}/objects/${osName}/lib/libbe_build.so" "${tmpDir}/BUILDROOT/${prepLeaf}/opt/hvif2png/lib"
     54cp "${genDir}/objects/${osName}/lib/libroot_build.so" "${tmpDir}/BUILDROOT/${prepLeaf}/opt/hvif2png/lib"
     55cp "${genDir}/objects/${osName}/${archName}/release/tools/hvif2png/hvif2png" "${tmpDir}/BUILDROOT/${prepLeaf}/opt/hvif2png/bin"
     56
     57cat << EOF > "${tmpDir}/BUILDROOT/${prepLeaf}/opt/hvif2png/bin/hvif2png.sh"
     58#!/bin/sh
     59HVIF2PNG_HOME=/opt/hvif2png
     60export LD_LIBRARY_PATH=\${HVIF2PNG_HOME}/lib:${LD_LIBRARY_PATH}
     61\${HVIF2PNG_HOME}/bin/hvif2png "\$@"
     62EOF
     63
     64# build the SPEC file.
     65
     66cat << EOF > "${tmpDir}/SPECS/hvif2png.spec"
     67%define _unpackaged_files_terminate_build 0
     68Name: hvif2png
     69Version: ${version}.1
     70Release: 1
     71Summary: hvif2png
     72License: MIT
     73Group: haikuos
     74Packager: haikuos
     75autoprov: yes
     76autoreq: yes
     77BuildArch: ${archName}
     78BuildRoot: ${tmpDir}
     79
     80%description
     81This tool allows HVIF formatted vector artwork to be rastered to PNG bitmap images.
     82
     83%install
     84
     85%files
     86%dir %attr(775,root,root) "/opt/hvif2png/lib"
     87%dir %attr(775,root,root) "/opt/hvif2png/bin"
     88%attr(444,root,root)  "/opt/hvif2png/lib/libbe_build.so"
     89%attr(444,root,root)  "/opt/hvif2png/lib/libroot_build.so"
     90%attr(755,root,root)  "/opt/hvif2png/bin/hvif2png"
     91%attr(755,root,root)  "/opt/hvif2png/bin/hvif2png.sh"
     92
     93EOF
     94
     95# now produce the RPM
     96
     97if ! rpmbuild -vv -bb --buildroot "${tmpDir}/BUILDROOT/${prepLeaf}" --define "_topdir ${tmpDir}" "${tmpDir}/SPECS/hvif2png.spec"; then
     98    echo "unable to create the rpm"
     99    exit 1
     100fi
     101
  • new file uild/scripts/build_hvif2png_tarball

    diff --git a/build/scripts/build_hvif2png_tarball b/build/scripts/build_hvif2png_tarball
    new file mode 100755
    index 0000000..584219f
    - +  
     1#!/bin/sh
     2
     3# --------------------------------------------
     4# This script will create an RPM file for installing the hvif2png tool into a
     5# suitable UNIX-like environment.  The launch script will support the use of
     6# 'macports' on the MacOS-X environment in order to have access to the
     7# 'libpng' software.
     8# The only argument to this script is the top of the build-products directory
     9# which is typically ".../haiku/generated".
     10# --------------------------------------------
     11
     12syntax() {
     13    echo "build_hvif2png_rpm <generated-directory>"
     14    exit 1
     15}
     16
     17if [ $# -lt 1 ]; then
     18    syntax
     19fi
     20
     21osName="$(echo `uname`| tr [:upper:] [:lower:])"
     22archName="$(uname -m)"
     23genDir="$1"
     24tmpDir="${genDir}/tmp/hvif2png_tarball"
     25version=`cat "${genDir}/build/haiku-revision"`
     26libPathVar="LD_LIBRARY_PATH"
     27
     28if [ 'Darwin' == "$(uname)" ]; then
     29    libPathVar="DYLD_FALLBACK_LIBRARY_PATH"
     30fi
     31
     32if [ -z "${version}" ]; then
     33        echo "the version was not able to be determined"
     34        version='noversion'
     35fi
     36
     37buildRootDir="${tmpDir}/hvif2png-${version}"
     38prepLeaf="hvif2png-${version}.1-1.${archName}"
     39
     40echo "generating tarball from '${genDir}' for version '${version}'"
     41
     42# create the build directories
     43for d in bin lib; do
     44    if ! mkdir -p "${buildRootDir}/${d}" ; then
     45        echo "unable to create the tarball working directory; ${d}"
     46        exit 1
     47    fi
     48done
     49
     50# copy the necessary files into the right source directory
     51
     52cp "${genDir}/objects/${osName}/lib/libbe_build.so" "${buildRootDir}/lib"
     53cp "${genDir}/objects/${osName}/lib/libroot_build.so" "${buildRootDir}/lib"
     54cp "${genDir}/objects/${osName}/${archName}/release/tools/hvif2png/hvif2png" "${buildRootDir}/bin"
     55
     56cat << EOF > "${buildRootDir}/bin/hvif2png.sh"
     57#!/bin/sh
     58HVIF2PNG_HOME="\$(dirname \$0)/.."
     59${libPathVar}=\${HVIF2PNG_HOME}/lib:\${${libPathVar}}
     60
     61# support for MacOS-X macports
     62if [ -d /opt/local/lib ]; then
     63    ${libPathVar}=\${${libPathVar}}:/opt/local/lib
     64fi
     65
     66export ${libPathVar}
     67\${HVIF2PNG_HOME}/bin/hvif2png "\$@"
     68EOF
     69
     70if ! chmod +x "${buildRootDir}/bin/hvif2png.sh"; then
     71    echo "unable to change the permission on the launch script"
     72    exit 1
     73fi
     74
     75if ! tar -C "${tmpDir}" -czf "${genDir}/tmp/hvif2png-${version}-${archName}.tgz" "hvif2png-${version}" ; then
     76    echo "unable to create the tarball"
     77    exit 1
     78fi
     79
     80echo "note that the libpng libraries must be available for the hvif2png software to work."