Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discerning between a file and a folder in the files signal is impossible? #117

Open
purpleidea opened this issue Mar 6, 2016 · 6 comments

Comments

@purpleidea
Copy link

Getting the list of a files in a package is wonderfully useful, although in some packages (such as drbd-utils) on Fedora (an arbitrary example that demonstrates the issue) it lists:

/etc/drbd.d"

as a file, which is in fact a directory.

I'm well aware of the similarity in Linux, but it would be particularly useful for certain tools if there was a way to get more information about the file, such as if in fact it is a directory or not.

Other properties might also be useful information, although I have not found a personal use for this information yet. Getting file owner/group/mode and executable status would probably also be quite handy!

I expect this might involve adding a new method and signal to the API as to not break it.

Thanks in advance!

@purpleidea
Copy link
Author

To add a bit more credence to this, if you look at:

http://mirror.its.dal.ca/pub/fedora/linux/releases/23/Everything/x86_64/os/repodata/874f220caf48ccd307c203772c04b8550896c42a25f82b93bd17082d69df80db-filelists.xml.gz

This file contains the file lists for all the packages in a particular repository. The file is huge so, I just took out an excerpt from drbd-utils:

<package pkgid="791ee772612b57978589435ad45f39c65aa7a611df2a51cef7d262b4b61b10fb" name="drbd-utils" arch="x86_64">
  <version epoch="0" ver="8.9.4" rel="1.fc23"/>
  <file>/etc/drbd.conf</file>
  <file>/etc/drbd.d/global_common.conf</file>
  <file>/lib/drbd/drbd</file>
  <file>/lib/drbd/drbdadm-83</file>
  <file>/lib/drbd/drbdadm-84</file>
  <file>/lib/drbd/drbdsetup-83</file>
  <file>/lib/drbd/drbdsetup-84</file>
  <file>/usr/lib/drbd/crm-fence-peer.sh</file>
  <file>/usr/lib/drbd/crm-unfence-peer.sh</file>
  <file>/usr/lib/drbd/notify-emergency-reboot.sh</file>
  <file>/usr/lib/drbd/notify-emergency-shutdown.sh</file>
  <file>/usr/lib/drbd/notify-io-error.sh</file>
  <file>/usr/lib/drbd/notify-out-of-sync.sh</file>
  <file>/usr/lib/drbd/notify-pri-lost-after-sb.sh</file>
  <file>/usr/lib/drbd/notify-pri-lost.sh</file>
  <file>/usr/lib/drbd/notify-pri-on-incon-degr.sh</file>
  <file>/usr/lib/drbd/notify-split-brain.sh</file>
  <file>/usr/lib/drbd/notify.sh</file>
  <file>/usr/lib/drbd/outdate-peer.sh</file>
  <file>/usr/lib/drbd/rhcs_fence</file>
  <file>/usr/lib/drbd/snapshot-resync-target-lvm.sh</file>
  <file>/usr/lib/drbd/stonith_admin-fence-peer.sh</file>
  <file>/usr/lib/drbd/unsnapshot-resync-target-lvm.sh</file>
  <file>/usr/lib/systemd/system/drbd.service</file>
  <file>/usr/lib/tmpfiles.d/drbd.conf</file>
  <file>/usr/sbin/drbd-overview</file>
  <file>/usr/sbin/drbdadm</file>
  <file>/usr/sbin/drbdmeta</file>
  <file>/usr/sbin/drbdsetup</file>
  <file>/usr/share/doc/drbd-utils/COPYING</file>
  <file>/usr/share/doc/drbd-utils/ChangeLog</file>
  <file>/usr/share/doc/drbd-utils/README</file>
  <file>/usr/share/doc/drbd-utils/drbd.conf.example</file>
  <file>/usr/share/man/man5/drbd.conf-8.3.5.gz</file>
  <file>/usr/share/man/man5/drbd.conf-8.4.5.gz</file>
  <file>/usr/share/man/man5/drbd.conf-9.0.5.gz</file>
  <file>/usr/share/man/man5/drbd.conf.5.gz</file>
  <file>/usr/share/man/man8/drbd-8.3.8.gz</file>
  <file>/usr/share/man/man8/drbd-8.4.8.gz</file>
  <file>/usr/share/man/man8/drbd-9.0.8.gz</file>
  <file>/usr/share/man/man8/drbd-overview-9.0.8.gz</file>
  <file>/usr/share/man/man8/drbd-overview.8.gz</file>
  <file>/usr/share/man/man8/drbd.8.gz</file>
  <file>/usr/share/man/man8/drbdadm-8.3.8.gz</file>
  <file>/usr/share/man/man8/drbdadm-8.4.8.gz</file>
  <file>/usr/share/man/man8/drbdadm-9.0.8.gz</file>
  <file>/usr/share/man/man8/drbdadm.8.gz</file>
  <file>/usr/share/man/man8/drbddisk-8.3.8.gz</file>
  <file>/usr/share/man/man8/drbddisk-8.4.8.gz</file>
  <file>/usr/share/man/man8/drbdmeta-8.3.8.gz</file>
  <file>/usr/share/man/man8/drbdmeta-8.4.8.gz</file>
  <file>/usr/share/man/man8/drbdmeta-9.0.8.gz</file>
  <file>/usr/share/man/man8/drbdmeta.8.gz</file>
  <file>/usr/share/man/man8/drbdsetup-8.3.8.gz</file>
  <file>/usr/share/man/man8/drbdsetup-8.4.8.gz</file>
  <file>/usr/share/man/man8/drbdsetup-9.0.8.gz</file>
  <file>/usr/share/man/man8/drbdsetup.8.gz</file>
  <file type="dir">/etc/drbd.d</file>
  <file type="dir">/usr/share/doc/drbd-utils</file>
  <file type="dir">/var/lib/drbd</file>
