list-dependencies.sh (1702B)
1#!/bin/sh -e 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20 21## 22## @fn list-dependencies.sh 23## 24## Lists the Alpine Linux package names for all library dependencies of the 25## given binaries. Each package is only listed once, even if multiple binaries 26## provided by the same package are given. 27## 28## @param ... 29## The full paths to all binaries being checked. 30## 31 32while [ -n "$1" ]; do 33 34 # For all non-Guacamole library dependencies 35 ldd "$1" | grep -v 'libguac' | awk '/=>/{print $(NF-1)}' \ 36 | while read LIBRARY; do 37 38 # List the package providing that library, if any 39 apk info -W "$LIBRARY" 2> /dev/null \ 40 | grep 'is owned by' | grep -o '[^ ]*$' || true 41 42 done 43 44 # Next binary 45 shift 46 47# Strip the "-VERSION" suffix from each package name, listing each resulting 48# package uniquely ("apk add" cannot handle package names that include the 49# version number) 50done | sed 's/\(.*\)-[0-9]\+\..*$/\1/' | sort -u 51