~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to buildtools/wafsamba/stale_files.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
# encoding: utf-8
 
3
# Thomas Nagy, 2006-2010 (ita)
 
4
 
 
5
"""
 
6
Add a pre-build hook to remove all build files
 
7
which do not have a corresponding target
 
8
 
 
9
This can be used for example to remove the targets
 
10
that have changed name without performing
 
11
a full 'waf clean'
 
12
 
 
13
Of course, it will only work if there are no dynamically generated
 
14
nodes/tasks, in which case the method will have to be modified
 
15
to exclude some folders for example.
 
16
"""
 
17
 
 
18
import Logs, Build, os, samba_utils, Options, Utils
 
19
from Runner import Parallel
 
20
 
 
21
old_refill_task_list = Parallel.refill_task_list
 
22
def replace_refill_task_list(self):
 
23
    '''replacement for refill_task_list() that deletes stale files'''
 
24
 
 
25
    iit = old_refill_task_list(self)
 
26
    bld = self.bld
 
27
 
 
28
    if not getattr(bld, 'new_rules', False):
 
29
        # we only need to check for stale files if the build rules changed
 
30
        return iit
 
31
 
 
32
    if Options.options.compile_targets:
 
33
        # not safe when --target is used
 
34
        return iit
 
35
 
 
36
    # execute only once
 
37
    if getattr(self, 'cleanup_done', False):
 
38
        return iit
 
39
    self.cleanup_done = True
 
40
 
 
41
    def group_name(g):
 
42
        tm = self.bld.task_manager
 
43
        return [x for x in tm.groups_names if id(tm.groups_names[x]) == id(g)][0]
 
44
 
 
45
    bin_base = bld.bldnode.abspath()
 
46
    bin_base_len = len(bin_base)
 
47
 
 
48
    # paranoia
 
49
    if bin_base[-4:] != '/bin':
 
50
        raise Utils.WafError("Invalid bin base: %s" % bin_base)
 
51
    
 
52
    # obtain the expected list of files
 
53
    expected = []
 
54
    for i in range(len(bld.task_manager.groups)):
 
55
        g = bld.task_manager.groups[i]
 
56
        tasks = g.tasks_gen
 
57
        for x in tasks:
 
58
            try:
 
59
                if getattr(x, 'target'):
 
60
                    tlist = samba_utils.TO_LIST(getattr(x, 'target'))
 
61
                    for t in tlist:
 
62
                        p = os.path.join(x.path.abspath(bld.env), t)
 
63
                        p = os.path.normpath(p)
 
64
                        expected.append(p)
 
65
                for n in x.allnodes:
 
66
                    p = n.abspath(bld.env)
 
67
                    if p[0:bin_base_len] == bin_base:
 
68
                        expected.append(p)
 
69
            except:
 
70
                pass
 
71
 
 
72
    for root, dirs, files in os.walk(bin_base):
 
73
        for f in files:
 
74
            p = root + '/' + f
 
75
            if os.path.islink(p):
 
76
                link = os.readlink(p)
 
77
                if link[0:bin_base_len] == bin_base:
 
78
                    p = link
 
79
            if f in ['config.h']:
 
80
                continue
 
81
            if f[-2:] not in [ '.c', '.h' ]:
 
82
                continue
 
83
            if f[-7:] == '.inst.h':
 
84
                continue
 
85
            if p.find("/.conf") != -1:
 
86
                continue
 
87
            if not p in expected:
 
88
                Logs.warn("Removing stale file: %s" % p)
 
89
                os.unlink(p)
 
90
    return iit
 
91
 
 
92
 
 
93
def AUTOCLEANUP_STALE_FILES(bld):
 
94
    """automatically clean up any files in bin that shouldn't be there"""
 
95
    old_refill_task_list = Parallel.refill_task_list
 
96
    Parallel.refill_task_list = replace_refill_task_list
 
97
    Parallel.bld = bld
 
98
Build.BuildContext.AUTOCLEANUP_STALE_FILES = AUTOCLEANUP_STALE_FILES