[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Removing deb-multimedia pkgs w/o removing everything



On 09/16/12 22:32, Sharon Kimble wrote:
> On 15 September 2012 19:45, Dmitriy Matrosov <sgf.dma@gmail.com> wrote:
>> On 09/15/12 21:38, Andrei POPESCU wrote:
>>>
>>> On Sb, 15 sep 12, 12:53:46, Ed Jabbour wrote:
>>>>
>>>> I'd like to remove packages gotten from deb-multimedia and replace
>>>> some from the Debian repos.  However, removing them will also remove a
>>>> bunch  of libs and kde progs. E.g., apt-get remove libavcodec53
>>>> yields:
>>>>
>>>> 0 upgraded, 1 newly installed, 190 to remove and 1 not upgraded.
>>>>
>>>> I'm not up to reinstalling 190 packages.  apt-get install that pkg
>>>> just tells me that "libavcodec53 is already the newest version".  Is
>>>> there any way around this?  Is it possible to easily replace the deb-
>>>> multimedia pkgs with the Debian ones?
>>>
>>>
>>> It's possible. I've done it with aptitude by looking up each package
>>> from the list generated by the command below and selecting the Debian
>>> version instead of the deb-multimedia version.
>>>
>>>      aptitude search ~S~i~Omultimedia
>>>
>>> With apt-get you would have to build up a big command line like
>>>
>>>      apt-get install package1/version1 package2/versions ...
>>>
>>> because there are lots of interdependencies which would get in the way.
>>
>> You can find packages from deb-multimedia without aptitude as well. Like so
>>
>> $ dpkg-query -Wf '${Package}\n' \
>>      | xargs -d'\n' sh -euf -c '
>>             apt-cache showpkg "$@" \
>>                 | sed -ne"
>>                             s/^Package: //p;
>>                             /^Versions:/,/^Reverse Depends:/{
>> \_^[^[:space:]].*(/var/lib/dpkg/status)_p;
>>                             };" \
>>                 | sed -ne"N; /_deb.multimedia_/P;"
>>             ' sh
>>
> I tried this on a wheezy installation, and it failed, so I tried
> sending it to a 'dpkg.txt' and I got a null output on it although I
> know that I do have some files from that repository. I'd like to know
> how to get it working on wheezy please?

Ok. First, i'll explain what it does, and may be this will help you to fix it,
because this command relies on names and output formatting and is not very
reliable, to be honest.  I'll get list of all packages, like

    $ dpkg-query -Wf '${Package}\n' | head -n3
    ace-gperf
    acl
    acpi

then i execute short script. Though, script is executed for as many arguments as possible, this is just for performance reasons. I use `apt-cache showpkg`, because it displays version with path to corresponding repository (repository
'Packages' file in fact, cached in /var/lib/apt/lists) and, if package is
installed (see note [1]), path to dpkg status file (/var/lib/dpkg/status).
Let's see how it looks:

    # apt-cache showpkg hello
    Package: hello
    Versions:
2.8-2 (/var/lib/apt/lists/shilvana.local:3142_debian_dists_wheezy_main_binary-i386_Packages) (/var/lib/apt/lists/shilvana.local:3142_debian_dists_sid_main_binary-i386_Packages)
     Description Language: en
File: /var/lib/apt/lists/shilvana.local:3142_debian_dists_wheezy_main_i18n_Translation-en
                      MD5: b7df6fe7ffb325083a3a60819a7df548
     Description Language:
File: /var/lib/apt/lists/shilvana.local:3142_debian_dists_wheezy_main_binary-i386_Packages
                      MD5: b7df6fe7ffb325083a3a60819a7df548

2.6-1 (/var/lib/apt/lists/shilvana.local:3142_debian_dists_squeeze_main_binary-i386_Packages) (/var/lib/dpkg/status)
     Description Language: en
File: /var/lib/apt/lists/shilvana.local:3142_debian_dists_wheezy_main_i18n_Translation-en
                      MD5: b7df6fe7ffb325083a3a60819a7df548
     Description Language:
File: /var/lib/apt/lists/shilvana.local:3142_debian_dists_squeeze_main_binary-i386_Packages
                      MD5: b7df6fe7ffb325083a3a60819a7df548


    Reverse Depends:
<..>

the interesting lines are these two:

2.8-2 (/var/lib/apt/lists/shilvana.local:3142_debian_dists_wheezy_main_binary-i386_Packages) (/var/lib/apt/lists/shilvana.local:3142_debian_dists_sid_main_binary-i386_Packages) 2.6-1 (/var/lib/apt/lists/shilvana.local:3142_debian_dists_squeeze_main_binary-i386_Packages) (/var/lib/dpkg/status)

as you may see, they have the form:

    ^version (path) (path)

Now to choose only installed packages, i should check, that one of package's
version lines contain (/var/lib/dpkg/status). And to determine from what
repository package came from, i should check other path entries. Let's try it
with sed:

    apt-cache showpkg hello \
        | sed -ne"
                    s/^Package: //p;
                    /^Versions:/,/^Reverse Depends:/{
                        \_^[^[:space:]].*(/var/lib/dpkg/status)_p;
                    };
                "

I print package name, then for range starting at /^Versions:/ and ending at
/^Reverse Depends:/ i choose lines, which start not with [:space:] and contain
(/var/lib/dpkg/status). Result will look like:

    hello
2.6-1 (/var/lib/apt/lists/shilvana.local:3142_debian_dists_squeeze_main_binary-i386_Packages) (/var/lib/dpkg/status)

and now the only thing left is to choose lines, which i want. This is done by
the second sed. Also you should remember, that our "entries" are two-line:
first line is package name, and second - its version line. Here are several
examples.

For choosing all installed packages from wheezy, which are not in squeeze (have
different version or not present), you may use for 2nd sed following regexp

    "N; /_squeeze_/d; /_wheezy_/P;"

Hence, entire command will look like

    dpkg-query -Wf '${Package}\n' \
        | xargs -d'\n' sh -euf -c '
                apt-cache showpkg "$@" \
                    | sed -ne"
                                s/^Package: //p;
                                /^Versions:/,/^Reverse Depends:/{
\_^[^[:space:]].*(/var/lib/dpkg/status)_p;
                                };
                            " \
                    | sed -ne"N; /_squeeze_/d; /_wheezy_/P;"
            ' sh

or for finding all packages from backports you may use "N; /~bpo60/P;" (this
matches against package version instead of repository file path, as in
previous example):

    dpkg-query -Wf '${Package}\n' \
        | xargs -d'\n' sh -euf -c '
                apt-cache showpkg "$@" \
                    | sed -ne"
                                s/^Package: //p;
                                /^Versions:/,/^Reverse Depends:/{
\_^[^[:space:]].*(/var/lib/dpkg/status)_p;
                                };
                            " \
                    | sed -ne"N; /~bpo60/P;"
            ' sh

Returning to your question, why it does not work on wheezy - well, i don't
know. Second sed regexp, which i wrote for debian-multimedia, matches against
repository file path, so you should start with checking filenames in
/var/lib/apt/lists. I don't use debian-multimedia, and can't check whether
'_deb.multimedia_' regexp correctly matches or not. If it is not, try to
write the one, which matches. Or post here

    $ ls /var/lib/apt/lists/


[1]: Though, note, that (/var/lib/dpkg/status) file will be listed in
`apt-cache showpkg` output even for uninstalled packages, which config files
still present. E.g.  for status, like:

    Status: deinstall ok config-files


Reply to: