From fcf18de4a44fcc496837fbb6eedcc01e5f6eb680 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 10 Mar 2019 00:30:24 +0100 Subject: [PATCH] Upgrade packages to 19.03 --- default.nix | 71 +++--- patches/terminal_velocity_fix_build.patch | 6 + .../terminal_velocity_python3_support.patch | 215 ++++++++++++++++++ .../terminal_velocity_sort_found_notes.patch | 16 +- 4 files changed, 266 insertions(+), 42 deletions(-) create mode 100644 patches/terminal_velocity_python3_support.patch diff --git a/default.nix b/default.nix index c8d8c8b..ad9bca7 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,5 @@ with import ./libs.nix; -with import {}; +with import {}; let mypkgs = {}; @@ -26,11 +26,13 @@ let } ); - mypkgs.weboob = pythonPackages.weboob.overrideAttrs (old: rec { - postInstall = ''${old.postInstall or ""} - mkdir -p $out/share/bash-completion/completions/ - cp tools/weboob_bash_completion $out/share/bash-completion/completions/weboob - ''; + mypkgs.weboob = (pythonPackages.weboob.overridePythonAttrs { + setupPyBuildFlags = [ "--no-qt" "--xdg" ]; + }).overrideAttrs (old: rec { + postInstall = ''${old.postInstall or ""} + mkdir -p $out/share/bash-completion/completions/ + cp tools/weboob_bash_completion $out/share/bash-completion/completions/weboob + ''; }); mypkgs.slrn = slrn.overrideAttrs (old: rec { @@ -61,7 +63,17 @@ let configureFlags = old.configureFlags ++ [ "--enable-plugins" ]; }); - mypkgs.weechat = nixpkgs_unstable.weechat.override { + mypkgs.weechat = (wrapWeechat ( + weechat-unwrapped.overrideAttrs (old: rec { + version = "2.3"; + name = "weechat-${version}"; + src = fetchurl { + url = "https://weechat.org/files/src/weechat-${version}.tar.bz2"; + sha256 = "0mi4pfnyny0vqc35r0scn6yy21y790a5iwq8ms7kch7b7z11jn9w"; + }; + patches = []; + }) + ) {}).override { configure = { availablePlugins, ... }: { plugins = with availablePlugins; [ (python.withPackages (ps: with ps; [websocket_client emoji])) @@ -89,18 +101,19 @@ let }; }; - mypkgs.terminal-velocity = with python2Packages; buildPythonApplication rec { + mypkgs.terminal-velocity = with python3Packages; buildPythonApplication rec { pname = "terminal-velocity-git"; version = "0.2.0"; patches = [ + ./patches/terminal_velocity_sort_found_notes.patch + ./patches/terminal_velocity_python3_support.patch # FIXME: update this patch when version changes ./patches/terminal_velocity_fix_build.patch - ./patches/terminal_velocity_sort_found_notes.patch ]; - propagatedBuildInputs = [ chardet urwid nixpkgs_unstable.python2Packages.sh pyyaml ]; - buildInputs = [ m2r restructuredtext_lint pygments ]; + propagatedBuildInputs = [ chardet urwid (sh.overridePythonAttrs { doCheck = false; }) pyyaml ]; + buildInputs = [ m2r (restructuredtext_lint.overridePythonAttrs { doCheck = false; }) pygments ]; postInstall = '' rm $out/bin/terminal_velocity @@ -456,9 +469,9 @@ let mypkgs.notmuch-vim = stdenv.mkDerivation rec { name = "notmuch-vim-${version}"; - version = nixpkgs_unstable.notmuch.version; + version = notmuch.version; outputs = [ "out" ]; - src = nixpkgs_unstable.notmuch.src; + src = notmuch.src; phases = [ "unpackPhase" "installPhase" ]; installPhase = '' make -C vim DESTDIR=$out prefix="/share/vim/vimfiles" install @@ -467,10 +480,10 @@ let mypkgs.notmuch-python2 = stdenv.mkDerivation rec { name = "notmuch-python2-${version}"; - version = nixpkgs_unstable.notmuch.version; + version = notmuch.version; outputs = [ "out" ]; buildInputs = [ python2Packages.sphinx python2Packages.python ]; - src = nixpkgs_unstable.notmuch.src; + src = notmuch.src; phases = [ "unpackPhase" "buildPhase" "installPhase" "fixupPhase" ]; buildPhase = '' cd bindings/python @@ -483,10 +496,10 @@ let mypkgs.notmuch-python3 = stdenv.mkDerivation rec { name = "notmuch-python3-${version}"; - version = nixpkgs_unstable.notmuch.version; + version = notmuch.version; outputs = [ "out" ]; - buildInputs = [ nixpkgs_unstable.python3Packages.sphinx nixpkgs_unstable.python3Packages.python ]; - src = nixpkgs_unstable.notmuch.src; + buildInputs = [ python3Packages.sphinx python3Packages.python ]; + src = notmuch.src; phases = [ "unpackPhase" "buildPhase" "installPhase" "fixupPhase" ]; buildPhase = '' cd bindings/python @@ -581,24 +594,8 @@ in inherit feh imagemagick; inherit lftp; stgit = gitAndTools.stgit; - # todo: lx* ?, unrar, unzip, zeromq? - #inherit nextcloud-client; - #inherit nixos; - } // (with nixpkgs_unstable; { - inherit googler; - inherit khal; - inherit newsboat; - inherit xmr-stak; - inherit urlwatch; - inherit graphicsmagick; - inherit ncmpc; - inherit solc; - inherit w3m lynx links; - inherit valgrind; - inherit ranger; - inherit strace; - inherit notmuch notmuch-mutt; - stgit = gitAndTools.stgit; inherit bundix; bower2nix = nodePackages.bower2nix; - }) + # todo: unrar, unzip + #inherit nixos; + } diff --git a/patches/terminal_velocity_fix_build.patch b/patches/terminal_velocity_fix_build.patch index 5c7f716..b08e0c4 100644 --- a/patches/terminal_velocity_fix_build.patch +++ b/patches/terminal_velocity_fix_build.patch @@ -1,3 +1,9 @@ +commit a64bf3d58f6ba7f5fa72fe5b89a3973cac0c1a99 +Author: Ismaël Bouya +Date: Sat Mar 9 20:13:52 2019 +0100 + + Remove mister_bump dependency + diff --git a/setup.py b/setup.py index 84a99e9..a783dff 100644 --- a/setup.py diff --git a/patches/terminal_velocity_python3_support.patch b/patches/terminal_velocity_python3_support.patch new file mode 100644 index 0000000..bd4aec7 --- /dev/null +++ b/patches/terminal_velocity_python3_support.patch @@ -0,0 +1,215 @@ +commit 6ca19964b9e8a7866fd7e21a3dac9ccd35f0d434 +Author: Ismaël Bouya +Date: Sat Mar 9 20:13:18 2019 +0100 + + Add python3 support + +diff --git a/terminal_velocity/notebook.py b/terminal_velocity/notebook.py +index b6226dc..11f76de 100644 +--- a/terminal_velocity/notebook.py ++++ b/terminal_velocity/notebook.py +@@ -60,51 +60,6 @@ import sys + import chardet + + +-def unicode_or_bust(raw_text): +- """Return the given raw text data decoded to unicode. +- +- If the text cannot be decoded, return None. +- +- """ +- encodings = ["utf-8"] +- for encoding in (sys.getfilesystemencoding(), sys.getdefaultencoding()): +- # I would use a set for this, but they don't maintain order. +- if encoding not in encodings: +- encodings.append(encoding) +- +- for encoding in encodings: +- if encoding: # getfilesystemencoding() may return None +- try: +- decoded = unicode(raw_text, encoding=encoding) +- return decoded +- except UnicodeDecodeError: +- pass +- +- # If none of those guesses worked, let chardet have a go. +- encoding = chardet.detect(raw_text)["encoding"] +- if encoding and encoding not in encodings: +- try: +- decoded = unicode(raw_text, encoding=encoding) +- logger.debug("File decoded with chardet, encoding was {0}".format( +- encoding)) +- return decoded +- except UnicodeDecodeError: +- pass +- except LookupError: +- pass +- +- # I've heard that decoding with cp1252 never fails, so try that last. +- try: +- decoded = unicode(raw_text, encoding="cp1252") +- logger.debug("File decoded with encoding cp1252") +- return decoded +- except UnicodeDecodeError: +- pass +- +- # If nothing worked then give up. +- return None +- +- + class Error(Exception): + """Base class for exceptions in this module.""" + pass +@@ -192,12 +147,12 @@ class PlainTextNote(object): + # subdirs) if they don't exist. + directory = os.path.split(self.abspath)[0] + if not os.path.isdir(directory): +- logger.debug(u"'{0} doesn't exist, creating it".format(directory)) ++ logger.debug("'{0} doesn't exist, creating it".format(directory)) + try: + os.makedirs(directory) + except os.error as e: + raise NewNoteError( +- u"{0} could not be created: {1}".format(directory, e)) ++ "{0} could not be created: {1}".format(directory, e)) + + # Create an empty file if the file doesn't exist. + open(self.abspath, 'a') +@@ -217,11 +172,11 @@ class PlainTextNote(object): + + @property + def contents(self): +- contents = unicode_or_bust(open(self.abspath, "r").read()) ++ contents = open(self.abspath, "rb").read().decode(errors='ignore') + if contents is None: + logger.error( +- u"Could not decode file contents: {0}".format(self.abspath)) +- return u"" ++ "Could not decode file contents: {0}".format(self.abspath)) ++ return "" + else: + return contents + +@@ -322,12 +277,12 @@ class PlainTextNoteBook(object): + + # Create notebook_dir if it doesn't exist. + if not os.path.isdir(self.path): +- logger.debug(u"'{0} doesn't exist, creating it".format(self.path)) ++ logger.debug("'{0} doesn't exist, creating it".format(self.path)) + try: + os.makedirs(self.path) + except os.error as e: + raise NewNoteBookError( +- u"{0} could not be created: {1}".format(self.path, e)) ++ "{0} could not be created: {1}".format(self.path, e)) + else: + # TODO: Check that self.path is a directory, if not raise. + pass +@@ -358,13 +313,12 @@ class PlainTextNoteBook(object): + abspath = os.path.join(root, filename) + relpath = os.path.relpath(abspath, self.path) + relpath, ext = os.path.splitext(relpath) +- unicode_relpath = unicode_or_bust(relpath) + if relpath is None: + # The filename could not be decoded. + logger.error( + "Could not decode filename: {0}".format(relpath)) + else: +- self.add_new(title=unicode_relpath, extension=ext) ++ self.add_new(title=relpath, extension=ext) + + @property + def path(self): +@@ -418,7 +372,7 @@ class PlainTextNoteBook(object): + for note in self._notes: + if note.title == title and note.extension == extension: + raise NoteAlreadyExistsError( +- u"Note already in NoteBook: {0}".format(note.title)) ++ "Note already in NoteBook: {0}".format(note.title)) + + # Ok, add the note. + note = PlainTextNote(title, self, extension) +diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py +index 5f0e213..9234bea 100755 +--- a/terminal_velocity/terminal_velocity.py ++++ b/terminal_velocity/terminal_velocity.py +@@ -1,7 +1,7 @@ +-#!/usr/bin/env python2 ++#!/usr/bin/env python3 + """A fast note-taking app for the UNIX terminal""" + from __future__ import print_function +-import ConfigParser ++import configparser + import argparse + import os + import logging +@@ -9,9 +9,9 @@ import logging.handlers + import sys + + #import terminal_velocity.urwid_ui as urwid_ui +-import urwid_ui ++from . import urwid_ui + +-from git import get_git_project_config, git_project_is_configured, fetch_changes, push_changes ++from .git import get_git_project_config, git_project_is_configured, fetch_changes, push_changes + + + def startup(): +@@ -37,7 +37,7 @@ def main(): + + # Parse the config file. + config_file = os.path.abspath(os.path.expanduser(args.config)) +- config = ConfigParser.SafeConfigParser() ++ config = configparser.ConfigParser() + config.read(config_file) + defaults = dict(config.items('DEFAULT')) + +diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py +index caebcb9..89bab35 100644 +--- a/terminal_velocity/urwid_ui.py ++++ b/terminal_velocity/urwid_ui.py +@@ -10,7 +10,7 @@ import logging + logger = logging.getLogger(__name__) + + import urwid +-import notebook ++from . import notebook + + + palette = [ +@@ -27,8 +27,6 @@ def system(cmd, loop): + + loop.screen.stop() + +- cmd = u"{0}".format(cmd) +- cmd = cmd.encode("utf-8") # FIXME: Correct encoding? + safe_cmd = shlex.split(cmd) + + logger.debug("System command: {0}".format(safe_cmd)) +@@ -114,7 +112,7 @@ class AutocompleteWidget(urwid.Edit): + + # When search bar is empty show placeholder text. + if not self.edit_text and not self.autocomplete_text: +- placeholder_text = u"Find or Create" ++ placeholder_text = "Find or Create" + return (placeholder_text, + [("placeholder", len(placeholder_text))]) + +@@ -186,7 +184,7 @@ class NoteFilterListBox(urwid.ListBox): + + def render(self, size, focus=False): + if len(self.list_walker) == 0: +- placeholder = placeholder_text(u"No matching notes, press Enter " ++ placeholder = placeholder_text("No matching notes, press Enter " + "to create a new note") + return placeholder.render(size) + return super(NoteFilterListBox, self).render(size, self.fake_focus) +@@ -399,7 +397,7 @@ class MainFrame(urwid.Frame): + # If the user has no notes yet show some placeholder text, otherwise + # show the note list. + if len(self.notebook) == 0: +- self.body = placeholder_text(u"You have no notes yet, to create " ++ self.body = placeholder_text("You have no notes yet, to create " + "a note type a note title then press Enter") + else: + self.body = urwid.Padding(self.list_box, left=1, right=1) diff --git a/patches/terminal_velocity_sort_found_notes.patch b/patches/terminal_velocity_sort_found_notes.patch index 8296d54..2bc563c 100644 --- a/patches/terminal_velocity_sort_found_notes.patch +++ b/patches/terminal_velocity_sort_found_notes.patch @@ -1,8 +1,14 @@ +commit 0f9df37046e58c8963aff93c649e5d3dbf2202bd +Author: Ismaël Bouya +Date: Sat Mar 9 20:11:46 2019 +0100 + + Add sorting option + diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py -index db2eb05..bb77dc6 100755 +index a53eda3..5f0e213 100755 --- a/terminal_velocity/terminal_velocity.py +++ b/terminal_velocity/terminal_velocity.py -@@ -75,6 +75,10 @@ the default default will be used""" +@@ -90,6 +90,10 @@ the default default will be used""" default=defaults.get("log_file", "~/.tvlog"), help="the file to log to (default: %(default)s)") @@ -13,15 +19,15 @@ index db2eb05..bb77dc6 100755 parser.add_argument("-p", "--print-config", dest="print_config", action="store_true", default=False, help="print your configuration settings then exit") -@@ -120,7 +124,7 @@ the default default will be used""" +@@ -138,7 +142,7 @@ the default default will be used""" try: urwid_ui.launch(notes_dir=args.notes_dir, editor=args.editor, extension=args.extension, extensions=args.extensions, - exclude=args.exclude) + exclude=args.exclude, sort=args.sort) except KeyboardInterrupt: - # Silence KeyboardInterrupt tracebacks on ctrl-c. - sys.exit() + # Run the shutdown hook + shutdown() diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py index 34cf4f6..caebcb9 100644 --- a/terminal_velocity/urwid_ui.py -- 2.41.0