From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 1F90F59CA4 for ; Fri, 18 Mar 2016 03:16:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C7E4121C02F; Fri, 18 Mar 2016 03:16:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A84F821C02F for ; Fri, 18 Mar 2016 03:16:32 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 896C8340DA4 for ; Fri, 18 Mar 2016 03:16:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 87F8C859 for ; Fri, 18 Mar 2016 03:16:26 +0000 (UTC) From: "Evan Teran" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Evan Teran" Message-ID: <1458270824.0cba229f49cba683ac1afbf0667b04ff7ed13bd4.eteran@gentoo> Subject: [gentoo-commits] proj/vmware:master commit in: eclass/ X-VCS-Repository: proj/vmware X-VCS-Files: eclass/vmware-bundle.eclass X-VCS-Directories: eclass/ X-VCS-Committer: eteran X-VCS-Committer-Name: Evan Teran X-VCS-Revision: 0cba229f49cba683ac1afbf0667b04ff7ed13bd4 X-VCS-Branch: master Date: Fri, 18 Mar 2016 03:16:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 0604f724-3bb4-4514-8b90-ee66ab7afce9 X-Archives-Hash: c0180d97bac2a66d47209cbd137c1581 commit: 0cba229f49cba683ac1afbf0667b04ff7ed13bd4 Author: Evan Teran gmail com> AuthorDate: Fri Mar 18 03:13:44 2016 +0000 Commit: Evan Teran gmail com> CommitDate: Fri Mar 18 03:13:44 2016 +0000 URL: https://gitweb.gentoo.org/proj/vmware.git/commit/?id=0cba229f initial support for vmware-12 eclass/vmware-bundle.eclass | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/eclass/vmware-bundle.eclass b/eclass/vmware-bundle.eclass new file mode 100644 index 0000000..3b019e9 --- /dev/null +++ b/eclass/vmware-bundle.eclass @@ -0,0 +1,87 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +# @ECLASS: vmware-bundle.eclass +# @MAINTAINER: +# vmware@gentoo.org +# @AUTHOR: +# Matt Whitlock +# @BLURB: Provides extract functionality for vmware products bundles + +DEPEND="dev-libs/libxslt" + +vmware-bundle_extract-bundle-component() { + local bundle=${1:?} component=${2:?} dest=${3:-${2}} + cat > "${T}"/list-bundle-components.xsl <<-EOF + + + + + + + + + + + + + + EOF + local -i bundle_size=$(stat -L -c'%s' "${bundle}") + local -i bundle_manifestOffset=$(od -An -j$((bundle_size-36)) -N4 -tu4 "${bundle}") + local -i bundle_manifestSize=$(od -An -j$((bundle_size-40)) -N4 -tu4 "${bundle}") + local -i bundle_dataOffset=$(od -An -j$((bundle_size-44)) -N4 -tu4 "${bundle}") + local -i bundle_dataSize=$(od -An -j$((bundle_size-52)) -N8 -tu8 "${bundle}") + tail -c+$((bundle_manifestOffset+1)) "${bundle}" 2> /dev/null | head -c$((bundle_manifestSize)) | + xsltproc "${T}"/list-bundle-components.xsl - | + while read -r component_offset component_size component_name ; do + if [[ ${component_name} == ${component} ]] ; then + ebegin "Extracting '${component_name}' component from '$(basename "${bundle}")'" + vmware-bundle_extract-component "${bundle}" "${dest}" $((bundle_dataOffset+component_offset)) + eend + fi + done +} + +vmware-bundle_extract-component() { + local component=${1:?} dest=${2:-.} + local -i offset=${3} + cat > "${T}"/list-component-files.xsl <<-EOF + + + + + + + + + + + + + + + + EOF + local -i component_manifestOffset=$(od -An -j$((offset+9)) -N4 -tu4 "${component}") + local -i component_manifestSize=$(od -An -j$((offset+13)) -N4 -tu4 "${component}") + local -i component_dataOffset=$(od -An -j$((offset+17)) -N4 -tu4 "${component}") + local -i component_dataSize=$(od -An -j$((offset+21)) -N8 -tu8 "${component}") + tail -c+$((offset+component_manifestOffset+1)) "${component}" 2> /dev/null | + head -c$((component_manifestSize)) | xsltproc "${T}"/list-component-files.xsl - | + while read -r file_offset file_compressedSize file_uncompressedSize file_path ; do + if [[ ${file_path} ]] ; then + file_path="${dest}/${file_path}" + mkdir -p "$(dirname "${file_path}")" || die + if [[ ${file_compressedSize} -gt 0 ]] ; then + echo -n '.' + tail -c+$((offset+component_dataOffset+file_offset+1)) "${component}" 2> /dev/null | + head -c$((file_compressedSize)) | gzip -cd > "${file_path}" || die + else + echo -n 'x' + fi + fi + done + echo +}