#29 Mangle /bin shebnags to /usr/bin ones (#1581757)
Merged 5 years ago by churchyard. Opened 5 years ago by churchyard.
rpms/ churchyard/redhat-rpm-config bin_shebangs  into  master

file modified
+4
@@ -121,6 +121,10 @@ 

    # /whatsoever/env foo → /whatsoever/foo

    shebang=$(echo "$shebang" | sed -r -e 's@^(.+/)env (.+)$@\1\2@')

  

+   # If the shebang now starts with /bin, change it to /usr/bin

+   # https://bugzilla.redhat.com/show_bug.cgi?id=1581757

+   shebang=$(echo "$shebang" | sed -r -e 's@^/bin/@/usr/bin/@')

+ 

    # Replace ambiguous python with python2

    py_shebang=$(echo "$shebang" | sed -r -e 's@/usr/bin/python(\s|$)@/usr/bin/python2\1@')

  

file modified
+4 -1
@@ -6,7 +6,7 @@ 

  

  Summary: Red Hat specific rpm configuration files

  Name: redhat-rpm-config

- Version: 116

+ Version: 117

  Release: 1%{?dist}

  # No version specified.

  License: GPL+
@@ -183,6 +183,9 @@ 

  %{_rpmconfigdir}/macros.d/macros.kmp

  

  %changelog

+ * Mon Jul 16 2018 Miro Hrončok <mhroncok@redhat.com> - 117-1

+ - Mangle /bin shebnags to /usr/bin ones (#1581757)

+ 

  * Tue Jul 10 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 116-1

  - Add option to add -Wl,--as-needed into LDFLAGS

  

Do we have any binaries which still live in /bin and do not have /usr/bin equivalent?

In any case, I think we should have done this long time ago.

+1 from me.

Can this result in generation of Requires: dependencies for which there are no matching Provides:?

It can. But such packages should be fixed.

Note that I also have tests, because i got sick of manual testing. Will add them in a separate commit.

My only concern with this is that #!/bin/sh is… a rather common idiom. So this will mean that a rather significant quantity of files will change and that's always something to think about.

It appears that the script isn't too alarming when it changes that type of shebang line (it just says "mangling shebang in $path from $orig_shebang to #!$shebang") so I would hope that it doesn't give maintainers the idea that they need to fix this kind of thing manually instead of letting the script do it.

We should still look for all packages which provide /bin/foo without the corresponding /usr/bin/foo in advance of making this change. Currently Fedora doesn't run a broken dependency report (although I'm trying to fix that), so any dependency problems caused by this wouldn't necessarily be particularly obvious.

Ok, I have no idea, how to get such list.

There aren't so many packages; directly inspecting the output of this should be sufficient:

for i in $(repoquery --whatprovides /bin/\* --qf '%{NAME}'); do echo "==== $i"; echo provides; repoquery --provides $i|grep bin; echo; echo files; repoquery -l $i|grep bin; echo; echo; done

Manual inspection of the result (included below) turns up the following oddities:

  • iputils provides /bin/ping and /bin/ping6, but only includes /usr/sbin/ping6. That's broken but shouldn't cause problems for this change.
  • mailx only includes /bin/mail and /bin/mailx, which then get installed to the wrong location because of the symlink. I have a hard time imagining a shebang line of #!/bin/mailx.
  • sed provides only /bin/sed and needs fixing. /bin/sed in a shebang line is certainly reasonable though I would not expect it in packaged software.

Of course all of these should be fixed or at least have bugs filed.

The only one I can imagine being problematic is sed. Only four packages have a direct dependency on /bin/sed: gnu-smalltalk, openvswitch, os-prober and resource-agents. I looked at all of them and none contain files with shebang lines which reference /bin/sed.

Full output:

==== bash
provides
/bin/bash
/bin/sh

files
/usr/bin/alias
/usr/bin/bash
/usr/bin/bashbug
/usr/bin/bashbug-64
/usr/bin/bg
/usr/bin/cd
/usr/bin/command
/usr/bin/fc
/usr/bin/fg
/usr/bin/getopts
/usr/bin/hash
/usr/bin/jobs
/usr/bin/read
/usr/bin/sh
/usr/bin/type
/usr/bin/ulimit
/usr/bin/umask
/usr/bin/unalias
/usr/bin/wait
/usr/share/man/man1/bind.1.gz


