5

I tried to install Gnome 3 on Debian Testing following this explanation. However, this didn't work and left me without any graphical user interface.

At the moment I try to fix that and I realised there is a long list of packages marked as manually installed. I stored a (line-break separated) list of the packages that – in my opinion – should be marked as auto installed (nearly all of them).

Now I want to run apt-mark auto for this list.

How do I do that?

P.S.: I also would appreciate if somebody tells me that this is not a good idea (if it isn't).

phk
  • 5,893
  • 7
  • 41
  • 70
Marcel
  • 1,114
  • 1
  • 14
  • 28

3 Answers3

7

You can use xargs:

 cat /path/to/file | xargs apt-mark auto

This should work if there is one package name per line in the text file /path/to/file.

Another option would be to use a for loop:

 for pkg in `cat /path/to/file`; do apt-mark auto $pkg; done

The second way might be useful if you have a similar problem where the command can't be called with a list of parameters but you have to call it once for each parameter you have. But in your case it's not that elegant of course… :)

Btw I assume that you are using bash.

Note: On my system apt-mark --help says:

Usage: apt-mark [options] {markauto|unmarkauto} packages...

And also:

apt-mark is deprecated, use apt-get markauto/unmarkauto.
phk
  • 5,893
  • 7
  • 41
  • 70
lumbric
  • 339
  • 5
  • 15
3

It sounds like you want to dump your list of files into apt-mark auto one at a time. This pseudo-code should get you started:

while read pkgname; do apt-mark auto $pkgname; done <list_of_packages
phk
  • 5,893
  • 7
  • 41
  • 70
pboin
  • 1,470
  • 1
  • 11
  • 12
1

Run the following script with python scriptname.py list-of-packages.txt as root:

import subprocess
import sys

filename = sys.argv[1]
with open(filename) as f:
    packages = f.read()
    packages = packages.split()
    packages = " ".join(packages)
    cmd = "apt-mark auto " + packages
    subprocess.call(cmd, shell=True)

I expect that this wouldn't be a problem since having GNOME implies that you already have Python installed.

tshepang
  • 64,472
  • 86
  • 223
  • 290