Ticket #12255: 0001-packaging-builds-an-rpm-or-tarball-for-the-hvif2png-.patch

File 0001-packaging-builds-an-rpm-or-tarball-for-the-hvif2png-.patch, 6.4 KB (added by apl-haiku, 9 years ago)
  • new file uild/scripts/build_hvif2png_rpm

    From dbf54d2f616b75c93b3ccedb5f38d19ab6d64cc2 Mon Sep 17 00:00:00 2001
    From: Andrew Lindesay <apl@lindesay.co.nz>
    Date: Sun, 9 Aug 2015 16:14:24 +1200
    Subject: [PATCH] packaging - builds an rpm or tarball for the hvif2png tool
    
    ---
     build/scripts/build_hvif2png_rpm     | 102 +++++++++++++++++++++++++++++++++++
     build/scripts/build_hvif2png_tarball |  79 +++++++++++++++++++++++++++
     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..bb20460
    - +  
     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-1.${version}-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: 1.${version}
     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"
     87%dir %attr(775,root,root) "/opt/hvif2png/lib"
     88%dir %attr(775,root,root) "/opt/hvif2png/bin"
     89%attr(444,root,root)  "/opt/hvif2png/lib/libbe_build.so"
     90%attr(444,root,root)  "/opt/hvif2png/lib/libroot_build.so"
     91%attr(755,root,root)  "/opt/hvif2png/bin/hvif2png"
     92%attr(755,root,root)  "/opt/hvif2png/bin/hvif2png.sh"
     93
     94EOF
     95
     96# now produce the RPM
     97
     98if ! rpmbuild -vv -bb --buildroot "${tmpDir}/BUILDROOT/${prepLeaf}" --define "_topdir ${tmpDir}" "${tmpDir}/SPECS/hvif2png.spec"; then
     99    echo "unable to create the rpm"
     100    exit 1
     101fi
     102
  • 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..f27a4ec
    - +  
     1#!/bin/sh
     2
     3# --------------------------------------------
     4# This script will create a tarball 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}"
     38
     39echo "generating tarball from '${genDir}' for version '${version}'"
     40
     41# create the build directories
     42for d in bin lib; do
     43    if ! mkdir -p "${buildRootDir}/${d}" ; then
     44        echo "unable to create the tarball working directory; ${d}"
     45        exit 1
     46    fi
     47done
     48
     49# copy the necessary files into the right source directory
     50
     51cp "${genDir}/objects/${osName}/lib/libbe_build.so" "${buildRootDir}/lib"
     52cp "${genDir}/objects/${osName}/lib/libroot_build.so" "${buildRootDir}/lib"
     53cp "${genDir}/objects/${osName}/${archName}/release/tools/hvif2png/hvif2png" "${buildRootDir}/bin"
     54
     55cat << EOF > "${buildRootDir}/bin/hvif2png.sh"
     56#!/bin/sh
     57HVIF2PNG_HOME="\$(dirname \$0)/.."
     58${libPathVar}=\${HVIF2PNG_HOME}/lib:\${${libPathVar}}
     59
     60# support for MacOS-X macports
     61if [ -d /opt/local/lib ]; then
     62    ${libPathVar}=\${${libPathVar}}:/opt/local/lib
     63fi
     64
     65export ${libPathVar}
     66\${HVIF2PNG_HOME}/bin/hvif2png "\$@"
     67EOF
     68
     69if ! chmod +x "${buildRootDir}/bin/hvif2png.sh"; then
     70    echo "unable to change the permission on the launch script"
     71    exit 1
     72fi
     73
     74if ! tar -C "${tmpDir}" -czf "${genDir}/tmp/hvif2png-${version}-${archName}.tgz" "hvif2png-${version}" ; then
     75    echo "unable to create the tarball"
     76    exit 1
     77fi
     78
     79echo "note that the libpng libraries must be available for the hvif2png software to work."