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