/[gentoo-x86]/eclass/vmware-bundle.eclass
Gentoo

Contents of /eclass/vmware-bundle.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Mon Aug 22 04:46:32 2011 UTC (2 years, 11 months ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +5 -5 lines
fix random bugs in eclass documentation, and convert to new @AUTHOR tag

1 vadimk 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 vapier 1.2 # $Header: /var/cvsroot/gentoo-x86/eclass/vmware-bundle.eclass,v 1.1 2011/03/17 18:23:40 vadimk Exp $
4 vadimk 1.1
5     # @ECLASS: vmware-bundle.eclass
6 vapier 1.2 # @MAINTAINER:
7     # vmware@gentoo.org
8     # @AUTHOR:
9     # Matt Whitlock <matt@whitlock.name>
10 vadimk 1.1 # @BLURB: Provides extract functionality for vmware products bundles
11    
12     DEPEND="dev-libs/libxslt"
13    
14     vmware-bundle_extract-bundle-component() {
15     local bundle=${1:?} component=${2:?} dest=${3:-${2}}
16     cat > "${T}"/list-bundle-components.xsl <<-EOF
17     <?xml version="1.0" encoding="ISO-8859-1"?>
18     <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
19     <xsl:output omit-xml-declaration="yes"/>
20     <xsl:template match="text()"/>
21     <xsl:template match="/bundle/components/component">
22     <xsl:value-of select="@offset"/>
23     <xsl:text> </xsl:text>
24     <xsl:value-of select="@size"/>
25     <xsl:text> </xsl:text>
26     <xsl:value-of select="@name"/>
27     <xsl:text>&#10;</xsl:text>
28     </xsl:template>
29     </xsl:stylesheet>
30     EOF
31     local -i bundle_size=$(stat -L -c'%s' "${bundle}")
32     local -i bundle_manifestOffset=$(od -An -j$((bundle_size-36)) -N4 -tu4 "${bundle}")
33     local -i bundle_manifestSize=$(od -An -j$((bundle_size-40)) -N4 -tu4 "${bundle}")
34     local -i bundle_dataOffset=$(od -An -j$((bundle_size-44)) -N4 -tu4 "${bundle}")
35     local -i bundle_dataSize=$(od -An -j$((bundle_size-52)) -N8 -tu8 "${bundle}")
36     tail -c+$((bundle_manifestOffset+1)) "${bundle}" 2> /dev/null | head -c$((bundle_manifestSize)) |
37     xsltproc "${T}"/list-bundle-components.xsl - |
38     while read -r component_offset component_size component_name ; do
39     if [[ ${component_name} == ${component} ]] ; then
40     ebegin "Extracting '${component_name}' component from '$(basename "${bundle}")'"
41     vmware-bundle_extract-component "${bundle}" "${dest}" $((bundle_dataOffset+component_offset))
42     eend
43     fi
44     done
45     }
46    
47     vmware-bundle_extract-component() {
48     local component=${1:?} dest=${2:-.}
49     local -i offset=${3}
50     cat > "${T}"/list-component-files.xsl <<-EOF
51     <?xml version="1.0" encoding="ISO-8859-1"?>
52     <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
53     <xsl:output omit-xml-declaration="yes"/>
54     <xsl:template match="text()"/>
55     <xsl:template match="/component/fileset/file">
56     <xsl:value-of select="@offset"/>
57     <xsl:text> </xsl:text>
58     <xsl:value-of select="@compressedSize"/>
59     <xsl:text> </xsl:text>
60     <xsl:value-of select="@uncompressedSize"/>
61     <xsl:text> </xsl:text>
62     <xsl:value-of select="@path"/>
63     <xsl:text>&#10;</xsl:text>
64     </xsl:template>
65     </xsl:stylesheet>
66     EOF
67     local -i component_manifestOffset=$(od -An -j$((offset+9)) -N4 -tu4 "${component}")
68     local -i component_manifestSize=$(od -An -j$((offset+13)) -N4 -tu4 "${component}")
69     local -i component_dataOffset=$(od -An -j$((offset+17)) -N4 -tu4 "${component}")
70     local -i component_dataSize=$(od -An -j$((offset+21)) -N8 -tu8 "${component}")
71     tail -c+$((offset+component_manifestOffset+1)) "${component}" 2> /dev/null |
72     head -c$((component_manifestSize)) | xsltproc "${T}"/list-component-files.xsl - |
73     while read -r file_offset file_compressedSize file_uncompressedSize file_path ; do
74     if [[ ${file_path} ]] ; then
75     echo -n '.'
76     file_path="${dest}/${file_path}"
77     mkdir -p "$(dirname "${file_path}")" || die
78     tail -c+$((offset+component_dataOffset+file_offset+1)) "${component}" 2> /dev/null |
79     head -c$((file_compressedSize)) | gzip -cd > "${file_path}" || die
80     fi
81     done
82     echo
83     }

  ViewVC Help
Powered by ViewVC 1.1.20