LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 880|回复: 4

arch有删除软件残馀配置文件的命令吗?其他解决方案也行!

[复制链接]
发表于 2008-9-26 13:55:46 | 显示全部楼层 |阅读模式
我的/目录是10G(包括home目录),但是现在就已经使用了43%了。软件也没安装那么多,gnome和KDE,Office那些胖子也没装,我就很奇怪是不是被有些没用的东西占据了。
发表于 2008-9-26 14:15:36 | 显示全部楼层
pacman -Scc 清除下载的安装包。

其实你安装gnome和kde4就已经非常庞大了,特别是kde4,包含很多软件
回复 支持 反对

使用道具 举报

发表于 2008-9-26 20:03:01 | 显示全部楼层
pacman -Rcu package.name
回复 支持 反对

使用道具 举报

发表于 2008-9-27 01:47:43 | 显示全部楼层
Here is a python script to clean the /var/cache/pacman/pkg directory while allowing you to specify how many package versions should be retained.

#!/usr/bin/env python
"""pkg_clean - a simple python script to clean up the /var/cache/pacman/pkg directory.
More versatile than 'pacman -Sc' in that you can select how many old versions
to keep.
Usage: pkg_clean {-p} {-v} <# of copies to keep>
  # of copies to keep - (required) how many generations of each package to keep
  -p - (optional) preview what would be deleted; forces verbose (-v) mode.
  -v - (optional) show deleted packages."""
# Note that the determination of package age is done by simply looking at the date-time
# modified stamp on the file. There is just enough variation in the way package version
# is done that I thought this would be simpler & just as good.
# Also note that you must be root to run this script.

import getopt
import os
import re
import sys

# cleanup does the actual pkg file deletion
def cleanup(run_list):
  # strictly speaking only the first of these globals needs to be listed.
  global n''deleted, opt''verbose, opt''preview, n''to_keep
  # return if the run_list is too short
  if len(run''list) <= n''to_keep: return
  # Build list of tuples (date-time file modified, file name)
  dtm''list = [(os.stat(tfn)[8], tfn) for tfn in run''list]
  # Sort the list by date-time
  dtm_list.sort()
  # Build list of the filenames to delete (all but last n''to''keep).
  kill''list = [tfn[1] for tfn in dtm''list[:-n''to''keep]]
  if opt''verbose: print kill''list
  n''deleted += len(kill''list)
  if not opt_preview:
    for dfn in kill_list:
      os.unlink(dfn)

######################################################################
# mainline processing

# process command line options
try:
  opts, pargs = getopt.getopt(sys.argv[1:], 'vp')
  opt_dict = dict(opts)
  opt''preview = opt''dict.has_key('-p')
  opt''verbose = opt''dict.has_key('-v')
  if opt''preview: opt''verbose = True
  if len(pargs) <code></code> 1:
    n''to''keep = pargs[0]
  else:
    raise getopt.GetoptError("missing required argument.")
  try:
    n''to''keep = int(n''to''keep)
    if n''to''keep <= 0: raise ValueError
  except ValueError, e:
    raise getopt.GetoptError("# of copies to keep must be numeric > 0!")
except getopt.GetoptError, msg:
  print "Error:",msg,"\n",''''doc''''
  sys.exit(1)

# change to the pkg directory & get a sorted list of its contents
os.chdir('/var/cache/pacman/pkg')
pkg_fns = os.listdir('.')
pkg_fns.sort()

# for pkg e.g. 'gnome-common-2.8.0-1.pkg.tar.gz' group(1) is 'gnome-common'.
bpat = re.compile(r'(.+)-[^-]+-.+\.pkg.tar.gz$')
n_deleted = 0
pkg''base''nm = ''
# now look for "runs" of the same package differing only in version info.
for run''end in range(len(pkg''fns)):
  fn = pkg''fns[run''end]
  mo = bpat.match(fn) # test for a match of the package name pattern
  if mo:
    tbase = mo.group(1) # gets the 'base' package name
    # is it a new base name, i.e. the start of a new run?
    if tbase != pkg''base''nm: # if so then process the prior run
      if pkg''base''nm != '':
        cleanup(pkg''fns[run''start:run_end])
      pkg''base''nm = tbase # & setup for the new run
      run''start = run''end
  else:
    print >>sys.stderr, "File '"+fn+"' doesn't match package pattern!"

# catch the final run of the list
run_end += 1
cleanup(pkg''fns[run''start:run_end])

if opt_verbose:
  print n_deleted,"files deleted."
回复 支持 反对

使用道具 举报

发表于 2008-9-27 11:13:56 | 显示全部楼层
楼上的代码是描述的撒子哟? 没有看懂~~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表