You are not logged in.

#1 2014-10-10 03:50:01

cyker
Member
Registered: 2009-05-30
Posts: 86

[SOLVED] Find modified files from a package in local file system

Is there a quick pacman command doing a diff between the local file system and a pacman package?

Say I have installed a package foo and modified /etc/foo.conf. Now I want to find what's the difference between the file in my local file system and that in a clean package.

If there's not a quick pacman command, what would you use in this case?

Last edited by cyker (2014-10-10 05:18:46)


.

Offline

#2 2014-10-10 04:24:10

amish
Member
Registered: 2014-05-10
Posts: 513

Re: [SOLVED] Find modified files from a package in local file system

The original package foo.tar.xz is always there in /var/cache/pacman/pkg (unless you cleared it)

Fast solution to compare full package:(lists names of files which differ)

pacman -Qkk foo
OR
tar --diff -C / -f /var/cache/pacman/pkg/foo.tar.xz

Once you know names of file that differ, do per file comparison as follows:

tar -xOf /var/cache/pacman/pkg/foo.tar.gz etc/foo.conf | diff /etc/foo.conf -

Last edited by amish (2014-10-10 05:17:06)

Offline

#3 2014-10-10 04:31:07

cyker
Member
Registered: 2009-05-30
Posts: 86

Re: [SOLVED] Find modified files from a package in local file system

Thanks. Then it doesn't seem we have a handy tool right now. Actually it'd be good if it also accepts full-package comparison. I want this tool because sometimes my package doesn't work and I'd like to figure out what changes I made stopped it from working. The clean package should work so a diff can be helpful.


.

Offline

#4 2014-10-10 04:38:21

amish
Member
Registered: 2014-05-10
Posts: 513

Re: [SOLVED] Find modified files from a package in local file system

EDIT:
post moved to my previous post above

Last edited by amish (2014-10-10 05:18:04)

Offline

#5 2014-10-10 04:45:33

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: [SOLVED] Find modified files from a package in local file system

You could pacman -S the package and get .pacnew files, I guess.

Last edited by lucke (2014-10-10 04:45:56)

Offline

#6 2014-10-10 05:00:06

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: [SOLVED] Find modified files from a package in local file system


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#7 2014-10-10 05:04:04

amish
Member
Registered: 2014-05-10
Posts: 513

Re: [SOLVED] Find modified files from a package in local file system

@loafer - possibly he does not want that.

Offline

#8 2014-10-10 05:07:26

cyker
Member
Registered: 2009-05-30
Posts: 86

Re: [SOLVED] Find modified files from a package in local file system

amish wrote:

Ok here is just one line code which compares full-package! (lists names of files which differ)

tar --diff -C / -f /var/cache/pacman/pkg/foo.tar.xz

After that u can use old solution (in my previous post) to do per file comparison

This can help find files of interest. Some issues:

  1. tar diff doesn't show the full text diff.

  2. tar diff shows mod time diff and size diff, which are not quite interesting to me.


.

Offline

#9 2014-10-10 05:11:21

amish
Member
Registered: 2014-05-10
Posts: 513

Re: [SOLVED] Find modified files from a package in local file system

Yes I realized it later that the content difference is not shown. So updated my post accordingly.

Basically first command will help you know the files which differ. (mod time differs is what you need to look for)
2nd command will tell u exact difference.

You can also use:

pacman -Qkk foo

May be "tar" can add the feature in --diff command to compare the files contents too.

Last edited by amish (2014-10-10 05:31:18)

Offline

#10 2014-10-10 05:14:57

cyker
Member
Registered: 2009-05-30
Posts: 86

Re: [SOLVED] Find modified files from a package in local file system

Well, this helps in a different way. If every package accurately lists its backup files then this command is very handy. I guess it doesn't care about non-backup files right now.


.

Offline

#11 2014-10-10 05:18:12

cyker
Member
Registered: 2009-05-30
Posts: 86

Re: [SOLVED] Find modified files from a package in local file system

amish wrote:

Yes I realized it later that the file difference is not shown. So updated my post accordingly.

Basically first command will help you know the files which differ. (size diference is what you need to look for)
2nd command will tell u exact difference.

You can also use:

pacman -Qkk foo

May be "tar" can add the feature in --diff command to compare the files contents too.

pacman -Qkk

is good. Almost solved this problem. Removing uninteresting mod time mismatches should be easy. Thanks!


.

Offline

#12 2014-10-10 05:30:20

amish
Member
Registered: 2014-05-10
Posts: 513

Re: [SOLVED] Find modified files from a package in local file system

Size difference does not always work! smile

Lets say original conf file had two lines:

Alert=true
#Alert=false

Now you changed it to:

#Alert=true
Alert=false

So size will remain same!!

So mod time is possibly better way to check! smile

Offline

#13 2014-10-10 05:33:15

cyker
Member
Registered: 2009-05-30
Posts: 86

Re: [SOLVED] Find modified files from a package in local file system

amish wrote:

Size difference does not always work! smile

Lets say original conf file had two lines:

Alert=true
#Alert=false

Now you changed it to:

#Alert=true
Alert=false

So size will remain same!!

So mod time is possibly better way to check! smile

Right. Actually diff is the best way to check but doesn't seem to be there.


.

Offline

#14 2014-10-10 05:37:44

amish
Member
Registered: 2014-05-10
Posts: 513

Re: [SOLVED] Find modified files from a package in local file system

Yup, wonder why --diff of tar is not extended to give actual diference!

Offline

#15 2014-10-10 06:35:04

progandy
Member
Registered: 2012-05-17
Posts: 5,317

Re: [SOLVED] Find modified files from a package in local file system

If you want to create your own tool to check packages, then you can start with something like this. Current packages should have an mtree database with a list of checksums.

zcat /var/lib/pacman/local/filesystem-2014.07-1/mtree | sed -n 's/^\([^ ]*\).*sha256digest=\(\w*\)/\2 \1/p' | (cd / && sudo sha256sum --quiet -c)

To clarify: That may be useful if you create a script to check one or two specific files from one package. If you do it manually, pacman -Qkk is simpler. When you have huge packages it may be preferrable to limit the checks to a few files, though.

Last edited by progandy (2014-10-10 06:47:48)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#16 2014-10-10 06:40:55

amish
Member
Registered: 2014-05-10
Posts: 513

Re: [SOLVED] Find modified files from a package in local file system

Thats too big command to remember!

Probably pacman -Qkk does the same internally.

Also he is looking for a way to find a "diff" easily.

Last edited by amish (2014-10-10 06:41:33)

Offline

#17 2014-10-11 00:31:05

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Find modified files from a package in local file system

See http://xyne.archlinux.ca/projects/pkg_scripts/ - pkg-extract_original may help:

$ type ddiff
ddiff is a function
ddiff ()
{
    LC_ALL=C TZ=GMT0 diff -Naur $1 <(pkg-extract_original $1) | less
}

e.g.

$ ddiff /etc/pacman.conf

Offline

#18 2014-10-11 00:45:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,459
Website

Re: [SOLVED] Find modified files from a package in local file system

amish wrote:

Thats too big command to remember!

That's what functions and aliases are for.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB