This file is indexed.

/usr/share/pyshared/smart/commands/newer.py is in python-smartpm 1.4-2.

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

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
#
# Written by Pascal Bleser <guru@unixtech.be>
#
# This file is part of Smart Package Manager.
#
# Smart Package Manager 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 2 of the License, or (at
# your option) any later version.
#
# Smart Package Manager 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 Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart.util.strtools import isGlob, sizeToStr
from smart.transaction import Transaction, PolicyUpgrade, UPGRADE
from smart.option import OptionParser
from smart.cache import Provides, PreRequires, Package
from smart.const import *
from smart import *
import tempfile
import fnmatch
import string
import sys
import os
import re

USAGE=_("smart newer")

DESCRIPTION=_("""
This command shows packages that have available upgrades.
""")

EXAMPLES=_("""
smart newer
""")

def option_parser(help=None):
    if help:
        parser = OptionParser(help=help)
    else:
        parser = OptionParser(usage=USAGE,
                              description=DESCRIPTION,
                              examples=EXAMPLES)
    return parser

def parse_options(argv, help=None):
    parser = option_parser(help)
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts

def main(ctrl, opts, reloadchannels=True):

    if reloadchannels:
        ctrl.reloadChannels()

    cache = ctrl.getCache()
    trans = Transaction(cache, PolicyUpgrade)
    checkstate = None

    for pkg in cache.getPackages():
        if pkg.installed:
            trans.enqueue(pkg, UPGRADE)
            pass
        pass

    trans.run()
    changeset = trans.getChangeSet()
    state = changeset.getPersistentState()
    if not state:
        iface.showStatus(_("No interesting upgrades available."))
        return 2
    elif checkstate:
        for entry in state:
            if checkstate.get(entry) != state[entry]:
                break
            pass
        else:
            iface.showStatus(_("There are pending upgrades!"))
            return 1
        iface.showStatus(_("There are new upgrades available!"))
    elif not trans:
        iface.showStatus(_("No interesting upgrades available."))
        pass
    else:
        iface.hideStatus()
        upgrades = [pkg for (pkg, op) in changeset.items() if op == INSTALL]
        upgrades.sort()
        report = []
        for pkg in upgrades:
            upgraded = []
            for upg in pkg.upgrades:
                for prv in upg.providedby:
                    for prvpkg in prv.packages:
                        if prvpkg.installed:
                            upgraded.append(prvpkg)
                            pass
                        pass
                    pass
                pass

            for loader in pkg.loaders:
                if not loader.getInstalled():
                    break
                else:
                    continue
            info = loader.getInfo(pkg)
            for url in info.getURLs():
                size = info.getSize(url)
            ch = loader.getChannel()

            if len(upgraded) > 0:
                if str.find(upgraded[0].version, '@') != -1 :
                    (uversion, uarch) = upgraded[0].version.split('@')
                else:
                    (uversion, uarch) = (upgraded[0].version, "")
            else:
                uversion = _('(not installed)')
                uarch = ''
                pass
            if str.find(pkg.version, '@') != -1 :
                (iversion, iarch) = pkg.version.split('@')
            else:
                (iversion, iarch) = (pkg.version, "")
            entry = [pkg.name, uversion, uarch, iversion, iarch, ch.getAlias(), size]
            report.append(entry)
            pass

        # TODO: make this use an interface method
        
        report.insert(0, [_('Package Name'), _('Installed'), '', _('Upgrade'), '', _('Channel'), _('Size')])

        maxwidth = [0, 0, 0, 0, 0, 0, 0]
        for entry in report:
            for i in range(len(entry)):
                if entry[i] != None and len(str(entry[i])) > maxwidth[i]:
                    maxwidth[i] = len(str(entry[i]))
                    pass
                pass
            pass

        line = []
        mask = []
        mask.append('%-'+str(maxwidth[0])+'s')
        mask.append('%-'+str(maxwidth[1])+'s %'+str(maxwidth[2])+'s')
        mask.append('%-'+str(maxwidth[3])+'s %'+str(maxwidth[4])+'s')
        mask.append('%-'+str(maxwidth[5])+'s')
        mask.append('%-'+str(maxwidth[6])+'s')
        
        for mw in maxwidth:
            line.append(''.join(['-' for x in range(mw)]))
            pass

        maskline = ' | '.join(mask)

        print maskline % tuple(report[0])
        print '-+-'.join(mask) % tuple(line)
        for entry in report[1:]:
            print maskline % tuple(entry)

# vim:ts=4:sw=4:et