#!/usr/bin/env bash
#
#   Script to install host system binaries along with required libraries.
#
#   Copyright (C) 2012-2013 Jo-Philipp Wich <jow@openwrt.org>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

DIR="$1"; shift

_cp() {
	cp ${VERBOSE:+-v} -L "$1" "$2" || {
		echo "cp($1 $2) failed" >&2
		exit 1
	}
}

_md() {
	mkdir ${VERBOSE:+-v} -p "$1" || {
		echo "mkdir($1) failed" >&2
		exit 2
	}
}

_ln() {
	ln ${VERBOSE:+-v} -sf "$1" "$2" || {
		echo "ln($1 $2) failed" >&2
		exit 3
	}
}

for LDD in ${PATH//://ldd }/ldd; do
	"$LDD" --version >/dev/null 2>/dev/null && break
	LDD=""
done

[ -n "$LDD" -a -x "$LDD" ] || LDD=

for BIN in "$@"; do
	[ -n "$BIN" -a -x "$BIN" -a -n "$DIR" ] || {
		echo "Usage: $0 <destdir> <executable> ..." >&2
		exit 1
	}

	[ ! -d "$DIR/bundled/lib" ] && {
		_md "$DIR/bundled/lib"
		_md "$DIR/bundled/usr"
		_ln "../lib" "$DIR/bundled/usr/lib"
	}

	LDSO=""

	echo "Bundling ${BIN##*/}"
	[ -n "$LDD" ] && {
		for token in $("$LDD" "$BIN" 2>/dev/null); do
			case "$token" in */*.so*)
				case "$token" in
					*ld-*.so*) LDSO="${token##*/}" ;;
					*) echo " * lib: ${token##*/}" ;;
				esac

				dest="$DIR/bundled/lib/${token##*/}"
				ddir="${dest%/*}"

				[ -f "$token" -a ! -f "$dest" ] && {
					_md "$ddir"
					_cp "$token" "$dest"
				}
			;; esac
		done
	}

	_md "$DIR"

	# is a dynamically linked executable
	if [ -n "$LDSO" ]; then
		_cp "$BIN" "$DIR/bundled/${BIN##*/}"

		RUN="${LDSO#ld-}"; RUN="run-${RUN%%.so*}.sh"

		[ -x "$DIR/bundled/$RUN" ] || {
			cat <<-EOF > "$DIR/bundled/$RUN"
				#!/usr/bin/env bash
				dir="\$(dirname "\$0")"
				bin="\$(basename "\$0")"
				exec -a "\$0" "\$dir/bundled/lib/$LDSO" --library-path "\$dir/bundled/lib" "\$dir/bundled/\$bin" "\$@"
			EOF
			chmod ${VERBOSE:+-v} 0755 "$DIR/bundled/$RUN"
		}

		_ln "./bundled/$RUN" "$DIR/${BIN##*/}"

	# is a static executable or non-elf binary
	else
		[ -n "$LDD" ] && echo " * not dynamically linked"
		_cp "$BIN" "$DIR/${BIN##*/}"
	fi
done
form>
</td></tr></table>
<div class='path'>path: <a href='/cgit/cloud-email/mitmproxy/tree/?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>root</a>/<a href='/cgit/cloud-email/mitmproxy/tree/web?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>web</a>/<a href='/cgit/cloud-email/mitmproxy/tree/web/src?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>src</a>/<a href='/cgit/cloud-email/mitmproxy/tree/web/src/js?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>js</a>/<a href='/cgit/cloud-email/mitmproxy/tree/web/src/js/components?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>components</a>/<a href='/cgit/cloud-email/mitmproxy/tree/web/src/js/components/FlowTable?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>FlowTable</a>/<a href='/cgit/cloud-email/mitmproxy/tree/web/src/js/components/FlowTable/FlowRow.jsx?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>FlowRow.jsx</a></div><div class='content'>blob: 7961d502633a7e23272e65380cdca478359eac2a (<a href='/cgit/cloud-email/mitmproxy/plain/web/src/js/components/FlowTable/FlowRow.jsx?id=7fe09f4d26e604db9d3e7f9868b3f0da0b3a6406'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
<a id='n19' href='#n19'>19</a>
<a id='n20' href='#n20'>20</a>
<a id='n21' href='#n21'>21</a>
<a id='n22' href='#n22'>22</a>
<a id='n23' href='#n23'>23</a>
<a id='n24' href='#n24'>24</a>
<a id='n25' href='#n25'>25</a>
<a id='n26' href='#n26'>26</a>
<a id='n27' href='#n27'>27</a>
<a id='n28' href='#n28'>28</a>
<a id='n29' href='#n29'>29</a>
<a id='n30' href='#n30'>30</a>
<a id='n31' href='#n31'>31</a>
</pre></td>
<td class='lines'><pre><code></code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2026-01-27 11:06:56 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
