This file is indexed.

/usr/bin/pkgkde-override-sc-dev-latest is in pkg-kde-tools 0.15.28ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#!/usr/bin/perl

# Copyright (C) 2010 Modestas Vainius <modax@debian.org>
#
# 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 <http://www.gnu.org/licenses/>

=head1 NAME

pkgkde-override-sc-dev-latest - loosen kde-sc-dev-latest Break restrictions

=head1 SYNOPSIS

B<pkgkde-override-sc-dev> [B<-b>I<base_version>] [B<-v>I<version>]

=head1 DESCRIPTION

B<pkgkde-override-sc-dev-lastest> is a helper utility which can be used to
generate a dummy I<kde-sc-dev-latest> package without I<Breaks> field that is
present in the original version. Original I<kde-sc-dev-latest> package is used
to force KDE Software Compilation modules to be built against the latest
version of the KDE Development Platform modules without bumping versions of
a bunch build dependencies for each KDE SC module. However, while
original I<kde-sc-dev-latest> does not cause problems when building in clean
chroots, the restrictions imposed by its I<Breaks> field might be undesirable
on the maintainer system when:

=over 4

=item *

the maintainer wants to (test)build KDE module version X.Y.A against KDE
Development Platform X.Y.B where (A > B);

=item *

the maintainer builds a new upstream version of the some KDE Development
Platform module on the system that has an old version of some KDE Development
Platform packages installed. For example, even if kdepimlibs does not build
depend on kdebase-workspace-dev, original I<kde-sc-dev-latest> may prevent
kdepimlibs X.Y.A to be built on the system which has kdebase-workspace X.Y.B
(where A > B) installed.

=back

By default, B<pkgkde-override-sc-dev-latest> generates a dummy
I<kde-sc-dev-latest> package in the current working directory that is based on the
current C<candidate> version of the original I<kde-sc-dev-latest> (as per
apt-cache policy). You may specify a base version with the I<-b> option. The
resulting dummy I<kde-sc-dev-latest> override package will have
C<I<base_version>+override> as its version unless another one is specified with
I<-v> option. Once the package is generated, you can install it like:

  # dpkg --install kde-sc-dev_<version>+override_all.deb

=head1 OPTIONS

=over 4

=item B<-b>I<base_version>, B<--basever>=I<base_version>

The version of the original I<kde-sc-dev-latest> package to base an override
package on. It must be available in the APT database on the system. You may
also pass special value C<latest> to select the latest available version in the
APT database. If you specify C<priority>, the latest version with the highest
priority will be selection. By default (if this option is not specified),
candidate version is selected

=item B<-v>I<version>, B<--version>=I<version>

Generate an override package with the specified C<I<version>+override> rather
than default C<I<base_version>+override> version.

=back

=head1 AUTHOR

Modestas Vainius <modax@debian.org>

=cut

use warnings;
use strict;
use File::Temp;
use File::Basename qw(basename);
use Getopt::Long;
use Cwd qw(cwd);

my $APT_CACHE = `which apt-cache`; chomp $APT_CACHE;
my $DPKG_GENCONTROL = `which dpkg-gencontrol`; chomp $DPKG_GENCONTROL;
my $DPKG_DEB = `which dpkg-deb`; chomp $DPKG_DEB;
my $DPKG_NAME = `which dpkg-name`; chomp $DPKG_NAME;

sub error {
    my $format = shift;
    print STDERR sprintf(basename($0) . ": error ". $format, @_), "\n";
    exit 1;
}

sub info {
    my $format = shift;
    print STDERR sprintf(basename($0) . ": info ". $format, @_), "\n";
}

sub syserr {
    my $format = shift;
    error("$format: $!", @_);
}

sub check_environment {
    unless (-x $APT_CACHE) {
        error('`apt-cache` from the apt package is needed');
    }
    unless (-x $DPKG_GENCONTROL) {
        error('`dpkg-gencontrol` from the dpkg-dev package is needed');
    }
    unless (-x $DPKG_DEB) {
        error('`dpkg-deb` from the dpkg-dev package is needed');
    }
    unless (-x $DPKG_NAME) {
        error('`dpkg-name` from the dpkg-dev package is needed');
    }
}

sub get_apt_policy {
    my $package = shift;
    my %result;
    my $versions;
    my $ver;
    open (APT_CACHE, "LC_ALL=C $APT_CACHE policy $package |") or
        syserr("unable to run apt-cache");
    while (<APT_CACHE>) {
        chop;
        if (m/^  Candidate: (\S+)$/) {
            $result{candidate} = $1 unless $1 =~ /\(none\)/;
        } elsif (m/^  Version table/) {
            $versions = {};
        } elsif (defined $versions) {
            if (/^ [ *]{3} (\S+)/) {
                $ver = $1;
                push @{$result{byversion}}, $ver;
            } elsif (defined $ver && /^     \s\s*(\d+)/) {
                if (!exists $versions->{$ver} || $1 > $versions->{$ver}) {
                    $versions->{$ver} = $1;
                }
            } else {
                $ver = undef;
            }
        }
    }
    close APT_CACHE;

    # By priority
    use sort 'stable';
    $result{bypriority} =
        [ sort { -($versions->{$a} <=> $versions->{$b}) } keys %$versions ];
    no sort 'stable';

    $result{versions} = $versions;

    return \%result;
}

sub get_apt_show {
    my ($package, $version) = @_;
    open (APT_CACHE, "LC_ALL=C $APT_CACHE show $package |") or
        syserr("unable to run apt-cache");
    my %fields;
    my $field;
    while (<APT_CACHE>) {
        chop;
        if (m/^(\S+):\s*(.*)$/) {
            $field = $1;
            if ($field eq "Package") {
                if (exists $fields{Version} && $fields{Version} eq $version) {
                    return \%fields;
                } else {
                    %fields = ();
                }
            }
            $fields{$field} = $2;
        } elsif (defined $field && m/^(\s.*)$/) {
            $fields{$field} .= "\n" . $_;
        } elsif (! m/^\s*$/) {
            error("problem while parsing apt-cache show output, line $.");
        }
    }
    close APT_CACHE;

    if (exists $fields{Version} && $fields{Version} eq $version) {
        return \%fields;
    } else {
        return ();
    }
}

sub get_maintainer {
    my $maintlogin;
    my $maintname = $ENV{DEBFULLNAME} || $ENV{NAME};
    my $maintemail = $ENV{DEBEMAIL};

    my ($login, $passwd, $uid, $gid,
        $quota, $comment, $gcos, $dir, $shell, $expire) = getpwuid($<);
    $maintlogin = $login || $uid || "unknown";
    unless ($maintname) {
        my @maintname = split(/,/, $comment);
        $maintname = $maintname[0] || "Unknown name";
    }
    unless ($maintemail) {
        $maintemail = "$maintlogin\@localhost";
    }
    return "$maintname <$maintemail>";
}


check_environment();

my $opt_basever;
my $opt_version;
if (!GetOptions("b|basever=s" => \$opt_basever,
                "v|version=s" => \$opt_version)) {
    exit 2;
}

my $policy = get_apt_policy("kde-sc-dev-latest");
error("there no versions of kde-sc-dev-latest available in the APT database")
    unless %{$policy->{versions}};

if (! $opt_basever) {
    $opt_basever = $policy->{candidate};
    $opt_basever = $policy->{bypriority}->[0] unless $opt_basever;
} elsif ($opt_basever eq "latest") {
    $opt_basever = $policy->{byversion}->[0];
} elsif ($opt_basever eq "priority") {
    $opt_basever = $policy->{bypriority}->[0];
}

if ($opt_basever && ! exists $policy->{versions}{$opt_basever}) {
    error("kde-sc-dev-latest version $opt_basever is not available in the APT database");
}

unless ($opt_version) {
    $opt_version = $opt_basever;
}
$opt_version .= "+override";

my $fields = get_apt_show("kde-sc-dev-latest", $opt_basever);
unless (%$fields) {
    error("no kde-sc-dev-latest version $opt_basever in the APT database");
}

info "Basing custom kde-sc-dev-latest package on the version %s ...", $opt_basever;

my $maintainer = get_maintainer();
my $date = `date -R`;
chop $date;
my $curdir = cwd();
my $dir = File::Temp->newdir("kde-sc-dev-latest-override.XXXXXX", CLEANUP => 1);
chdir $dir or syserr("unable to change directory to ". $dir->filename);
mkdir "debian" or syserr("unable to create debian subdirectory");

# Write control
open(CONTROL, ">", "debian/control") or
    syserr("unable to create control file");
print CONTROL <<EOF;
Source: kde-sc-dev-latest-override
Section: kde
Priority: optional
Maintainer: $maintainer
Standards-Version: 3.8.4

EOF

for my $field (qw{Package Architecture Pre-Depends
                  Depends Suggests Recommends})
{
    if (exists $fields->{$field}) {
        print CONTROL $field, ": ", $fields->{$field}, "\n";
    }
}

print CONTROL <<EOF;
Description: override for the kde-sc-dev-latest $opt_basever
 This package is based on the original kde-sc-dev-latest package
 version $opt_basever.
 .
 The purpose of this package is to loosen restrictions imposed by the Breaks
 field of the original package, i.e. permit building KDE SC packages when
 non-latest versions of KDE Development Platform packages are installed on the
 system. Therefore, this package has the same control fields as original except
 that "Breaks" field is not present.
 .
 This package was generated with the pkgkde-override-sc-dev-latest utility on
 $date.
EOF

close CONTROL;

# Write changelog
open(CHANGELOG, ">", "debian/changelog") or
    syserr("unable to create changelog file");
print CHANGELOG "kde-sc-dev-latest-override (", $opt_version, ") dummy; urgency=low", "\n";
print CHANGELOG "\n";
print CHANGELOG "  * kde-sc-dev-latest override (without Breaks) for version ",
                $opt_basever, ".", "\n";
print CHANGELOG "\n";
print CHANGELOG " -- ", $maintainer, "  ", $date, "\n";
close CHANGELOG;

# Generate binary control and create deb
mkdir "debian/tmp" or syserr("unable to create debian/tmp subdirectory");
mkdir "debian/tmp/DEBIAN" or syserr("unable to create debian/tmp/DEBIAN subdirectory");
system($DPKG_GENCONTROL, "-pkde-sc-dev-latest", "-Pdebian/tmp") and error("dpkg-gencontrol FAILED!");
system($DPKG_DEB, "--build", "debian/tmp", "kde-sc-dev-latest.deb") and error("dpkg-deb --build FAILED!");
system($DPKG_NAME, "kde-sc-dev-latest.deb") and error("dpkg-name FAILED!");

# Move
my @deb = glob('*.deb');
system("mv", $deb[0], $curdir) and
    error("unable to move debian package to the current directory");
chdir $curdir;

info "%s created sucessfully.", $deb[0];
info 'You may install it with `dpkg -i %s`', $deb[0];