Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | pkg_fix_deps(): change internal logic to increase efficiency and speed |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | cpt-6.3.x |
Files: | files | file ages | folders |
SHA3-256: |
5dfbf828f84f5a29442b0af2ec2a50b9 |
User & Date: | merakor 2022-02-15 02:03:47 |
Context
2022-02-15
| ||
02:06 | pkg_fix_deps(): change internal logic to increase efficiency and speed check-in: a6554fc9b7 user: merakor tags: trunk | |
02:03 | pkg_fix_deps(): change internal logic to increase efficiency and speed Closed-Leaf check-in: 5dfbf828f8 user: merakor tags: cpt-6.3.x | |
01:57 | Create new branch named "cpt-6.3.x" check-in: afc75d2081 user: merakor tags: cpt-6.3.x | |
Changes
Changes to src/cpt-lib.in.
︙ | ︙ | |||
615 616 617 618 619 620 621 622 623 624 625 626 627 628 | pkg_owner=$(grep "$@") pkg_owner=${pkg_owner%/*} pkg_owner=${pkg_owner##*/} set -f -- "$pkg_owner"; unset pkg_owner [ "$1" ] && printf '%s\n' "$1" } pkg_isbuilt() ( # Check if a package is built or not. read -r ver rel < "$(pkg_find "$1")/version" set +f for tarball in "$bin_dir/$1#$ver-$rel.tar."*; do | > > > > > > > > > > > > | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | pkg_owner=$(grep "$@") pkg_owner=${pkg_owner%/*} pkg_owner=${pkg_owner##*/} set -f -- "$pkg_owner"; unset pkg_owner [ "$1" ] && printf '%s\n' "$1" } pkg_owner_multi() { set +f [ "$3" ] || set -- "$1" "$2" "$sys_db"/*/manifest grep "$@" | while read -r pkg_owner; do pkg_owner=${pkg_owner%/*} pkg_owner=${pkg_owner##*/} printf '%s\n' "${pkg_owner##*/}" done } pkg_isbuilt() ( # Check if a package is built or not. read -r ver rel < "$(pkg_find "$1")/version" set +f for tarball in "$bin_dir/$1#$ver-$rel.tar."*; do |
︙ | ︙ | |||
925 926 927 928 929 930 931 | ;; esac done 2>/dev/null ||: } pkg_fix_deps_fullpath() { # Return the canonical path of libraries extracted by readelf. | | | > > | > | 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 | ;; esac done 2>/dev/null ||: } pkg_fix_deps_fullpath() { # Return the canonical path of libraries extracted by readelf. while read -r line _ rslv _; do [ "$line" = "$1" ] || continue case $rslv in ldd) out "$line" ;; *) out "$rslv" ;; esac done } pkg_fix_deps() { # Dynamically look for missing runtime dependencies by checking each binary # and library with either 'ldd' or 'readelf'. This catches any extra # libraries and or dependencies pulled in by the package's build suite. |
︙ | ︙ | |||
954 955 956 957 958 959 960 | dep_file=/dev/null fi # Generate a list of all installed manifests. pkg_name=$1 set +f; set -f -- "$sys_db/"*/manifest | > > > > > > > > > > > > > > > > | | | > > > | > | | < > > | < < | | | | < | | | | | | | | | | < | | | | | | | | | | | | | | | > > > | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | dep_file=/dev/null fi # Generate a list of all installed manifests. pkg_name=$1 set +f; set -f -- "$sys_db/"*/manifest # We create two separate files for storing dependency information. # # 'lddfile' is where we will be storing the output of ldd, so that we can # reference it later. # # 'dep_file_list' is where we will be listing the needed files which we will # be passing to grep. # lddfile=$(_tmp_create lddfile) dep_file_list=$(_tmp_create dfl) pkg_fix_deps_find() { # We run the similar command twice, might as well be a function. # Basically runs find on the package directory and executes the # given command. end=+; [ "$1" = ldd ] && end=';' # Get a list of binaries and libraries, false files will be found, # however it's faster to get 'ldd' to check them anyway than to filter # them out. # # We are terminating exec, so no worries. # shellcheck disable=2067 find "$pkg_dir/$pkg_name/" -type f -exec "$@" {} "$end" 2>/dev/null | sed 's/([^)]*) *$//' | sort -u } # Record all the dependencies in the 'lddfile'. This will include all # dependencies, including non-direct ones. Unless the user prefers ldd, # readelf will be used to filter the non-direct dependencies out. pkg_fix_deps_find ldd -- > "$lddfile" case "$elf_prog" in *readelf) pkg_fix_deps_find "$elf_prog" -d ;; *) cat "$lddfile" esac | while read -r dep; do # Skip lines containing 'ldd'. [ "${dep##*ldd*}" ] || continue case $dep in *NEEDED*\[*\] | *'=>'*) ;; *) continue; esac # readelf output: # 0x0000 (NEEDED) Shared library: [libc.so] dep=${dep##*\[} dep=${dep%%\]*} # Retrieve the fullpath of the library from our ldd buffer. case $elf_prog in *readelf) dep=$(pkg_fix_deps_fullpath "$dep" < "$lddfile") esac # ldd output: # libc.so => /lib/ld-musl-x86_64.so.1 dep=${dep#* => } dep=${dep% *} # Figure out which package owns the file. Skip file if it is owned # by the current package. This also handles cases where a '*-bin' # package exists on the system, so the package manager doesn't think # that the package we are building depends on the *-bin version of # itself, or any other renamed versions of the same software. pkg_owner -l "/${dep#/}\$" "$PWD/manifest" >/dev/null && continue out "/${dep#/}\$" done >> "$dep_file_list" # We write all the files into 'dep_file_list' so that we don't need to call # grep on our entire database manifest hundreds of times. pkg_owner_multi -lf "$dep_file_list" "$@" >> depends # Remove duplicate entries from the new depends file. # This removes duplicate lines looking *only* at the # first column. sort -uk1,1 -o depends depends 2>/dev/null ||: # Display a diff of the new dependencies against the old ones. |
︙ | ︙ |