View previous topic :: View next topic |
Author |
Message |
ecatmur Advocate
Joined: 20 Oct 2003 Posts: 3595 Location: Edinburgh
|
Posted: Sun Aug 14, 2005 5:53 pm Post subject: mono-rebuild.sh: rebuild broken Mono applications |
|
|
After updating *-sharp packages and other libraries with mono bindings, mono applications that use those libraries sometimes start to fail with errors like:
Code: | ** (/usr/lib/muine/muine.exe:8850): WARNING **: The following assembly referenced from /usr/lib/muine/muine.exe could not be loaded:
Assembly: dbus-sharp (assemblyref_index=13)
Version: 0.35.0.0
Public Key: 9eef2692033670f5
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/usr/lib/muine). |
What's needed is a rebuilding script like revdep-rebuild or perl-cleaner.
mono-rebuild.sh version 0 - please test and report back!
Dependencies: sys-apps/file, app-shells/bash, dev-lang/mono (of course).
Code: | #!/bin/bash
# mono-rebuild.sh
# Fixes errors like:
#
#** (/usr/lib/muine/muine.exe:8850): WARNING **: The following assembly referenced from /usr/lib/muine/muine.exe could not be loaded:
# Assembly: dbus-sharp (assemblyref_index=13)
# Version: 0.35.0.0
# Public Key: 9eef2692033670f5
#The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/usr/lib/muine).
#
shopt -s extglob
if [[ "$1" == @(-h|--help) ]]; then
cat <<END
$0: revdep-rebuild for mono.
Searches /usr for PE executables and tries to resolve assembly references in
all the standard places.
If an assembly reference cannot be found the owner is located and queued for
re-emerging.
Usage: $0 [ path-to-single-executable ]
END
exit
fi
is_windows_pe() {
case "$(file -b "$1")" in
"MS Windows PE"*) return 0;;
"PE executable for MS Windows"*) return 0;;
*) return 1;;
esac
}
can_resolve_assemblies() {
pe_exe="$1"
monodis --assemblyref "$pe_exe" \
| (
retval=0
while read tok ver; do
[[ "$tok" == +([[:digit:]]): \
&& "$ver" == "Version="* ]] || continue
ver="${ver#Version=}"
read name
name="${name#Name=}"
read junk; read junk key
key="$(echo "${key// }" | tr "[A-Z]" "[a-z]")"
# mscorlib is built in
[[ "$name" == mscorlib?(.dll) ]] && continue
# look in the gac
[[ -e /usr/lib/mono/gac/"${name}/${ver}__${key}/${name%.dll}.dll" ]] \
&& continue
# look in the dir of the PE
[[ -e "$(dirname "$pe_exe")/${name%.dll}.dll" ]] \
&& continue
# look in MONO_ASSEMBLIES
[[ -e "/usr/lib/${name%.dll}.dll" ]] \
&& continue
# look in MONO_PATH
IFS=: read -a expanded_MONO_PATH <<<"$MONO_PATH"
(( ${#expanded_MONO_PATH[@]} > 0 )) \
&& for dir in "${expanded_MONO_PATH[@]}"; do
[[ -e "$dir/${name%.dll}.dll" ]] && break
done \
&& continue
# not found
echo "${pe_exe}: cannot resolve ${name} ${ver} ${key}"
retval=1
done
exit $retval
)
}
pe_exe="$1"
if [[ -z "$pe_exe" ]]; then
tempdir="$HOME/.mono-rebuild"
[[ -d "$tempdir" ]] || mkdir "$tempdir"
[[ -d "$tempdir" ]] || exit "cannot create $tempdir"
find /usr -type f -name '*.exe' 2>/dev/null \
| while read exe; do
is_windows_pe "$exe" || continue
can_resolve_assemblies "$exe" >&2 && continue
echo "$exe"
done \
| while read path; do
grep -lx "obj ${path%/} [[:xdigit:]]\+ [[:digit:]]\+" \
/var/db/pkg/*/*/CONTENTS
done | while read x; do
x=${x#/var/db/pkg/}; x=${x%/CONTENTS}
echo "belongs to: $x" >&2
echo "$x"
done | sort | uniq >"$tempdir/EBUILDS"
if [[ -s "$tempdir/EBUILDS" ]]; then
emerge_ask="$([[ "$EUID" == 0 ]] && echo "--ask" || echo "--pretend")"
emerge -1v $emerge_ask $(sed -e 's/^/=/' "$tempdir/EBUILDS")
else
echo "All PE assemblies resolvable, nothing to do."
fi
exit
fi
if ! is_windows_pe "$pe_exe"; then
echo "$pe_exe: not a MS Windows PE executable."
exit 2
fi
can_resolve_assemblies "$pe_exe"
exit $? |
_________________ No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Last edited by ecatmur on Wed Aug 17, 2005 2:17 pm; edited 1 time in total |
|
Back to top |
|
|
latexer Retired Dev
Joined: 05 Mar 2003 Posts: 239 Location: NYC
|
Posted: Wed Aug 17, 2005 12:46 am Post subject: |
|
|
Hey!
This looks great! Something I've been meaning to get around to writing. Is there any chance you could look into actually integrating it somehow into revdep-rebuild though? Keeping things like this in one central tool, but extended for other realms of dependancy checking than native .so stuff would be a big help for things like this.
(It'd be especially nice to have tonight, since I just bumped all the *-sharp stuff for the new beta release, which changed assembly versions and will mean recompilation of monodevelop, new muine, etc for folks). _________________ overlays - Use at your own risk. File bug reports on this stuff and i'll kick you in the junk. Ask me before asking upstream if these fail. I mean it. No, really.
#gentoo-dotnet on freenode |
|
Back to top |
|
|
ecatmur Advocate
Joined: 20 Oct 2003 Posts: 3595 Location: Edinburgh
|
Posted: Wed Aug 17, 2005 2:55 pm Post subject: |
|
|
Hmm...
Well, revdep-rebuild certainly has things that'd be useful (rebuild reordering, sane interface, etc.) I'll have a look at modularising it; should be feasible (and quite interesting) but might take a little while, so don't expect a modularised revdep-rebuild immediately. _________________ No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS? |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|