Hello community, here is the log from the commit of package setconf for openSUSE:Factory checked in at 2017-10-23 16:51:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/setconf (Old) and /work/SRC/openSUSE:Factory/.setconf.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "setconf" Mon Oct 23 16:51:56 2017 rev:9 rq:534930 version:0.7.5 Changes: -------- --- /work/SRC/openSUSE:Factory/setconf/setconf.changes 2017-05-10 20:53:31.537378852 +0200 +++ /work/SRC/openSUSE:Factory/.setconf.new/setconf.changes 2017-10-23 16:51:57.264440307 +0200 @@ -1,0 +2,12 @@ +Wed Oct 18 06:52:11 UTC 2017 - aavind...@gmail.com + +- Update to version 0.7.5 + * Can now uncomment configuration options with the -u flag. + * Uncommenting and setting values also works on Linux kernel + configuration (#CONFIG_KERNEL_XY is not set to CONFIG_KERNEL_XY=y). +- Mark python dependency +- Lint spec file +- Add copying-fsf.patch to fix warning about incorrect mailing address + for the FSF. + +------------------------------------------------------------------- Old: ---- setconf-0.7.4.tar.xz New: ---- copying-fsf.patch setconf-0.7.5.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ setconf.spec ++++++ --- /var/tmp/diff_new_pack.JLLbMo/_old 2017-10-23 16:51:57.744417844 +0200 +++ /var/tmp/diff_new_pack.JLLbMo/_new 2017-10-23 16:51:57.748417657 +0200 @@ -17,13 +17,16 @@ Name: setconf -Version: 0.7.4 +Version: 0.7.5 Release: 0 Summary: Utility to easily change settings in configuration files License: GPL-2.0+ Group: Development/Tools/Building Url: http://setconf.roboticoverlords.org/ Source: http://setconf.roboticoverlords.org/%{name}-%{version}.tar.xz +# UPSTREAM: https://github.com/xyproto/setconf/pull/10 +Patch0: copying-fsf.patch +Requires: python BuildArch: noarch %description @@ -32,6 +35,7 @@ %prep %setup -q +%patch0 -p1 gzip -d %{name}.1.gz %build @@ -42,7 +46,6 @@ install -Dpm 0644 %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1 %files -%defattr(-,root,root) %doc COPYING %{_bindir}/%{name} %{_mandir}/man?/%{name}.?%{?ext_man} ++++++ copying-fsf.patch ++++++ >From 78d50e0a8c35d3b64356d2511bcad6888839156b Mon Sep 17 00:00:00 2001 From: Avindra Goolcharan <aavind...@gmail.com> Date: Wed, 18 Oct 2017 02:57:15 -0400 Subject: [PATCH] COPYING: refresh file The FSF address has changed. This fixes it. --- COPYING | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/COPYING b/COPYING index d60c31a..d159169 100644 --- a/COPYING +++ b/COPYING @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to +the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not @@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE + + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names: This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General +library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. ++++++ setconf-0.7.4.tar.xz -> setconf-0.7.5.tar.xz ++++++ Binary files old/setconf-0.7.4/setconf.1.gz and new/setconf-0.7.5/setconf.1.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/setconf-0.7.4/setconf.py new/setconf-0.7.5/setconf.py --- old/setconf-0.7.4/setconf.py 2016-10-30 15:46:34.000000000 +0100 +++ new/setconf-0.7.5/setconf.py 2017-10-04 17:18:48.000000000 +0200 @@ -23,6 +23,7 @@ # Mar 2015 # Jun 2015 # Mar 2016 +# Oct 2017 # from sys import argv @@ -33,7 +34,7 @@ from decimal import Decimal from base64 import b64decode -VERSION = "0.7.4" +VERSION = "0.7.5" # TODO: Use optparse or argparse if shedskin is no longer a target. @@ -44,9 +45,12 @@ return x.encode("utf-8") return x + NL = bs(linesep_str) ASSIGNMENTS = [b'==', b'=>', b'+=', b'-=', b'?=', - b'=', b':=', b'::', b':'] + b'=', b':=', b'::', b':', b'is'] +SINGLE_LINE_COMMENTS = [b"#", b"//", b"--"] +MULTI_LINE_COMMENTS = [b"/*"] def parts(line, including_assignment=True): @@ -56,7 +60,7 @@ if not stripline: return None, None # Skip lines that start with #, // or /* - for commentsymbol in [b"#", b"//", b"/*"]: + for commentsymbol in SINGLE_LINE_COMMENTS + MULTI_LINE_COMMENTS: if stripline.startswith(commentsymbol): # Skip this line return None, None @@ -98,10 +102,6 @@ return parts(line, including_assignment)[0] -def secondpart(line, including_assignment=True): - return parts(line, including_assignment)[1] - - def changeline(line, newvalue): line = bs(line) newvalue = bs(newvalue) @@ -113,6 +113,10 @@ elif b"=\t" in line or b":\t" in line or b">\t" in line: return first + b"\t" + newvalue else: + # Special case for Linux kernel configuration files + if first.endswith(b" is"): + # Use "=" instead of "is" when setting a config value to "=y" for instance + first = first[:-3] + b"=" return first + newvalue else: return line @@ -145,6 +149,56 @@ return passes +def uncomment(lines, key): + """Given a list of lines and a key, uncomment lines starting with a single line comment.""" + key = bs(key) + + newlines = [] + for line in lines: + if not line.strip(): + newlines.append(line) + continue + else: + stripped = line.strip() + comment_markers = SINGLE_LINE_COMMENTS + # Strip away comment marker + space if possible, if not, just strip away the comment marker + for comment_marker in [x + b" " for x in comment_markers] + comment_markers: + if stripped.startswith(comment_marker): + # Use the line, with the comment stripped away + commentpos = line.find(comment_marker) + after_comment_marker = line[commentpos + len(comment_marker):] + stripped_contents = after_comment_marker.strip() + if stripped_contents.startswith(key): + newlines.append(line[:commentpos] + after_comment_marker) + break + else: + # No uncommenting, the regular case + newlines.append(line) + return newlines + + +def test_uncomment(): + testcontent = b"""y = 1 +// x = 42 + #CONFIG_EVERYTHING=y +z := 9 +""" + testcontent_changed = b"""y = 1 +// x = 42 + CONFIG_EVERYTHING="ABSOLUTELY NOT" +z := 9 +""" + passes = True + splitted = testcontent.split(NL) + splitted = uncomment(splitted, "CONFIG_EVERYTHING") + elements = change(splitted, "CONFIG_EVERYTHING", "\"ABSOLUTELY NOT\"") + a = bytes.join(b"", elements) + b = bytes.join(b"", testcontent_changed.split(NL)) + passes = passes and a == b + print("Uncomment passes: %s" % (passes)) + return passes + + def change(lines, key, value, define=False): key = bs(key) value = bs(value) @@ -197,6 +251,7 @@ print("Change passes: %s" % (passes)) return passes + def test_change_define(): passes = True @@ -213,7 +268,8 @@ print("Change define passes: %s" % (passes)) return passes -def changefile(filename, key, value, dummyrun=False, define=False): + +def changefile(filename, key, value, dummyrun=False, define=False, uncomment_first=False): """if dummyrun==True, don't write but return True if changes would have been made""" key = bs(key) @@ -234,7 +290,10 @@ elif not data.endswith(NL): final_nl = False # Change and write the file - changed_contents = NL.join(change(lines, key, value, define=define)) + if uncomment_first: + changed_contents = NL.join(change(uncomment(lines, key), key, value, define=define)) + else: + changed_contents = NL.join(change(lines, key, value, define=define)) # Only add a final newline if the original contents had one at the end if final_nl: changed_contents += NL @@ -298,6 +357,59 @@ return passes +def test_changefile_uncomment(): + # Test data + testcontent = b"""# y = 1 +// x = 42 + #DESTROY_EVERYTHING=y +# z := 123 +""" + testcontent_changed = b""" y = 2 +x = 9000 + #DESTROY_EVERYTHING=y +z := 7 +""" + filename = mkstemp()[1] + # Write the testfile + with open(filename, 'wb') as f: + f.write(testcontent) + # Change the file with changefile + changefile(filename, "x", "9000", uncomment_first=True) + changefile(filename, "DESTROY_EVERYTHING", "!IGNORED!", uncomment_first=False) + changefile(filename, "z", "7", uncomment_first=True) + changefile(filename, "y", "2", uncomment_first=True) + # Read the file + with open(filename, 'rb') as f: + newcontent = f.read().split(NL)[:-1] + # Do the tests + passes = True + passes = passes and newcontent == testcontent_changed.split(NL)[:-1] + print("Changefile and uncomment passes: %s" % (passes)) + return passes + + +def test_changefile_uncomment_kernel(): + # Test data + testcontent = b"""# CONFIG_KERNEL_XZ is not set +""" + testcontent_changed = b"""CONFIG_KERNEL_XZ=y +""" + filename = mkstemp()[1] + # Write the testfile + with open(filename, 'wb') as f: + f.write(testcontent) + # Change the file with changefile + changefile(filename, "CONFIG_KERNEL_XZ", "y", uncomment_first=True) + # Read the file + with open(filename, 'rb') as f: + newcontent = f.read().split(NL)[:-1] + # Do the tests + passes = True + passes = passes and newcontent == testcontent_changed.split(NL)[:-1] + print("Changefile kernel config passes: %s" % (passes)) + return passes + + def change_multiline(data, key, value, endstring=NL, verbose=True, searchfrom=0, define=False): data = bs(data) @@ -584,6 +696,9 @@ passes = passes and test_changefile_multiline() passes = passes and test_addline() passes = passes and test_latin1() + passes = passes and test_uncomment() + passes = passes and test_changefile_uncomment() + passes = passes and test_changefile_uncomment_kernel() if passes: print("All tests pass!") else: @@ -659,7 +774,7 @@ return strip_trailing_zeros(result) -def main(args=argv[1:], exitok=True): +def main(args=argv[1:]): if len(args) == 1: if args[0] in ["-t", "--test"]: tests() @@ -678,7 +793,7 @@ print("\t-a or --add\t\tadd the option if it doesn't exist") print("\t\t\t\tcreates the file if needed") print("\t-d or --define\t\tset a #define") - #print("\t-r or --remove\t\tremove the option if it exist") + print("\t-u or --uncomment\t\tuncomment the line first") print("") print("Examples:") print("\tsetconf Makefile.defaults NETSURF_USE_HARU_PDF NO") @@ -688,7 +803,7 @@ print("\tsetconf app.py NUMS \"[1, 2, 3]\" ']'") print("\tsetconf -a server.conf ABC 123") print("\tsetconf -d linux/printk.h CONSOLE_LOGLEVEL_DEFAULT=4") - #print("\tsetconf -r server.conf ABC") + print("\tsetconf -u kernel_config CONFIG_MAGIC_SYSRQ=y") print("") elif args[0] in ["-v", "--version"]: print(VERSION) @@ -730,7 +845,6 @@ create_if_missing(filename) assignment = None - special = None for ass in ASSIGNMENTS: if ass in keyvalue: assignment = ass @@ -753,7 +867,6 @@ keyvalue = bs(args[2]) assignment = None - special = None for ass in ASSIGNMENTS: if ass in keyvalue: assignment = ass @@ -765,6 +878,22 @@ # Change the #define value in the file changefile(filename, key, value, define=True) + elif args[0] in ["-u", "--uncomment"]: + filename = args[1] + keyvalue = bs(args[2]) + + assignment = None + for ass in ASSIGNMENTS: + if ass in keyvalue: + assignment = ass + break + if not assignment: + sysexit(2) + _, value = keyvalue.split(assignment, 1) + key = firstpart(keyvalue, False) + + # Uncomment the key in the file, then try to set the value + changefile(filename, key, value, uncomment_first=True) else: # Single line replace ("x 123") filename = args[0] @@ -788,6 +917,13 @@ data = f.read() if not has_key(data, key): addtofile(filename, keyvalue) + elif args[0] in ["-u", "--uncomment"]: + filename = args[1] + key = bs(args[2]) + value = bs(args[3]) + + # Uncomment the key in the file, then try to set the value + changefile(filename, key, value, uncomment_first=True) else: # Multiline replace filename = args[0] @@ -798,5 +934,6 @@ else: sysexit(1) + if __name__ == "__main__": main()