pastebinit: change upstream to maintained fork and add manpage

+41 -104
+28 -24
pkgs/tools/misc/pastebinit/default.nix
··· 1 1 { lib 2 2 , stdenv 3 - , fetchurl 4 - , fetchpatch 3 + , fetchFromGitHub 5 4 , python3 5 + , libxslt 6 + , docbook_xsl 7 + , installShellFiles 8 + , callPackage 6 9 }: 7 10 stdenv.mkDerivation rec { 8 - version = "1.5"; 11 + version = "1.6.2"; 9 12 pname = "pastebinit"; 10 13 11 - src = fetchurl { 12 - url = "https://launchpad.net/pastebinit/trunk/${version}/+download/${pname}-${version}.tar.bz2"; 13 - sha256 = "0mw48fgm9lyh9d3pw997fccmglzsjccf2y347gxjas74wx6aira2"; 14 + src = fetchFromGitHub { 15 + owner = pname; 16 + repo = pname; 17 + rev = version; 18 + hash = "sha256-vuAWkHlQM6QTWarThpSbY0qrxzej0GvLU0jT2JOS/qc="; 14 19 }; 15 20 16 - buildInputs = [ 17 - (python3.withPackages (p: [ p.distro ])) 21 + patches = [ 22 + ./use-drv-etc.patch 18 23 ]; 19 24 20 - patchFlags = [ "-p0" ]; 25 + nativeBuildInputs = [ 26 + libxslt 27 + installShellFiles 28 + ]; 21 29 22 - patches = [ 23 - # Required to allow pastebinit 1.5 to run on Python 3.8 24 - ./use-distro-module.patch 25 - # Required to remove the deprecation warning of FancyURLopener 26 - ./use-urllib-request.patch 27 - # Required because pastebin.com now redirects http requests to https 28 - (fetchpatch { 29 - name = "pastebin-com-https.patch"; 30 - url = "https://bazaar.launchpad.net/~arnouten/pastebinit/pastebin-com-https/diff/264?context=3"; 31 - sha256 = "0hxhhfcai0mll8qfyhdl3slmbf34ynb759b648x63274m9nd2kji"; 32 - }) 30 + buildInputs = [ 31 + (python3.withPackages (p: [ p.distro ])) 33 32 ]; 34 33 34 + buildPhase = '' 35 + xsltproc --nonet ${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl pastebinit.xml 36 + ''; 37 + 35 38 installPhase = '' 36 39 mkdir -p $out/bin 37 40 mkdir -p $out/etc 38 41 cp -a pastebinit $out/bin 42 + cp -a utils/* $out/bin 39 43 cp -a pastebin.d $out/etc 40 - substituteInPlace $out/bin/pastebinit --replace "'/etc/pastebin.d" "'$out/etc/pastebin.d" 44 + substituteInPlace $out/bin/pastebinit --subst-var-by "etc" "$out/etc" 45 + installManPage pastebinit.1 41 46 ''; 42 47 43 48 meta = with lib; { 44 - homepage = "https://launchpad.net/pastebinit"; 49 + homepage = "https://stgraber.org/category/pastebinit/"; 45 50 description = "A software that lets you send anything you want directly to a pastebin from the command line"; 46 - maintainers = with maintainers; [ raboof ]; 51 + maintainers = with maintainers; [ raboof samuel-martineau ]; 47 52 license = licenses.gpl2; 48 53 platforms = platforms.linux ++ lib.platforms.darwin; 49 - mainProgram = "pastebinit"; 50 54 }; 51 55 }
-14
pkgs/tools/misc/pastebinit/use-distro-module.patch
··· 1 - === modified file 'pastebinit' 2 - --- pastebinit 2018-07-04 00:46:08 +0000 3 - +++ pastebinit 2020-11-13 14:21:11 +0000 4 - @@ -38,8 +38,8 @@ 5 - 6 - # Now try to override it with a distributor pastebin 7 - try: 8 - - import platform 9 - - release = platform.linux_distribution()[0].lower() 10 - + import distro 11 - + release = distro.id() 12 - if release == 'debian': 13 - defaultPB = "paste.debian.net" 14 - elif release == 'fedora':
+13
pkgs/tools/misc/pastebinit/use-drv-etc.patch
··· 1 + diff --git a/pastebinit b/pastebinit 2 + index 4e5f9ce..fe06bd3 100755 3 + --- a/pastebinit 4 + +++ b/pastebinit 5 + @@ -91,7 +91,7 @@ try: 6 + # Files found later override files found earlier. 7 + pastebind = {} 8 + confdirs = [] 9 + - for confdir in ['/usr/share', '/usr/local/share'] \ 10 + + for confdir in ['@etc@', '/usr/share', '/usr/local/share'] \ 11 + + list(reversed(os.environ.get('XDG_DATA_DIRS', '').split(':'))) \ 12 + + list(reversed(os.environ.get('XDG_CONFIG_DIRS', '').split(':'))) \ 13 + + ['/etc', '/usr/local/etc',
-66
pkgs/tools/misc/pastebinit/use-urllib-request.patch
··· 1 - === modified file 'pastebinit' 2 - --- pastebinit 2018-07-04 00:46:08 +0000 3 - +++ pastebinit 2020-11-13 14:21:11 +0000 4 - @@ -23,15 +23,9 @@ 5 - from __future__ import print_function 6 - 7 - import sys 8 - -if sys.version[0] == "2": 9 - - from ConfigParser import NoOptionError 10 - - from ConfigParser import SafeConfigParser as ConfigParser 11 - - from urllib import urlencode 12 - - from urllib import FancyURLopener 13 - -else: 14 - - from configparser import ConfigParser, NoOptionError 15 - - from urllib.parse import urlencode 16 - - from urllib.request import FancyURLopener 17 - +from configparser import ConfigParser, NoOptionError 18 - +from urllib.parse import urlencode 19 - +from urllib.request import urlopen, Request 20 - 21 - # Set the default pastebin 22 - defaultPB = "pastebin.com" 23 - @@ -72,13 +66,6 @@ try: 24 - version = "1.5" 25 - configfile = os.path.expanduser("~/.pastebinit.xml") 26 - 27 - - # Custom urlopener to handle 401's 28 - - class pasteURLopener(FancyURLopener): 29 - - version = "Pastebinit v%s" % version 30 - - 31 - - def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): 32 - - return None 33 - - 34 - def preloadPastebins(): 35 - # Check several places for config files: 36 - # - global config in /etc/pastebin.d 37 - @@ -410,12 +397,18 @@ try: 38 - else: 39 - post_format = 'standard' 40 - 41 - - url_opener = pasteURLopener() 42 - + request = Request( 43 - + fetch_url, 44 - + method="POST", 45 - + headers={ 46 - + 'User-Agent': "Pastebinit v%s" % version 47 - + } 48 - + ) 49 - 50 - if post_format == 'json': 51 - if json: 52 - params = json.dumps(params) 53 - - url_opener.addheader('Content-type', 'text/json') 54 - + request.add_header('Content-type', 'text/json') 55 - else: 56 - print(_("Could not find any json library."), file=sys.stderr) 57 - sys.exit(1) 58 - @@ -428,7 +421,7 @@ try: 59 - print("POSTing to: %s\nParams: %s" % ( 60 - fetch_url, str(params)), file=sys.stderr) 61 - try: 62 - - page = url_opener.open(fetch_url, params) 63 - + page = urlopen(request, params.encode("utf-8")) 64 - except Exception as e: 65 - print(_("Failed to contact the server: %s") % e, file=sys.stderr) 66 - sys.exit(1)