summaryrefslogtreecommitdiff
path: root/cmdline/apt-mark
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-12-10 22:20:07 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2009-12-10 22:20:07 +0100
commit43be0ac4b37f3a82ae4a16e473c3d8e44637ce1b (patch)
tree7c0e75b291d132b6f1577fc2267f8ea0a60df459 /cmdline/apt-mark
parent9307ef07498d37c0b5e05b036195abaf7ad0105c (diff)
parenta0895a74fe95997a5d75e5b54c95afb9594554f6 (diff)
merged from the mvo branch (and contains all non-abi break changes from donkult)
Diffstat (limited to 'cmdline/apt-mark')
-rwxr-xr-xcmdline/apt-mark15
1 files changed, 10 insertions, 5 deletions
diff --git a/cmdline/apt-mark b/cmdline/apt-mark
index 226d2079b..3a818a3db 100755
--- a/cmdline/apt-mark
+++ b/cmdline/apt-mark
@@ -2,13 +2,14 @@
from optparse import OptionParser
+import sys
+import os.path
+
try:
import apt_pkg
except ImportError:
print "Error importing apt_pkg, is python-apt installed?"
-
-import sys
-import os.path
+ sys.exit(1)
actions = { "markauto" : 1,
"unmarkauto": 0
@@ -31,8 +32,12 @@ def mark_unmark_automatic(filename, action, pkgs):
" mark or unmark automatic flag"
# open the statefile
if os.path.exists(STATE_FILE):
- tagfile = apt_pkg.ParseTagFile(open(STATE_FILE))
- outfile = open(STATE_FILE+".tmp","w")
+ try:
+ tagfile = apt_pkg.ParseTagFile(open(STATE_FILE))
+ outfile = open(STATE_FILE+".tmp","w")
+ except IOError, msg:
+ print "%s, are you root?" % (msg)
+ sys.exit(1)
while tagfile.Step():
pkgname = tagfile.Section.get("Package")
autoInst = tagfile.Section.get("Auto-Installed")