# Copyright (c) 2017 The Container Linux by CoreOS Authors. All rights # reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # torcx_manifest.sh contains helper functions for creating, editing, and # reading torcx manifest files. # create_empty creates an empty torcx manfiest at the given path. function torcx_manifest::create_empty() { local path="${1}" jq '.' > "${path}" < "${path}" } # get_pkg_names returns the list of packages in a given manifest. Each package # may have one or more versions associated with it. # # Example: # pkg_name_arr=($(torcx_manifest::get_pkg_names "torcx_manifest.json")) function torcx_manifest::get_pkg_names() { local file="${1}" jq -r '.value.packages[].name' < "${file}" } # local_store_path returns the in-container-linux store path a given package + # version combination should exist at. It returns the empty string if the # package shouldn't exist on disk. function torcx_manifest::local_store_path() { local file="${1}" local name="${2}" local version="${3}" jq -r ".value.packages[] | select(.name == \"${name}\") | .versions[] | select(.version == \"${version}\") | .locations[] | select(.path).path" < "${file}" } # get_digest returns the cas digest for a given package version function torcx_manifest::get_digest() { local file="${1}" local name="${2}" local version="${3}" jq -r ".value.packages[] | select(.name == \"${name}\") | .versions[] | select(.version == \"${version}\") | .casDigest" < "${file}" } # get_digests returns the list of digests for a given package. function torcx_manifest::get_digests() { local file="${1}" local name="${2}" jq -r ".value.packages[] | select(.name == \"${name}\").versions[].casDigest" < "${file}" } # get_versions returns the list of versions for a given package. function torcx_manifest::get_versions() { local file="${1}" local name="${2}" jq -r ".value.packages[] | select(.name == \"${name}\").versions[].version" < "${file}" } # default_version returns the default version for a given package, or an empty string if there isn't one. function torcx_manifest::default_version() { local file="${1}" local name="${2}" jq -r ".value.packages[] | select(.name == \"${name}\").defaultVersion" < "${file}" } # sources_on_disk returns the list of source packages of all torcx images installed on disk function torcx_manifest::sources_on_disk() { local file="${1}" local torcx_pkg="" jq -r ".value.packages[].versions[] | select(.locations[].path).metaPackage" < "${file}" | while read torcx_pkg; do torcx_dependencies "${torcx_pkg}" | tr ' ' '\n' done } # Print the first level of runtime dependencies for a torcx meta-package. function torcx_dependencies() ( pkg=${1:?} ebuild=$(equery-${BOARD} w "${pkg}") function inherit() { : ; } . "${ebuild}" echo ${RDEPEND} )