Commit 7d13c2ae authored by James Larrowe's avatar James Larrowe Committed by Ed Reel

Improve ld_default package (#2908)

Remove ability to recognise symlinks (not needed)

Use $() instead of backticks

fix backslashed dollar signs
parent b66575ef
...@@ -2,54 +2,70 @@ require 'package' ...@@ -2,54 +2,70 @@ require 'package'
class Ld_default < Package class Ld_default < Package
description 'Select the default ld executable and check for libraries in #{CREW_LIB_PREFIX} first' description 'Select the default ld executable and check for libraries in #{CREW_LIB_PREFIX} first'
homepage 'https://github.com/skycocker/chromebrew' homepage 'https://github.com/skycocker/chromebrew/wiki/FAQ'
version '1.0' version '1.1'
source_url 'https://raw.githubusercontent.com/skycocker/chromebrew/93aa4dc4d9198e28d84dcf9d59b3ab6b6a94d92c/README.md' source_url 'file:///dev/null'
source_sha256 '3ec9c6f7ba6a138d07dfb4a372d562cd3ad558b58b6bd447c2dbb52e16b697a5' source_sha256 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
depends_on 'llvm' depends_on 'llvm'
def self.build def self.build
system "cat << 'EOF' > ld_default system "cat << 'EOF' > ld_default
#!/bin/bash #!/bin/bash
cd #{CREW_PREFIX}/bin
type=\$(file ld | cut -d' ' -f2 | tr -d '\\n') set -e
if [ \"\$type\" == \"ELF\" ]; then
current=\$(find . -inum $(ls -i ld 2> /dev/null | cut -d' ' -f1) 2> /dev/null | fgrep 'ld.' 2> /dev/null | cut -d/ -f2 2> /dev/null) mktmp=\$(mktemp -d)
else
slashes=\$(tr -dc '/' <<<'#{CREW_PREFIX}/bin/ld/' | wc -c) cd #{CREW_PREFIX}/bin
current=\$(tail -1 ld | cut -d'/' -f\${slashes} 2> /dev/null | cut -d' ' -f1 2> /dev/null)
fi type=\$(file ld | cut -d' ' -f2 | tr -d '\\n')
echo
echo \"Current default: \$current\" if [ \"\${type}\" == \"ELF\" ]; then
echo current=\$(find . -inum \$(ls -i ld | cut -d' ' -f1) | fgrep 'ld.')
echo 'Enter the ld default:' elif [ \"${type}\" == \"symbolic\" ]; then
echo 'b = ld.bfd' current=\$(basename \$(readlink ld))
echo 'g = ld.gold' else
echo 'l = ld.lld' current=\$(basename \$(tail -1 ld | cut -d' ' -f1))
echo '0 = Cancel' fi
while true; do
read default echo
case $default in echo \" Current default linker: \${current}\"
b) echo
current='ld.bfd' echo ' Enter the new default linker:'
break;; echo
g) echo ' b = ld.bfd'
current='ld.gold' echo ' g = ld.gold'
break;; echo ' l = ld.lld'
l) echo ' 0 = Cancel'
current='ld.lld' echo
break;;
0) while true; do
exit;; read default
*) case \${default} in
echo 'Please select from one of the options or enter 0 to cancel.' b)
esac new='ld.bfd'
done break;;
echo '#!/bin/bash' > /tmp/ld g)
echo '#{CREW_PREFIX}/bin/'$current' --library-path #{CREW_LIB_PREFIX} -rpath #{CREW_LIB_PREFIX} \"\$@\"' >> /tmp/ld new='ld.gold'
install -Dm755 /tmp/ld #{CREW_PREFIX}/bin/ld break;;
rm -f /tmp/ld l)
new='ld.lld'
break;;
0)
exit;;
*)
echo 'Please select from one of the options or enter 0 to cancel.'
echo
esac
done
echo '#!/bin/bash' > \${mktmp}/ld
echo \"\${new}\"' --library-path #{CREW_LIB_PREFIX} -rpath #{CREW_LIB_PREFIX} \"\$@\"' >> \${mktmp}/ld
install -Dm755 \${mktmp}/ld #{CREW_PREFIX}/bin/ld
rm -rf \${mktmp}
EOF" EOF"
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment