#!/usr/bin/perl =pod =head1 Name emprunecross - Identify cross dependencies installed by dpkg-cross =head1 Copyright and Licence Copyright (C) 2007 Neil Williams This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =cut use File::Basename; use Debian::DpkgCross; use Emdebian::Tools; use Term::ANSIColor qw(:constants); use strict; use warnings; use vars qw/ $arch %chain %prune $target_gnu_type $suite $list $status $success @cross %chain $crosslist $progname $string $cmd $dryrun $our_version $unpacked /; $dryrun = 0; $progname = basename($0); $our_version = &tools_version(); &read_config(); $arch = &get_architecture(); sub usageversion { print(STDERR </dev/null`; $string = "$res $status"; $chain{$res}++ if ($success eq $string); } $crosslist = `dpkg-query -W -f='\${Package} \${Status}\n' \'*-$arch-cross\'`; @cross = split(/\n/, $crosslist); foreach my $c (@cross) { next if (($c !~ / $status$/) and ($c !~ / $unpacked/)); $c =~ s/ $status$//; $c =~ s/ $unpacked//; chomp($c); next if (defined $chain{$c}); next if ($c =~ /^libc6.*$arch-cross/); $prune{$c}++; } if (scalar keys %prune > 0) { my $plural = (scalar keys %prune == 1) ? "package" : "packages"; print RED, "Removing $plural\n", RESET; if ($dryrun > 0) { $cmd = join("\n", sort keys %prune); print "$cmd\n"; exit(0); } $cmd = join(" ", sort keys %prune); system ("sudo dpkg -P $cmd"); } =head1 Description Removes or just prints the complete list of packages that have been installed by dpkg-cross (whether using dpkg-cross directly or via apt-cross or emdebian-tools) for the selected architecture or dpkg-cross default architecture. This functionality cannot just be merged into apt-cross because that would remove cross packages used by the Emdebian toolchain. =head1 Commands and options -a|--arch Override the dpkg-cross default architecture. -n|--dry-run|--simulate Only print the list, do not call 'sudo dpkg -P' =cut