Skip to content

Instantly share code, notes, and snippets.

@rollcat

rollcat/findbins.py

Last active Oct 5, 2017
Embed
What would you like to do?
Executable basename conflicts in Debian packages
#!/usr/bin/env python3
import subprocess
import os
PATH = [
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
"/usr/games",
]
def group_by(f, xs, collection=list, add=list.append):
tmp = {}
for x in xs:
add(tmp.setdefault(f(x), collection()), x)
return tmp
def get_bins():
lines = []
lines.extend(subprocess.getoutput("apt-file find '/usr/games/'")
.split("\n"))
lines.extend(subprocess.getoutput("apt-file find 'bin/'").split("\n"))
for line in lines:
pkg, fname = line.strip().split(": ", 1)
if os.path.dirname(fname) not in PATH:
continue
yield pkg, fname
return
def main():
all_bins = get_bins()
by_basename = group_by(lambda pf: os.path.basename(pf[1]), all_bins)
for basename, bins in by_basename.items():
if len(bins) <= 1:
continue
if len({os.path.dirname(fname) for pkg, fname in bins}) <= 1:
continue
if len({pkg for pkg, fname in bins}) <= 1:
continue
for pkg, fname in bins:
print("{}:\t{}\t{}".format(basename, pkg, fname))
return
if __name__ == "__main__":
main()
arcstat: nordugrid-arc-client /usr/bin/arcstat
arcstat: zfsutils-linux /usr/sbin/arcstat
arping: arping /usr/sbin/arping
arping: iputils-arping /usr/bin/arping
bat: bacula-console-qt /usr/bin/bat
bat: bacula-console-qt /usr/sbin/bat
bat: bareos-bat /usr/bin/bat
bconsole: bacula-console /usr/sbin/bconsole
bconsole: bareos-bconsole /usr/bin/bconsole
bconsole: bareos-bconsole /usr/sbin/bconsole
bcopy: bacula-sd /usr/bin/bcopy
bcopy: bareos-tools /usr/sbin/bcopy
bregex: bacula-director /usr/sbin/bregex
bregex: bareos-tools /usr/bin/bregex
bregex: bareos-tools /usr/sbin/bregex
bscan: bacula-bscan /usr/bin/bscan
bscan: bareos-database-tools /usr/sbin/bscan
bsmtp: bacula-common /usr/sbin/bsmtp
bsmtp: bareos-common /usr/bin/bsmtp
bsmtp: bareos-common /usr/sbin/bsmtp
bwild: bacula-director /usr/sbin/bwild
bwild: bareos-tools /usr/bin/bwild
bwild: bareos-tools /usr/sbin/bwild
crm: crm114 /usr/bin/crm
crm: crmsh /usr/sbin/crm
dbverify: 389-ds-base /usr/sbin/dbverify
dbverify: lifelines /usr/bin/dbverify
faxq: hylafax-server /usr/sbin/faxq
faxq: mgetty-fax /usr/bin/faxq
gearmand: gearman-job-server /usr/sbin/gearmand
gearmand: gearman-server /usr/bin/gearmand
hcc: lam4-dev /usr/bin/hcc
hcc: uhexen2 /usr/games/hcc
hunt: bsdgames /usr/games/hunt
hunt: hunt /usr/sbin/hunt
icmd: ipmiutil /usr/sbin/icmd
icmd: renameutils /usr/bin/icmd
mailq: courier-mta /usr/bin/mailq
mailq: dma /usr/bin/mailq
mailq: esmtp-run /usr/bin/mailq
mailq: exim4-daemon-heavy /usr/bin/mailq
mailq: exim4-daemon-light /usr/bin/mailq
mailq: nullmailer /usr/bin/mailq
mailq: postfix /usr/bin/mailq
mailq: qmail-run /usr/sbin/mailq
mailq: sendmail-bin /usr/bin/mailq
mailq: ssmtp /usr/sbin/mailq
metar: flightgear /usr/games/metar
metar: metar /usr/bin/metar
monitor: 389-ds-base /usr/sbin/monitor
monitor: dmucs /usr/bin/monitor
monop: bsdgames /usr/games/monop
monop: mono-devel /usr/bin/monop
morse: bsdgames /usr/games/morse
morse: morse /usr/bin/morse
morse: morse-simulator /usr/bin/morse
mousetrap: gnome-mousetrap /usr/bin/mousetrap
mousetrap: mousetrap /usr/games/mousetrap
newaliases: courier-mta /usr/sbin/newaliases
newaliases: dma /usr/bin/newaliases
newaliases: esmtp-run /usr/bin/newaliases
newaliases: exim4-daemon-heavy /usr/bin/newaliases
newaliases: exim4-daemon-light /usr/bin/newaliases
newaliases: msmtp-mta /usr/bin/newaliases
newaliases: nullmailer /usr/bin/newaliases
newaliases: opensmtpd /usr/sbin/newaliases
newaliases: postfix /usr/bin/newaliases
newaliases: qmail-run /usr/sbin/newaliases
newaliases: sendmail-bin /usr/sbin/newaliases
newaliases: ssmtp /usr/sbin/newaliases
pm-hibernate: molly-guard /sbin/pm-hibernate
pm-hibernate: pm-utils /usr/sbin/pm-hibernate
pm-suspend-hybrid: molly-guard /sbin/pm-suspend-hybrid
pm-suspend-hybrid: pm-utils /usr/sbin/pm-suspend-hybrid
pm-suspend: molly-guard /sbin/pm-suspend
pm-suspend: pm-utils /usr/sbin/pm-suspend
primes: bsdgames /usr/games/primes
primes: libmath-prime-util-perl /usr/bin/primes
queen: flight-of-the-amazon-queen /usr/games/queen
queen: sgb /usr/bin/queen
ricochet: ricochet /usr/games/ricochet
ricochet: ricochet-im /usr/bin/ricochet
rm: coreutils /bin/rm
rm: safe-rm /usr/bin/rm
rmail: courier-mta /usr/sbin/rmail
rmail: exim4-daemon-heavy /usr/sbin/rmail
rmail: exim4-daemon-light /usr/sbin/rmail
rmail: postfix /usr/bin/rmail
rmail: postfix /usr/sbin/rmail
rmail: rmail /usr/sbin/rmail
rs: reminiscence /usr/games/rs
rs: rs /usr/bin/rs
sauce: fortunes-de /usr/games/sauce
sauce: sauce /usr/sbin/sauce
scramble: filters /usr/games/scramble
scramble: staden-io-lib-utils /usr/bin/scramble
sendfax: hylafax-client /usr/bin/sendfax
sendfax: mgetty-fax /usr/sbin/sendfax
sendpage: hylafax-client /usr/bin/sendpage
sendpage: sendpage-server /usr/sbin/sendpage
sethdlc: ax25-tools /usr/bin/sethdlc
sethdlc: dahdi /usr/sbin/sethdlc
siggen: siggen /usr/bin/siggen
siggen: tripwire /usr/sbin/siggen
singularity: singularity /usr/games/singularity
singularity: singularity-container /usr/bin/singularity
splat: spl /usr/sbin/splat
splat: splat /usr/bin/splat
spring: ruby-spring /usr/bin/spring
spring: spring /usr/games/spring
sslh: libnet-proxy-perl /usr/bin/sslh
sslh: sslh /usr/sbin/sslh
syslogd: busybox-syslogd /sbin/syslogd
syslogd: inetutils-syslogd /usr/sbin/syslogd
tcpd: tcm /usr/bin/tcpd
tcpd: tcpd /usr/sbin/tcpd
turnserver: coturn /usr/bin/turnserver
turnserver: turnserver /usr/sbin/turnserver
update-locale: gosa-dev /usr/bin/update-locale
update-locale: locales /usr/sbin/update-locale
update-service: daemontools-run /usr/sbin/update-service
update-service: runit /sbin/update-service
vuname: umview /usr/bin/vuname
vuname: util-vserver /usr/sbin/vuname
ztest: zfsutils-linux /sbin/ztest
ztest: zutils /bin/ztest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.