|
| 1 | +# |
| 2 | +# Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved. |
| 3 | +# |
| 4 | + |
| 5 | +# This script downloads debian packages. |
| 6 | +# It installs libc6-dev package (which is dev version of libc) into $UTBOT_ALL/debian-libc-dev-install and other packages into $UTBOT_ALL/debs-install |
| 7 | + |
| 8 | +set -e |
| 9 | +set -o pipefail |
| 10 | + |
| 11 | +# Downloading apt-rdepends tool which can get all the dependencies for a package |
| 12 | +apt-get update && apt-get -y --no-install-recommends install apt-rdepends && apt-get update |
| 13 | +rm -rf /tmp/debian_dependencies && mkdir -p /tmp/debian_dependencies && cd /tmp/debian_dependencies |
| 14 | +# expand_aliases is used to support alias command properly in bash script |
| 15 | +shopt -s expand_aliases |
| 16 | +# A grep command which clears out the output of apt-rdepends |
| 17 | +alias grepdepends='grep -v "^ " | grep -v "^libc-dev$" | grep -v "^debconf-2.0$" | grep -v "^libc6$" | grep -v "^libunwind8-dev$" | grep -v "^awk$"' |
| 18 | +# Get all the dependencies of utbot |
| 19 | +apt-rdepends libsqlite3-dev libgoogle-perftools-dev libssl-dev python3-pip gzip make gcc-9 g++-9 | grepdepends > all.txt |
| 20 | +# Get all the dependencies of libc6-dev |
| 21 | +apt-rdepends libc6-dev | grepdepends > debian-libc-dev.txt |
| 22 | +# Get all the dependencies of utbot except all the dependencies of libc6-dev |
| 23 | +diff --new-line-format="" --unchanged-line-format="" <(sort all.txt) <(sort debian-libc-dev.txt) > all_without_libc-dev.txt || : |
| 24 | + |
| 25 | +# A function which downloads all the dependencies from text file and extracts them. |
| 26 | +# Prerequisites: file path/to/file.txt exists |
| 27 | +# Arguments: |
| 28 | +# $1 = path/to/file The first argument is a path to a file without the .txt extension |
| 29 | +# The extracted packages will be located in $UTBOT_ALL/path/to/file-install directory |
| 30 | +get_debian_packages() { |
| 31 | + # Create a directory for .deb packages |
| 32 | + rm -rf $1 && mkdir -p $1 && cd $1 |
| 33 | + # Download .deb packages |
| 34 | + apt-get download $(cat ../$1.txt) |
| 35 | + cd .. |
| 36 | + |
| 37 | + # Extract all the .deb packages into $UTBOT_ALL/$1-install directory |
| 38 | + for filename in $1/*.deb; do |
| 39 | + dpkg-deb -x "$filename" $UTBOT_ALL/$1-install |
| 40 | + done |
| 41 | +} |
| 42 | + |
| 43 | +# Get all packages except libc6-dev |
| 44 | +get_debian_packages all_without_libc-dev |
| 45 | +rm -rf $UTBOT_ALL/debs-install |
| 46 | +mv $UTBOT_ALL/all_without_libc-dev-install $UTBOT_ALL/debs-install |
| 47 | +# Get libc6-dev package and it's dependencies |
| 48 | +get_debian_packages debian-libc-dev |
| 49 | + |
| 50 | +# Creating links to the current versions of gcc and python |
| 51 | +cd $UTBOT_ALL/debs-install/usr/bin |
| 52 | +ln -s python3 python |
| 53 | +ln -s gcov-9 gcov |
| 54 | +ln -s g++-9 g++ |
| 55 | +ln -s gcc-9 gcc |
| 56 | + |
| 57 | +# Setup python packages |
| 58 | +pip3 install --target=$UTBOT_ALL/debs-install/usr/local/lib/python3.4/dist-packages/ --ignore-installed typing |
0 commit comments