def chflags(cls, path, flags, opts=""): cmd = 'chflags %s %o %s' % (opts, flags, _shell_quote(path)) status, output = subprocess_getstatusoutput(cmd) if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK: return # Try to generate an ENOENT error if appropriate. if 'h' in opts: _os_merge.lstat(path) else: _os_merge.stat(path) # Make sure the binary exists. if not portage.process.find_binary('chflags'): raise portage.exception.CommandNotFound('chflags') # Now we're not sure exactly why it failed or what # the real errno was, so just report EPERM. e = OSError(errno.EPERM, output) e.errno = errno.EPERM e.filename = path e.message = output raise e
def _get_target(self): global VERSION if VERSION is not self: return VERSION if os.path.isdir(os.path.join(PORTAGE_BASE_PATH, '.git')): status, output = subprocess_getstatusoutput(( "cd %s ; git describe --tags || exit $? ; " + \ "if [ -n \"`git diff-index --name-only --diff-filter=M HEAD`\" ] ; " + \ "then echo modified ; git rev-list --format=%%ct -n 1 HEAD ; fi ; " + \ "exit 0") % _shell_quote(PORTAGE_BASE_PATH)) if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK: output_lines = output.splitlines() if output_lines: version_split = output_lines[0].split('-') if version_split: VERSION = version_split[0].lstrip('v') patchlevel = False if len(version_split) > 1: patchlevel = True VERSION = "%s_p%s" % (VERSION, version_split[1]) if len(output_lines ) > 1 and output_lines[1] == 'modified': head_timestamp = None if len(output_lines) > 3: try: head_timestamp = long(output_lines[3]) except ValueError: pass timestamp = long(time.time()) if head_timestamp is not None and timestamp > head_timestamp: timestamp = timestamp - head_timestamp if not patchlevel: VERSION = "%s_p0" % (VERSION, ) VERSION = "%s_p%d" % (VERSION, timestamp) return VERSION VERSION = 'HEAD' return VERSION
def _get_target(self): global VERSION if VERSION is not self: return VERSION if os.path.isdir(os.path.join(PORTAGE_BASE_PATH, '.git')): status, output = subprocess_getstatusoutput(( "cd %s ; git describe --tags || exit $? ; " + \ "if [ -n \"`git diff-index --name-only --diff-filter=M HEAD`\" ] ; " + \ "then echo modified ; git rev-list --format=%%ct -n 1 HEAD ; fi ; " + \ "exit 0") % _shell_quote(PORTAGE_BASE_PATH)) if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK: output_lines = output.splitlines() if output_lines: version_split = output_lines[0].split('-') if version_split: VERSION = version_split[0].lstrip('v') patchlevel = False if len(version_split) > 1: patchlevel = True VERSION = "%s_p%s" %(VERSION, version_split[1]) if len(output_lines) > 1 and output_lines[1] == 'modified': head_timestamp = None if len(output_lines) > 3: try: head_timestamp = long(output_lines[3]) except ValueError: pass timestamp = long(time.time()) if head_timestamp is not None and timestamp > head_timestamp: timestamp = timestamp - head_timestamp if not patchlevel: VERSION = "%s_p0" % (VERSION,) VERSION = "%s_p%d" % (VERSION, timestamp) return VERSION VERSION = 'HEAD' return VERSION