Re: [gentoo-portage-dev] sleep 1 in misc-functions.sh
On 10/20/2011 05:22 AM, Mike Frysinger wrote: On Thursday 20 October 2011 07:20:14 Fabian Groffen wrote: The full context of this message is from a thread on gentoo-alt ml: http://archives.gentoo.org/gentoo-alt/msg_db73b1a140fd958efb88f2437170646d. xml Long story short, this person has to deal with a fileserver that sets the rw world bits on for all files that are created. While I don't think the suggested patch is fair (this is obviously a very badly configured fileserver), I do wonder if the sleep 1 that is in the code is actually desired. In case we want it, I would suggest we move down the sleep 1 so it's only done once for the entire list with files. Can we use eqawarn in bin/misc-functions.sh:177 instead and avoid the sleep? or have it sleep once overall instead of per file -mike Fixed in git now: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a5968f7d9b1c17568fba27f7b7fd284b9431802d -- Thanks, Zac
Re: [gentoo-portage-dev] [PATCH 2 of 3] repoman: get ChangeLog header from skel.ChangeLog
On 19-10-2011 14:58:39 -0700, Zac Medico wrote: On 10/19/2011 12:55 PM, Fabian Groffen wrote: + if clold_lines[-1].strip(): + f.write(clold_lines[-1]) If the old ChangeLog happens to be an empty file, then clold_lines[-1] will raise IndexError. So, this is safer: if clold_lines and clold_lines[-1].strip(): I applied your fix, and moved it from the other patch in this one, where it belongs. -- Fabian Groffen Gentoo on a different level signature.asc Description: Digital signature
[gentoo-portage-dev] [PATCH] repoman: update copyright on modified files
To retain the behaviour of echangelog, update the copyrights on modified files (mostly ebuilds) when necessary. Also update the ChangeLog's copyright. diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -523,9 +523,77 @@ return outvcs +def update_copyright(fn_path, year, pretend): + + Check file for a Copyright statement, and update its year. The + patterns used for replacing copyrights are taken from echangelog. + Only the first lines of each file that start with a hash ('#') are + considered, until a line is found that doesn't start with a hash. + + + try: + fn_hdl = io.open(_unicode_encode(fn_path, + encoding=_encodings['fs'], errors='strict'), + mode='r', encoding=_encodings['repo.content'], errors='replace') + except EnvironmentError: + return + + orig_header = [] + new_header = [] + + for line in fn_hdl: + line_strip = line.strip() + orig_header.append(line) + if not line_strip or line_strip[:1] != '#': + new_header.append(line) + break + + # these two regexes are taken from + # echangelog update_copyright() + line = re.sub(r'^(# Copyright \d+) ', + r'\1-%s ' % year, line) + line = re.sub(r'^(# Copyright) \d\d\d\d-\d\d\d\d', + r'\1 1999-%s' % year, line) + new_header.append(line) + + difflines = 0 + for line in difflib.unified_diff(orig_header, new_header, + fromfile=fn_path, tofile=fn_path, n=0): + util.writemsg_stdout(line, noiselevel=-1) + difflines += 1 + util.writemsg_stdout(\n, noiselevel=-1) + + # unified diff has three lines to start with + if difflines 3 and not pretend: + # write new file with changed header + f, fnnew_path = mkstemp() + f = io.open(f, mode='w', encoding=_encodings['repo.content'], + errors='backslashreplace') + for line in new_header: + f.write(line); + for line in fn_hdl: + f.write(line) + f.close() + try: + fn_stat = os.stat(fn_path) + except OSError: + fn_stat = None + + shutil.move(fnnew_path, fn_path) + + if fn_stat is None: + util.apply_permissions(fn_path, mode=0o644) + else: + util.apply_stat_permissions(fn_path, fn_stat) + fn_hdl.close() + def UpdateChangeLog(pkgdir, category, package, new, removed, changed, \ msg, pretend, repodir): -Write an entry to an existing ChangeLog, or create a new one. + + Write an entry to an existing ChangeLog, or create a new one. + Updates copyright year on changed files, and updates the header of + ChangeLog with the contents of skel.ChangeLog. + # figure out who to write as if 'GENTOO_COMMITTER_NAME' in os.environ and \ @@ -548,6 +616,16 @@ logging.critical(err) return None + year = time.strftime('%Y') + date = time.strftime('%d %b %Y') + + # check modified files and the ChangeLog for copyright updates + # patches and diffs (identified by .patch and .diff) are excluded + for fn in new + changed: + if fn.endswith('.diff') or fn.endswith('.patch'): + continue + update_copyright(os.path.join(pkgdir, fn), year, pretend) + cl_path = os.path.join(pkgdir, 'ChangeLog') clold_lines = [] clnew_lines = [] @@ -584,8 +662,9 @@ clold_lines.append(line) if line_strip[:1] != '#': break - if clskel_file is None: - clnew_lines.append(line) + line = re.sub(r'^(# Copyright) \d\d\d\d-\d\d\d\d', + r'\1 1999-%s' % year, line) + clnew_lines.append(line) if not line_strip: break elif clskel_file is not None: @@ -597,7 +676,7 @@ line = line.replace('CATEGORY', category) line = line.replace('PACKAGE_NAME', package) line = re.sub(r'^(# Copyright \d\d\d\d)-\d\d\d\d ', - r'\1-%s ' % time.strftime('%Y'), line) +
Re: [gentoo-portage-dev] [PATCH] repoman: update copyright on modified files
On Thu, Oct 20, 2011 at 2:23 PM, Fabian Groffen grob...@gentoo.org wrote: To retain the behaviour of echangelog, update the copyrights on modified files (mostly ebuilds) when necessary. Also update the ChangeLog's copyright. diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -548,6 +616,16 @@ logging.critical(err) return None + year = time.strftime('%Y') + date = time.strftime('%d %b %Y') + echangelog calls time.strftime('%d %b %Y', gmtime) so that UTC is always used.
Re: [gentoo-portage-dev] [PATCH] repoman: update copyright on modified files
On 10/20/2011 11:55 AM, Mike Gilbert wrote: On Thu, Oct 20, 2011 at 2:23 PM, Fabian Groffen grob...@gentoo.org wrote: To retain the behaviour of echangelog, update the copyrights on modified files (mostly ebuilds) when necessary. Also update the ChangeLog's copyright. diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -548,6 +616,16 @@ logging.critical(err) return None + year = time.strftime('%Y') + date = time.strftime('%d %b %Y') + echangelog calls time.strftime('%d %b %Y', gmtime) so that UTC is always used. Thanks, the existing code is fixed in git now: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0f261405f63cd09639728da78e70a254cd3c5320 -- Thanks, Zac
Re: [gentoo-portage-dev] sleep 1 in misc-functions.sh
On 10/20/2011 07:18 AM, Zac Medico wrote: On 10/20/2011 05:22 AM, Mike Frysinger wrote: On Thursday 20 October 2011 07:20:14 Fabian Groffen wrote: The full context of this message is from a thread on gentoo-alt ml: http://archives.gentoo.org/gentoo-alt/msg_db73b1a140fd958efb88f2437170646d. xml Long story short, this person has to deal with a fileserver that sets the rw world bits on for all files that are created. While I don't think the suggested patch is fair (this is obviously a very badly configured fileserver), I do wonder if the sleep 1 that is in the code is actually desired. In case we want it, I would suggest we move down the sleep 1 so it's only done once for the entire list with files. Can we use eqawarn in bin/misc-functions.sh:177 instead and avoid the sleep? or have it sleep once overall instead of per file -mike Fixed in git now: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a5968f7d9b1c17568fba27f7b7fd284b9431802d Output is condensed now: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=44a03c9f2218ae7cfdc03aae495d255e0ca2e5b1 -- Thanks, Zac