diff options
author | wheatdog <wheatdoge@gmail.com> | 2019-02-27 09:57:15 +0800 |
---|---|---|
committer | wheatdog <wheatdoge@gmail.com> | 2019-02-27 09:57:15 +0800 |
commit | 0c8c66c5bbeb23117027543a4ce37b7c4fe16f09 (patch) | |
tree | 52709a096d817112e2de219703c5df803d2992a1 | |
parent | 0580b6a833bc77e3221dafc26a196f27fbddcbab (diff) | |
download | aurutils-extra-0c8c66c5bbeb23117027543a4ce37b7c4fe16f09.tar.gz aurutils-extra-0c8c66c5bbeb23117027543a4ce37b7c4fe16f09.tar.zst aurutils-extra-0c8c66c5bbeb23117027543a4ce37b7c4fe16f09.zip |
Explicitly setting the roots of dependencies graph
Originally use head(), but there might be some cases
that we should explicitly setting the roots, or else
some of them might be pruned.
-rwxr-xr-x | aur-fetch-all | 2 | ||||
-rwxr-xr-x | aur-prunedep | 33 |
2 files changed, 14 insertions, 21 deletions
diff --git a/aur-fetch-all b/aur-fetch-all index 19b9b74..2b2e1c2 100755 --- a/aur-fetch-all +++ b/aur-fetch-all @@ -132,7 +132,7 @@ pacconf --repo-list | complement <(echo "$db_name") | paste -s -d ' ' >repos xargs --arg-file=repos pacman -Slq | sort | uniq >installable_packages -aur prunedep -f depends_0 -e installable_packages >depends +aur prunedep -f depends_0 -e installable_packages -s "$aurpkg_file" >depends # $1 pkgname $2 pkgbase $3 pkgver cut -f2 --complement depends | sort -u >pkginfo diff --git a/aur-prunedep b/aur-prunedep index 9bb5722..d17d194 100755 --- a/aur-prunedep +++ b/aur-prunedep @@ -48,9 +48,7 @@ class PackageGraph: self.traverse_and_print_without_sub_reccur(child_info, nodes_color, exclude_pkgs) nodes_color[node] = 2 - def traverse_and_print_without_sub(self, exclude_pkgs): - head_nodes = self.head() - + def traverse_and_print_without_sub(self, exclude_pkgs, start_pkgs): ''' 0: white, not visited 1: grey, being visited @@ -61,31 +59,20 @@ class PackageGraph: for node in self.nodes: nodes_color[node] = 0 - for node in head_nodes: + for node in start_pkgs: for child_info in self.adjlist[node]: self.traverse_and_print_without_sub_reccur(child_info, nodes_color, exclude_pkgs) - def head(self): - candidates = set() - for node in self.nodes: - candidates.add(node) - - for node in self.nodes: - for child_info in self.adjlist[node]: - child = child_info[0] - if child.endswith('*'): - continue - if child in candidates: - candidates.remove(child) - - return candidates - def get_args(): parser = argparse.ArgumentParser(prog='aur-prunedep') parser.add_argument("-e", "--exclude-file", required=True, type=str, help='file list package name that need to filter out line by line') + parser.add_argument("-s", "--start-file", + required=True, + type=str, + help='file list package names that are root of dependency graph') parser.add_argument("-f", "--depends-file", required=True, type=str, @@ -99,8 +86,14 @@ def main(args): line = line.strip() exclude_pkgs.add(line) + start_pkgs = set() + with open(args.start_file) as f: + for line in f: + line = line.strip() + start_pkgs.add(line) + graph = PackageGraph(args.depends_file) - graph.traverse_and_print_without_sub(exclude_pkgs) + graph.traverse_and_print_without_sub(exclude_pkgs, start_pkgs) if __name__ == '__main__': main(get_args()) |