Lines Matching +full:- +full:- +full:local
3 set -eu
6 : ${IPKDBG_CONF_HOST:=host.local}
11 : ${IPKDBG_WGET_OPTS:="--quiet"}
15 /bin/echo -e "$@" | fold >&2
19 /bin/echo -e "$@" | fold
23 /bin/echo -e "\033[1mNAME\033[0m"
24 /bin/echo -e "\tipkdbg - debug OpenBMC applications from an (internally) released firmware"
25 /bin/echo -e
26 /bin/echo -e "\033[1mSYNOPSIS\033[0m"
27 /bin/echo -e "\tipkdbg [-q] RELEASE FILE CORE [PACKAGE...]"
28 /bin/echo -e
29 /bin/echo -e "\033[1mDESCRIPTION\033[0m"
30 /bin/echo -e "\tRELEASE is the firmware release whose packages to install"
31 /bin/echo -e "\tFILE is the absolute path to the binary of interest in the target environment"
32 /bin/echo -e "\tCORE is an optional core file generated by FILE. Pass '-' for no core file"
33 /bin/echo -e "\tPACKAGES will be used to populate a temporary rootfs for debugging FILE"
34 /bin/echo -e
35 /bin/echo -e "\033[1mOPTIONS\033[0m"
36 /bin/echo -e "\t\033[1m-h\033[0m"
37 /bin/echo -e "\tPrint this help."
38 /bin/echo -e
39 /bin/echo -e "\t\033[1m-q\033[0m"
40 /bin/echo -e "\tQuit gdb once done. Intended for use in a scripting environment in combination"
41 /bin/echo -e "\twith a core file, as the backtrace will be printed as an implicit first command."
42 /bin/echo -e
43 /bin/echo -e "\033[1mENVIRONMENT\033[0m"
44 /bin/echo -e "\tThere are several important environment variables controlling the behaviour of"
45 /bin/echo -e "\tthe script:"
46 /bin/echo -e
47 /bin/echo -e "\t\033[1mIPKDBG_OPKG_CACHE\033[0m"
48 /bin/echo -e "\tA package cache directory for opkg. Defaults to empty, disabling the cache."
49 /bin/echo -e
50 /bin/echo -e "\t\033[1mIPKDBG_CONF_HOST\033[0m"
51 /bin/echo -e "\tHostname for access to opkg.conf over the web interface"
52 /bin/echo -e
53 /bin/echo -e "\tDefaults to '${IPKDBG_CONF_HOST}'"
54 /bin/echo -e
55 /bin/echo -e "\t\033[1mIPKDBG_CONF_MNT\033[0m"
56 /bin/echo -e "\tMount-point for access to opkg.conf"
57 /bin/echo -e
58 /bin/echo -e "\tDefaults to '${IPKDBG_CONF_MNT}'"
59 /bin/echo -e
60 /bin/echo -e "\t\033[1mIPKDBG_CONF_LOC\033[0m"
61 /bin/echo -e "\tGeo-location for access to opkg.conf"
62 /bin/echo -e
63 /bin/echo -e "\tDefaults to '${IPKDBG_CONF_LOC}'"
64 /bin/echo -e
65 /bin/echo -e "\t\033[1mIPKDBG_CONF_ROOT\033[0m"
66 /bin/echo -e "\tPath to the directory containing build artifacts, for access to opkg.conf"
67 /bin/echo -e
68 /bin/echo -e "\tDefaults to '${IPKDBG_CONF_ROOT}'"
69 /bin/echo -e
70 /bin/echo -e "\t\033[1mIPKDBG_CONF_USER\033[0m"
71 /bin/echo -e "\tUsername for access to opkg.conf over the web interface"
72 /bin/echo -e
73 /bin/echo -e "\tDefaults to \$USER ($USER)"
74 /bin/echo -e
75 /bin/echo -e "\t\033[1mIPKDBG_GDB\033[0m"
76 /bin/echo -e "\tThe gdb(1) binary to invoke. Automatically detected if unset."
77 /bin/echo -e
78 /bin/echo -e "\t\033[1mIPKDBG_WGET_OPTS\033[0m"
79 /bin/echo -e "\tUser options to pass to wget(1) when fetching opkg.conf. Defaults to"
80 /bin/echo -e "\t'$IPKDBG_WGET_OPTS'"
81 /bin/echo -e
82 /bin/echo -e "\t\033[1mIPKDBG_ZSTD\033[0m"
83 /bin/echo -e "\tThe zstd(1) binary to extract the compressed core dump. Automatically"
84 /bin/echo -e "\tdetected if unset."
85 /bin/echo -e
86 /bin/echo -e "\033[1mEXAMPLE\033[0m"
87 /bin/echo -e "\tipkdbg 1020.2206.20220208a \\"
88 /bin/echo -e "\t\t/usr/bin/nvmesensor - \\"
89 /bin/echo -e "\t\tdbus-sensors dbus-sensors-dbg"
101 shift $(expr $OPTIND - 1)
107 if [ "-" = "$1" ]
109 echo -
111 local src="$(realpath "$1")"
112 local dst="${src%.zst}"
114 command -v $IPKDBG_ZSTD > /dev/null
115 $IPKDBG_ZSTD --decompress --quiet --quiet --force -o "$dst" "$src" || true
126 if [ -n "$IPKDBG_GDB" ]
130 os_id=$(. /etc/os-release; echo ${ID}-${VERSION_ID})
132 rhel-8.6 | fedora*)
134 if [ -z "$(command -v $IPKDBG_GDB)" ]
144 IPKDBG_GDB=gdb-multiarch
145 if [ -z "$(command -v $IPKDBG_GDB)" ]
147 ipkdbg_error "Please install the gdb-multiarch package:"
149 ipkdbg_error "\tsudo dnf install gdb-multiarch"
155 IPKDBG_GDB=gdb-multiarch
156 if [ -z "$(command -v $IPKDBG_GDB)" ]
158 ipkdbg_error "Please Install the gdb-multiarch package"
160 ipkdbg_error "\tsudo apt install gdb-multiarch"
171 ipkdbg_info "Using gdb command ${IPKDBG_GDB} ($(command -v $IPKDBG_GDB))"
175 local offset=$1
176 local work=$2
177 tail -n+$offset $0 | base64 --decode - | tar -xz -C $work
181 local root=$1
182 local arch=$(uname -m)
183 local release_id=$(. /etc/os-release; echo $ID)
184 local release_version_id=$(. /etc/os-release; echo $VERSION_ID)
185 local p=${root}/bin/${arch}/${release_id}/${release_version_id}/opkg
186 if [ ! -x "$p" ]
198 if [ ! -f $0 ]
205 IPKDBG_WORK=$(mktemp -t --directory ipkdbg.XXX)
212 rm -rf $IPKDBG_WORK
223 local build=$1
224 local component="$2"
229 local build=$1
230 local component="$2"
235 local build=$1
236 local component="$2"
241 local build=$1
246 local path=$1
247 local output=$2
252 local build=$1
257 local url=$1
258 local output=$2
261 if ! wget --http-user=$IPKDBG_CONF_USER \
262 --ask-password \
263 --output-document $output \
273 local build=$1
278 local build=$1
279 local output=$2
280 local path="$(ipkdbg_opkg_conf_gen_cache $build)"
285 local build=$1
286 local output=$2
287 mkdir -p $(dirname $output)
290 local cache="$(ipkdbg_opkg_conf_gen_cache $build)"
291 mkdir -p $(dirname $cache)
301 local build=$1
302 ipkdbg_build_gen_path $build bmc_ipk/opkg-database.tar.xz
306 local build=$1
307 ipkdbg_build_gen_url ${build} bmc_ipk/opkg-database.tar.xz
311 local build=$1
312 ipkdbg_build_gen_cache $build opkg-database.tar.xz
316 local build=$1
317 local root=$2
318 local state=${root}/var/lib/opkg
319 local cache="$(ipkdbg_opkg_db_gen_cache $build)"
320 mkdir -p $state
321 if ! [ -f $cache ]
323 mkdir -p $(dirname $cache)
326 rm -f $cache
328 tar -xf $cache -C $state 2> /dev/null
329 mkdir -p ${root}/usr/local
330 ln -s ${root}/var ${root}/usr/local/var
335 $([ -z "$IPKDBG_OPKG_CACHE" ] ||
336 echo --cache-dir $IPKDBG_OPKG_CACHE --host-cache-dir) \
337 -V1 -f $IPKDBG_CONF -o $IPKDBG_ROOT $@
341 local core=$1
342 $IPKDBG_GDB --core $core -ex quit 2> /dev/null |
343 awk -F "[\`']" '/Core was generated by/ { print $2 }' |
344 awk -F " " '{ print $1 }' # Chop off the arguments, we only want the binary path
352 local pkg=$1
354 # Try appending -dbg and -src to the binary package name
355 extra_pkgs="$(ipkdbg_opkg_find ${pkg}-dbg) $(ipkdbg_opkg_find ${pkg}-src)"
358 if [ -z "$extra_pkgs" ]
362 extra_pkgs="$(ipkdbg_opkg_find ${pkg%-*}-dbg) $(ipkdbg_opkg_find ${pkg%-*}-src)"
370 if [ '-' = "$IPKDBG_FILE" -a '-' != "$IPKDBG_CORE" ]
379 if [ '-' != "$IPKDBG_CORE" ]
385 if [ -n "$IPKDBG_CORE_PKG" ]
393 if [ -z "$IPKDBG_PKGS" ]
395 ipkdbg_error "Unable to determine package-set to install, please specify" \
401 # Force installation of gcc-runtime-dbg to give us debug symbols for libstdc++
402 IPKDBG_PKGS="gcc-runtime-dbg $IPKDBG_PKGS"
404 if [ -n "$IPKDBG_OPKG_CACHE" ]
406 mkdir -p "$IPKDBG_OPKG_CACHE"
407 ipkdbg_opkg install --download-only $IPKDBG_PKGS
410 ipkdbg_opkg install $IPKDBG_PKGS | grep -vF 'Warning when extracting archive entry'
414 exec $IPKDBG_OPKG_BIN -f $IPKDBG_CONF -o $IPKDBG_ROOT \$@
418 PATH=${IPKDBG_BINS}:${PATH} $IPKDBG_GDB -q \
419 -iex "set solib-absolute-prefix $IPKDBG_ROOT" \
420 -iex "add-auto-load-safe-path $IPKDBG_ROOT" \
421 -iex "set directories $IPKDBG_ROOT" \
422 -iex "cd $IPKDBG_ROOT" \
423 $([ '-' = "$IPKDBG_CORE" ] || echo -ex bt) \
424 $([ 0 -eq $IPKDBG_OPT_QUIT ] || echo -ex quit) \
426 $([ '-' = "$IPKDBG_CORE" ] || echo $IPKDBG_CORE)