==== coreutils
provides
/bin/cat
/bin/chmod
/bin/echo
/bin/ln
/bin/rm
/bin/touch

files
/usr/bin/[
/usr/bin/arch
/usr/bin/b2sum
/usr/bin/base32
/usr/bin/base64
/usr/bin/basename
/usr/bin/cat
/usr/bin/chcon
/usr/bin/chgrp
/usr/bin/chmod
/usr/bin/chown
/usr/bin/cksum
/usr/bin/comm
/usr/bin/cp
/usr/bin/csplit
/usr/bin/cut
/usr/bin/date
/usr/bin/dd
/usr/bin/df
/usr/bin/dir
/usr/bin/dircolors
/usr/bin/dirname
/usr/bin/du
/usr/bin/echo
/usr/bin/env
/usr/bin/expand
/usr/bin/expr
/usr/bin/factor
/usr/bin/false
/usr/bin/fmt
/usr/bin/fold
/usr/bin/groups
/usr/bin/head
/usr/bin/hostid
/usr/bin/id
/usr/bin/install
/usr/bin/join
/usr/bin/link
/usr/bin/ln
/usr/bin/logname
/usr/bin/ls
/usr/bin/md5sum
/usr/bin/mkdir
/usr/bin/mkfifo
/usr/bin/mknod
/usr/bin/mktemp
/usr/bin/mv
/usr/bin/nice
/usr/bin/nl
/usr/bin/nohup
/usr/bin/nproc
/usr/bin/numfmt
/usr/bin/od
/usr/bin/paste
/usr/bin/pathchk
/usr/bin/pinky
/usr/bin/pr
/usr/bin/printenv
/usr/bin/printf
/usr/bin/ptx
/usr/bin/pwd
/usr/bin/readlink
/usr/bin/realpath
/usr/bin/rm
/usr/bin/rmdir
/usr/bin/runcon
/usr/bin/seq
/usr/bin/sha1sum
/usr/bin/sha224sum
/usr/bin/sha256sum
/usr/bin/sha384sum
/usr/bin/sha512sum
/usr/bin/shred
/usr/bin/shuf
/usr/bin/sleep
/usr/bin/sort
/usr/bin/split
/usr/bin/stat
/usr/bin/stdbuf
/usr/bin/stty
/usr/bin/sum
/usr/bin/sync
/usr/bin/tac
/usr/bin/tail
/usr/bin/tee
/usr/bin/test
/usr/bin/timeout
/usr/bin/touch
/usr/bin/tr
/usr/bin/true
/usr/bin/truncate
/usr/bin/tsort
/usr/bin/tty
/usr/bin/uname
/usr/bin/unexpand
/usr/bin/uniq
/usr/bin/unlink
/usr/bin/users
/usr/bin/vdir
/usr/bin/wc
/usr/bin/who
/usr/bin/whoami
/usr/bin/yes
/usr/sbin/chroot


==== coreutils-single
provides
/bin/cat
/bin/chmod
/bin/echo
/bin/ln
/bin/rm
/bin/touch

files
/usr/bin/[
/usr/bin/arch
/usr/bin/b2sum
/usr/bin/base32
/usr/bin/base64
/usr/bin/basename
/usr/bin/cat
/usr/bin/chcon
/usr/bin/chgrp
/usr/bin/chmod
/usr/bin/chown
/usr/bin/cksum
/usr/bin/comm
/usr/bin/coreutils
/usr/bin/cp
/usr/bin/csplit
/usr/bin/cut
/usr/bin/date
/usr/bin/dd
/usr/bin/df
/usr/bin/dir
/usr/bin/dircolors
/usr/bin/dirname
/usr/bin/du
/usr/bin/echo
/usr/bin/env
/usr/bin/expand
/usr/bin/expr
/usr/bin/factor
/usr/bin/false
/usr/bin/fmt
/usr/bin/fold
/usr/bin/groups
/usr/bin/head
/usr/bin/hostid
/usr/bin/id
/usr/bin/install
/usr/bin/join
/usr/bin/link
/usr/bin/ln
/usr/bin/logname
/usr/bin/ls
/usr/bin/md5sum
/usr/bin/mkdir
/usr/bin/mkfifo
/usr/bin/mknod
/usr/bin/mktemp
/usr/bin/mv
/usr/bin/nice
/usr/bin/nl
/usr/bin/nohup
/usr/bin/nproc
/usr/bin/numfmt
/usr/bin/od
/usr/bin/paste
/usr/bin/pathchk
/usr/bin/pinky
/usr/bin/pr
/usr/bin/printenv
/usr/bin/printf
/usr/bin/ptx
/usr/bin/pwd
/usr/bin/readlink
/usr/bin/realpath
/usr/bin/rm
/usr/bin/rmdir
/usr/bin/runcon
/usr/bin/seq
/usr/bin/sha1sum
/usr/bin/sha224sum
/usr/bin/sha256sum
/usr/bin/sha384sum
/usr/bin/sha512sum
/usr/bin/shred
/usr/bin/shuf
/usr/bin/sleep
/usr/bin/sort
/usr/bin/split
/usr/bin/stat
/usr/bin/stdbuf
/usr/bin/stty
/usr/bin/sum
/usr/bin/sync
/usr/bin/tac
/usr/bin/tail
/usr/bin/tee
/usr/bin/test
/usr/bin/timeout
/usr/bin/touch
/usr/bin/tr
/usr/bin/true
/usr/bin/truncate
/usr/bin/tsort
/usr/bin/tty
/usr/bin/uname
/usr/bin/unexpand
/usr/bin/uniq
/usr/bin/unlink
/usr/bin/users
/usr/bin/vdir
/usr/bin/wc
/usr/bin/who
/usr/bin/whoami
/usr/bin/yes
/usr/sbin/chroot


==== cpio
provides
/bin/cpio

files
/usr/bin/cpio


==== findutils
provides
/bin/find

files
/usr/bin/find
/usr/bin/xargs


==== gawk
provides
/bin/awk
/bin/gawk

files
/usr/bin/awk
/usr/bin/gawk
/usr/share/awk/libintl.awk
/usr/bin/awk
/usr/bin/gawk
/usr/share/awk/libintl.awk


==== gettext
provides
/bin/gettext

files
/usr/bin/envsubst
/usr/bin/gettext
/usr/bin/gettext.sh
/usr/bin/msgattrib
/usr/bin/msgcat
/usr/bin/msgcmp
/usr/bin/msgcomm
/usr/bin/msgconv
/usr/bin/msgen
/usr/bin/msgexec
/usr/bin/msgfilter
/usr/bin/msgfmt
/usr/bin/msggrep
/usr/bin/msginit
/usr/bin/msgmerge
/usr/bin/msgunfmt
/usr/bin/msguniq
/usr/bin/ngettext
/usr/bin/recode-sr-latin
/usr/bin/xgettext


==== grep
provides
/bin/egrep
/bin/fgrep
/bin/grep

files
/usr/bin/egrep
/usr/bin/fgrep
/usr/bin/grep


==== gzip
provides
/bin/gunzip
/bin/gzip
/bin/zcat

files
/usr/bin/gunzip
/usr/bin/gzexe
/usr/bin/gzip
/usr/bin/zcat
/usr/bin/zcmp
/usr/bin/zdiff
/usr/bin/zegrep
/usr/bin/zfgrep
/usr/bin/zforce
/usr/bin/zgrep
/usr/bin/zless
/usr/bin/zmore
/usr/bin/znew


==== iputils
provides
/bin/ping
/bin/ping6
/sbin/arping
/sbin/rdisc

files
/usr/bin/ping
/usr/bin/tracepath
/usr/sbin/arping
/usr/sbin/clockdiff
/usr/sbin/ifenslave
/usr/sbin/ping
/usr/sbin/ping6
/usr/sbin/rdisc
/usr/sbin/tracepath
/usr/sbin/tracepath6


==== ksh
provides
/bin/ksh

files
/etc/binfmt.d/kshcomp.conf
/usr/bin/ksh
/usr/bin/shcomp


==== mailx
provides

files
/bin/mail
/bin/mailx
/usr/bin/Mail
/usr/bin/nail


==== mksh
provides
/bin/lksh
/bin/mksh

files
/usr/bin/lksh
/usr/bin/mksh


==== procps-ng
provides
/bin/ps
/sbin/sysctl

files
/usr/bin/free
/usr/bin/pgrep
/usr/bin/pidof
/usr/bin/pkill
/usr/bin/pmap
/usr/bin/ps
/usr/bin/pwdx
/usr/bin/skill
/usr/bin/slabtop
/usr/bin/snice
/usr/bin/tload
/usr/bin/top
/usr/bin/uptime
/usr/bin/vmstat
/usr/bin/w
/usr/bin/watch
/usr/sbin/pidof
/usr/sbin/sysctl


==== rc
provides
/bin/rc

files
/usr/bin/rc


==== sed
provides
/bin/sed

files
/usr/bin/sed


==== systemd
provides
/bin/systemctl
/sbin/shutdown

files
/etc/binfmt.d
/usr/bin/busctl
/usr/bin/coredumpctl
/usr/bin/hostnamectl
/usr/bin/journalctl
/usr/bin/localectl
/usr/bin/loginctl
/usr/bin/networkctl
/usr/bin/resolvectl
/usr/bin/systemctl
/usr/bin/systemd-analyze
/usr/bin/systemd-ask-password
/usr/bin/systemd-cat
/usr/bin/systemd-cgls
/usr/bin/systemd-cgtop
/usr/bin/systemd-delta
/usr/bin/systemd-detect-virt
/usr/bin/systemd-escape
/usr/bin/systemd-firstboot
/usr/bin/systemd-inhibit
/usr/bin/systemd-machine-id-setup
/usr/bin/systemd-mount
/usr/bin/systemd-notify
/usr/bin/systemd-path
/usr/bin/systemd-resolve
/usr/bin/systemd-run
/usr/bin/systemd-socket-activate
/usr/bin/systemd-stdio-bridge
/usr/bin/systemd-sysusers
/usr/bin/systemd-tmpfiles
/usr/bin/systemd-tty-ask-password-agent
/usr/bin/systemd-umount
/usr/bin/timedatectl
/usr/lib/binfmt.d
/usr/lib/systemd/system/proc-sys-fs-binfmt_misc.automount
/usr/lib/systemd/system/proc-sys-fs-binfmt_misc.mount
/usr/lib/systemd/system/rpcbind.target
/usr/lib/systemd/system/sysinit.target.wants/proc-sys-fs-binfmt_misc.automount
/usr/lib/systemd/system/sysinit.target.wants/systemd-binfmt.service
/usr/lib/systemd/system/systemd-binfmt.service
/usr/lib/systemd/systemd-binfmt
/usr/sbin/halt
/usr/sbin/init
/usr/sbin/poweroff
/usr/sbin/reboot
/usr/sbin/resolvconf
/usr/sbin/runlevel
/usr/sbin/shutdown
/usr/sbin/telinit
/usr/share/man/man5/binfmt.d.5.gz
/usr/share/man/man8/systemd-binfmt.8.gz
/usr/share/man/man8/systemd-binfmt.service.8.gz


==== tar
provides
/bin/gtar
/bin/tar

files
/usr/bin/gtar
/usr/bin/tar


==== tcsh
provides
/bin/csh
/bin/tcsh

files
/usr/bin/csh
/usr/bin/tcsh


==== util-linux
provides
/bin/dmesg
/bin/kill
/bin/more
/bin/mount
/bin/umount
/sbin/blkid
/sbin/blockdev
/sbin/findfs
/sbin/fsck
/sbin/nologin

files
/usr/bin/cal
/usr/bin/chmem
/usr/bin/chrt
/usr/bin/col
/usr/bin/colcrt
/usr/bin/colrm
/usr/bin/column
/usr/bin/dmesg
/usr/bin/eject
/usr/bin/fallocate
/usr/bin/fincore
/usr/bin/findmnt
/usr/bin/flock
/usr/bin/getopt
/usr/bin/hexdump
/usr/bin/i386
/usr/bin/ionice
/usr/bin/ipcmk
/usr/bin/ipcrm
/usr/bin/ipcs
/usr/bin/isosize
/usr/bin/kill
/usr/bin/last
/usr/bin/lastb
/usr/bin/linux32
/usr/bin/linux64
/usr/bin/logger
/usr/bin/login
/usr/bin/look
/usr/bin/lsblk
/usr/bin/lscpu
/usr/bin/lsipc
/usr/bin/lslocks
/usr/bin/lslogins
/usr/bin/lsmem
/usr/bin/lsns
/usr/bin/mcookie
/usr/bin/mesg
/usr/bin/more
/usr/bin/mount
/usr/bin/mountpoint
/usr/bin/namei
/usr/bin/nsenter
/usr/bin/prlimit
/usr/bin/raw
/usr/bin/rename
/usr/bin/renice
/usr/bin/rev
/usr/bin/script
/usr/bin/scriptreplay
/usr/bin/setarch
/usr/bin/setpriv
/usr/bin/setsid
/usr/bin/setterm
/usr/bin/su
/usr/bin/taskset
/usr/bin/ul
/usr/bin/umount
/usr/bin/uname26
/usr/bin/unshare
/usr/bin/utmpdump
/usr/bin/uuidgen
/usr/bin/uuidparse
/usr/bin/wall
/usr/bin/wdctl
/usr/bin/whereis
/usr/bin/write
/usr/bin/x86_64
/usr/sbin/addpart
/usr/sbin/agetty
/usr/sbin/blkdiscard
/usr/sbin/blkid
/usr/sbin/blkzone
/usr/sbin/blockdev
/usr/sbin/cfdisk
/usr/sbin/chcpu
/usr/sbin/clock
/usr/sbin/ctrlaltdel
/usr/sbin/delpart
/usr/sbin/fdformat
/usr/sbin/fdisk
/usr/sbin/findfs
/usr/sbin/fsck
/usr/sbin/fsck.cramfs
/usr/sbin/fsck.minix
/usr/sbin/fsfreeze
/usr/sbin/fstrim
/usr/sbin/hwclock
/usr/sbin/ldattach
/usr/sbin/losetup
/usr/sbin/mkfs
/usr/sbin/mkfs.cramfs
/usr/sbin/mkfs.minix
/usr/sbin/mkswap
/usr/sbin/nologin
/usr/sbin/partx
/usr/sbin/pivot_root
/usr/sbin/readprofile
/usr/sbin/resizepart
/usr/sbin/rfkill
/usr/sbin/rtcwake
/usr/sbin/runuser
/usr/sbin/sfdisk
/usr/sbin/sulogin
/usr/sbin/swaplabel
/usr/sbin/swapoff
/usr/sbin/swapon
/usr/sbin/switch_root
/usr/sbin/wipefs
/usr/sbin/zramctl
/usr/bin/cal
/usr/bin/chmem
/usr/bin/chrt
/usr/bin/col
/usr/bin/colcrt
/usr/bin/colrm
/usr/bin/column
/usr/bin/dmesg
/usr/bin/eject
/usr/bin/fallocate
/usr/bin/fincore
/usr/bin/findmnt
/usr/bin/flock
/usr/bin/getopt
/usr/bin/hexdump
/usr/bin/i386
/usr/bin/ionice
/usr/bin/ipcmk
/usr/bin/ipcrm
/usr/bin/ipcs
/usr/bin/isosize
/usr/bin/kill
/usr/bin/last
/usr/bin/lastb
/usr/bin/linux32
/usr/bin/linux64
/usr/bin/logger
/usr/bin/login
/usr/bin/look
/usr/bin/lsblk
/usr/bin/lscpu
/usr/bin/lsipc
/usr/bin/lslocks
/usr/bin/lslogins
/usr/bin/lsmem
/usr/bin/lsns
/usr/bin/mcookie
/usr/bin/mesg
/usr/bin/more
/usr/bin/mount
/usr/bin/mountpoint
/usr/bin/namei
/usr/bin/nsenter
/usr/bin/prlimit
/usr/bin/raw
/usr/bin/rename
/usr/bin/renice
/usr/bin/rev
/usr/bin/script
/usr/bin/scriptreplay
/usr/bin/setarch
/usr/bin/setpriv
/usr/bin/setsid
/usr/bin/setterm
/usr/bin/su
/usr/bin/taskset
/usr/bin/ul
/usr/bin/umount
/usr/bin/uname26
/usr/bin/unshare
/usr/bin/utmpdump
/usr/bin/uuidgen
/usr/bin/uuidparse
/usr/bin/wall
/usr/bin/wdctl
/usr/bin/whereis
/usr/bin/write
/usr/sbin/addpart
/usr/sbin/agetty
/usr/sbin/blkdiscard
/usr/sbin/blkid
/usr/sbin/blkzone
/usr/sbin/blockdev
/usr/sbin/cfdisk
/usr/sbin/chcpu
/usr/sbin/clock
/usr/sbin/ctrlaltdel
/usr/sbin/delpart
/usr/sbin/fdformat
/usr/sbin/fdisk
/usr/sbin/findfs
/usr/sbin/fsck
/usr/sbin/fsck.cramfs
/usr/sbin/fsck.minix
/usr/sbin/fsfreeze
/usr/sbin/fstrim
/usr/sbin/hwclock
/usr/sbin/ldattach
/usr/sbin/losetup
/usr/sbin/mkfs
/usr/sbin/mkfs.cramfs
/usr/sbin/mkfs.minix
/usr/sbin/mkswap
/usr/sbin/nologin
/usr/sbin/partx
/usr/sbin/pivot_root
/usr/sbin/readprofile
/usr/sbin/resizepart
/usr/sbin/rfkill
/usr/sbin/rtcwake
/usr/sbin/runuser
/usr/sbin/sfdisk
/usr/sbin/sulogin
/usr/sbin/swaplabel
/usr/sbin/swapoff
/usr/sbin/swapon
/usr/sbin/switch_root
/usr/sbin/wipefs
/usr/sbin/zramctl


==== yash
provides
/bin/yash

files
/usr/bin/yash
/usr/share/yash/completion/bindkey


==== zsh
provides
/bin/zsh

files
/usr/bin/zsh
/usr/share/zsh/5.5.1/functions/_bind_addresses
/usr/share/zsh/5.5.1/functions/_bindkey
/usr/share/zsh/5.5.1/functions/_combination
/usr/share/zsh/5.5.1/help/bindkey

Oh, TIL that I can do repoquery --whatprovides /bin/\*.

Let me do a PR for sed.

Also:

$ repoquery --disablerepo='*' --enablerepo='rawhide' --whatrequires /bin/sed
gnu-smalltalk-0:3.2.5-22.fc28.i686
gnu-smalltalk-0:3.2.5-22.fc28.x86_64
openvswitch-0:2.9.2-1.fc29.x86_64
os-prober-0:1.74-6.fc28.x86_64
resource-agents-0:4.1.1-1.fc29.1.x86_64
$ dnf repoquery --whatrequires /bin/mail --exact
amanda-0:3.5.1-12.fc29.x86_64
apcupsd-0:3.14.14-11.fc29.x86_64
$ dnf repoquery --whatrequires /bin/mailx --exact
redhat-lsb-core-0:4.1-44.fc28.i686
redhat-lsb-core-0:4.1-44.fc28.x86_64

https://src.fedoraproject.org/rpms/mailx/pull-request/1

Interestingly, I maintain both packages which depend on /bin/mail.

Of course that should be fixed. But neither /bin/mail nor /bin/mailx are going to appear in shebang lines and thus have no real bearing on this PR. I think we've established that the change mentioned here won't cause any dependency issues and the questions in the first two comments have been answered.

Please fix the typo in the commit description before merging.

Should this be a Fedora Change?

No changes in the mangling were a fedora change. This can also been seen as https://fedoraproject.org/wiki/Features/UsrMove

Will fix the typo

rebased onto 973e5c7

5 years ago

Pull-Request has been merged by churchyard

5 years ago