From 2bd0276e7608bf2d16d523c4bdc5ecf399d97e31 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 23 Apr 2015 21:42:53 -0300 Subject: [PATCH] Print essential and build-essential packages Parse Packages file and print all packages needed for essential and build-essential. --- debsort.pl | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 debsort.pl diff --git a/debsort.pl b/debsort.pl new file mode 100644 index 0000000..1066656 --- /dev/null +++ b/debsort.pl @@ -0,0 +1,84 @@ +#!/usr/bin/env perl +# +# Copyright 2014 Thadeu Lima de Souza Cascardo +# +# This program 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 . +# + +use strict; +use warnings; + +open(PACKAGES, ") { + if (/^Package: ([0-9a-z-+.]+)/) { + $package = $1; + push @packages, $package; + } + if (/^Depends: (.*)/) { + add_depends($package, $1); + } + if (/^Priority: (.*)/) { + $priority{$package} = $1; + } + if (/^Essential: yes/) { + $essential{$package} = "yes"; + } +} + +close(PACKAGES); +close(SOURCES); + +my @pp = (); + +my @visit = (); + +for my $i (keys %essential) { + push @visit, $i; +} +push @visit, "build-essential"; + +while (@visit) { + my $n = pop @visit; + next if grep /^$n$/, @pp; + push @pp, $n; + my $l = $depends{$n}; + for my $d (@$l) { + if (!grep /^$d$/, @pp && !grep /^$d$/, @visit) { + push @visit, $d; + } + } +} + +for my $i (@pp) { + print "$i\n"; +} -- 2.20.1