diff options
author | Erich Eckner <git@eckner.net> | 2018-11-22 11:30:18 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-11-22 11:30:18 +0100 |
commit | 9cf7c0dbf8331cbe2e0d2081d1e754d7434735f7 (patch) | |
tree | 1ef5a5c2213bf4a6e9822da9a99ec1e9104f131c /extract-link-dependencies | |
parent | f55587e9f0e115cfe7353dbe9d4feb43ba4c26f9 (diff) | |
download | devops-9cf7c0dbf8331cbe2e0d2081d1e754d7434735f7.tar.xz |
extract-link-dependencies new
Diffstat (limited to 'extract-link-dependencies')
-rwxr-xr-x | extract-link-dependencies | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/extract-link-dependencies b/extract-link-dependencies new file mode 100755 index 0000000..c229006 --- /dev/null +++ b/extract-link-dependencies @@ -0,0 +1,186 @@ +#!/bin/sh + +case $(hostname) in + 'rechenknecht') # on the master mirror + tmp_dir=$( + readlink -e "/tmp/${0##*/}."* || \ + mktemp -d "${0##*/}.XXXXXXXX" --tmpdir=/tmp + ) + cd "${tmp_dir}" + checksum=$( + sha512sum "$0" | \ + awk '{print $1}' + ) + for pkgfile in /srv/arch-mirror/arch/arch/archlinux32/pool/*-i686.pkg.tar.xz; do + if [ -f "${pkgfile##*/}.so.needs" ]; then + continue + fi + mkdir x + bsdtar -xf "$pkgfile" -C x + find 'x' \ + -name 'opt' -prune , \ + -type f \ + -exec objdump -x '{}' \; 2>/dev/null | \ + sed ' + /^architecture:.* i386:x86-64, /,/^architecture:.* i386:x86-32, / d + /\sNEEDED\s/ { + s/^\s*\S\+\s\+\(\S\+\)\(\s.*\)\?$/\1/ + /\.c32$/d + s,^.*/,, + t + } + /^Version References:$/,/^$/ { + /^\s*required from / { + s/^\s*required from \(\S\+\):\s*$/'"${checksum}"'\1/ + T end + h + d + } + s/^\s*\(0x[0-9a-fA-F]\+\)\s\+0x[0-9a-fA-F]\+\s\+[0-9]\+\s\+\(\S\+\)$/\2-\1/ + T end + G + s/^\(\S\+\)\n'"${checksum}"'\(\S\+\)$/\2-\1/ + t + } + :end + d + ' | \ + sort -u > \ + "${pkgfile##*/}.so.needs" + sed -i ' + /^\(libav.*\.so\)\.[0-9]\+$/ { + :a + N + s/^\(libav.*\.so\)\(\.[0-9]\+\)\?\n\1\.[0-9]\+$/\1/ + t a + P + D + } + ' "${pkgfile##*/}.so.needs" + find 'x' \ + -name 'opt' -prune , \ + -type f \ + -printf "${checksum}"'%f\n' \ + -exec objdump -x '{}' \; 2>/dev/null | \ + sed ' + /^architecture:.* i386:x86-64, /,/^architecture:.* i386:x86-32, / d + /^'"${checksum}"'/ { + h + d + } + /\sSONAME\s/ { + s/^\s*\S\+\s\+\(\S\+\)\s.*$/\1/ + t + } + /^Version definitions:$/,/^$/ { + s/^[0-9]\+\s\+0x[0-9a-fA-F]\+\s\+\(0x[0-9a-fA-F]\+\)\s\+\(\S\+\)$/\2-\1/ + T end + G + s/^\(\S\+\)\n'"${checksum}"'\(\S\+\)$/\2-\1/ + t + } + :end + d + ' | \ + sort -u >> \ + "${pkgfile##*/}.so.provides" + rm -rf --one-file-system x + printf . + done + ;; + 'buildmaster.archlinux32.org') # on the buildmaster + cd ~/builder + . lib/load-configuration + mysql_load_min_and_max_versions + { + printf 'SET @link_dep_id = (' + printf 'SELECT `dependency_types`.`id`' + printf ' FROM `dependency_types`' + printf ' WHERE `dependency_types`.`name`="link"' + printf ');' + printf 'CREATE TEMPORARY TABLE `x` (' + printf '`it` VARCHAR(128),' + printf '`kind` VARCHAR(16),' + printf '`pkgname` VARCHAR(64),' + printf '`epoch` MEDIUMINT,' + printf '`pkgver` VARCHAR(64),' + printf '`pkgrel` MEDIUMINT,' + printf '`spr_total` VARCHAR(8),' + printf '`sub_pkgrel` MEDIUMINT,' + printf '`architecture` VARCHAR(4),' + printf 'UNIQUE KEY `content`(`it`,`kind`,`pkgname`,`epoch`,`pkgver`,`pkgrel`,`sub_pkgrel`,`architecture`)' + printf ');\n' + printf 'LOAD DATA LOCAL INFILE "../so-todos" INTO TABLE `x`;\n' + printf 'INSERT IGNORE INTO `install_targets`(`name`) SELECT `x`.`it` FROM `x`;\n' + printf 'SELECT row_count();\n' + printf 'INSERT IGNORE INTO `install_target_providers`(' + printf '`package`,' + printf '`install_target`,' + printf '`version`' + printf ') SELECT ' + printf '`binary_packages`.`id`,' + printf '`install_targets`.`id`,' + printf '%s' \ + "${min_version_id}" + printf ' FROM `x`' + printf ' JOIN `install_targets`' + printf ' ON `x`.`it`=`install_targets`.`name`' + printf ' AND `x`.`kind`="provides"' + printf ' JOIN `architectures`' + printf ' ON `x`.`architecture`=`architectures`.`name`' + mysql_join_architectures_binary_packages + printf ' AND `binary_packages`.`pkgname`=`x`.`pkgname`' + printf ' AND `binary_packages`.`epoch`=`x`.`epoch`' + printf ' AND `binary_packages`.`pkgver`=`x`.`pkgver`' + printf ' AND `binary_packages`.`pkgrel`=`x`.`pkgrel`' + printf ' AND `binary_packages`.`sub_pkgrel`=`x`.`sub_pkgrel`' + printf ' AND (`binary_packages`.`sub_pkgrel_omitted` = (`x`.`spr_total`=""));' + printf 'SELECT row_count();' + for version_info in \ + "${min_version_id},\">=\"" \ + "${max_version_id},\"<\""; do + printf 'INSERT IGNORE INTO `dependencies` (' + printf '`dependent`,' + printf '`depending_on`,' + printf '`dependency_type`,' + printf '`version`,' + printf '`version_relation`) SELECT ' + printf '`binary_packages`.`id`,' + printf '`install_targets`.`id`,@link_dep_id,%s' \ + "${version_info}" + printf ' FROM `x`' + printf ' JOIN `install_targets`' + printf ' ON `x`.`it`=`install_targets`.`name`' + printf ' AND `x`.`kind`="needs"' + printf ' JOIN `architectures` ON `x`.`architecture`=`architectures`.`name`' + mysql_join_architectures_binary_packages + printf ' AND `binary_packages`.`pkgname`=`x`.`pkgname`' + printf ' AND `binary_packages`.`epoch`=`x`.`epoch`' + printf ' AND `binary_packages`.`pkgver`=`x`.`pkgver`' + printf ' AND `binary_packages`.`pkgrel`=`x`.`pkgrel`' + printf ' AND `binary_packages`.`sub_pkgrel`=`x`.`sub_pkgrel`' + printf ' AND (`binary_packages`.`sub_pkgrel_omitted` = (`x`.`spr_total`=""));' + printf 'SELECT row_count();' + done + } | \ + mysql buildmaster + ;; + *) # on some intermediate box, e.g. on nlopc43 + ssh rechenknecht ' + cd /tmp/'"${0##*/}"'.* + ls | \ + sed '"'"' + s/^\(\S\+\)-\(\([^-:]\+\):\)\?\([^-:]\+\)-\([^-.]\+\)\(\.\([0-9]\+\)\)\?-\([^-]\+\)\.pkg\.tar\.xz\.so\.\(needs\|provides\)$/\0 \9 \1 \3 \4 \5 \6 \7 \8/ + t + d + '"'"' | \ + while read -r f r; do + sed " + s/\$/ $r/ + " "$f" + done' | \ + pv --line-mode | \ + tr ' ' '\t' | \ + ssh buildmaster 'tee so-todos | wc -l' + ;; +esac |