</package>

As you can see, the "directory" files, have the:

file type="dir"

parts which is very useful to know.

I actually wrote a function to figure out which files must be dirs (because they have other listed files in the contents), but unfortunately some cases such as /var/lib/drbd can't be figured out since there are no files in the dir.

Thanks again!

@ximion
Copy link
Collaborator

ximion commented Mar 7, 2016

At least when using the aptcc backend, all directories have a / suffix, which makes it easy to tell whether a file is a file or dir.

@purpleidea
Copy link
Author

At least when using the aptcc backend, all directories have a / suffix, which makes it easy to tell whether a file is a file or dir.

That is very funny, because my https://github.com/purpleidea/mgmt/ actually uses the exact same convention to distinguish between a file and a directory. So that is a perfectly acceptable way to represent this. @ximion Very useful information, thanks!

For anyone using my tool under the aptcc backend, will not experience any issues, although I've tried to workaround some of them anyways.

This is an issue with the libhif (dnf) backend AFAICT. Can packagekit add the trailing slashes, since it has this information? This would be a perfectly acceptable way to represent this for me, and wouldn't require any API changes.

@hughsie
Copy link
Collaborator

hughsie commented Mar 7, 2016

Fwiw, I agree that a trailing backslash should indicate a directory. The issue is sometimes when packages own the files in a directory, and explicitly not the directory itself, e.g. in the bash completion case. If the directory-owned-by-package == trailing backslash is the behaviour you want, that should be pretty easily fixable.

@purpleidea
Copy link
Author

On Mon, Mar 7, 2016 at 3:25 AM, Richard Hughes [email protected]
wrote:

Fwiw, I agree that a trailing backslash should indicate a directory. The
issue is sometimes when packages own the files in a directory, and
explicitly not the directory itself, e.g. in the bash completion case. If
the directory-owned-by-package == trailing backslash is the behaviour you
want, that should be pretty easily fixable.

Yeah this sounds great. If the package doesn't own the directory, then it
won't be listed as an independent item anyways. Which is fine :)

So is it fair to count the current behaviour of sometimes not returning the
trailing slashes as a mini bug? (And can you patch this?)

@lukegb
Copy link

lukegb commented Oct 8, 2016

I looked into this briefly, and tried to work out what all the various pieces are doing:

As far as I can tell from looking into this (and I could well be wrong), this would mean a patch to libsolv to store information about what type of thing each <file> entry is, and then exposing this somehow in libdnf, so PackageKit can add trailing slashes to things if it deems they need them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants