unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] gnu: youtube-dl: Add native-search-paths.
@ 2015-12-13  3:24 Alex Vong
  2015-12-13  4:16 ` Ricardo Wurmus
  0 siblings, 1 reply; 11+ messages in thread
From: Alex Vong @ 2015-12-13  3:24 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1176 bytes --]

Hi,

I notice youtube-dl comes with a man page, bash completion file and
fish completion file. However, since it is located in a very werid
path, the programs normally wouldn't find it. So, I add
native-search-paths.

I can only confirm that MANPATH is working correctly. I don't know if
fish_complete_path works. I am only following what the documentation
says.

BASH_COMPLETION doesn't work. I think it has to do with the bash
completion package. From the bash completion README
<https://anonscm.debian.org/cgit/bash-completion/bash-completion.git/plain/README>,
it says package X install the bash completion file into the path
return by `pkg-config --variable=completionsdir bash-completion' or
`pkg-config --variable=compatdir bash-completion'. Both commands
return `/gnu/store/jyj96nxaw415yqi8vg6r73i1yib34k7i-bash-completion-2.1/share/bash-completion/completions'.
I think it should be point to something like
`~/.guix-profile/etc/bash_completion.d' instead so that other packages
could install their own bash completion file into
`/etc/bash_completion.d'. For instance, git install its own bash
completion file into that directory by default.

Any ideas?

Cheers,
Alex

[-- Attachment #2: 0001-gnu-youtube-dl-Add-native-search-paths.patch --]
[-- Type: text/x-patch, Size: 4540 bytes --]

From 5b04230e30fd594ebab43c50e84f989503dc3535 Mon Sep 17 00:00:00 2001
From: Alex Vong <alexvong1995@gmail.com>
Date: Sat, 12 Dec 2015 11:20:44 +0800
Subject: [PATCH] gnu: youtube-dl: Add native-search-paths.

* gnu/packages/video.scm (youtube-dl): Add native-search-paths.
[native-search-paths]: Add fish_complete_path and MANPATH.
---
 gnu/packages/video.scm | 73 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 18 deletions(-)

diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 76374e2..e30c1ce 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -24,6 +24,7 @@
 
 (define-module (gnu packages video)
   #:use-module (ice-9 match)
+  #:use-module (srfi srfi-26)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix utils)
   #:use-module (guix packages)
@@ -808,25 +809,61 @@ projects while introducing many more.")
     (home-page "http://www.webmproject.org/")))
 
 (define-public youtube-dl
-  (package
-    (name "youtube-dl")
-    (version "2015.12.09")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "http://youtube-dl.org/downloads/"
-                                  version "/youtube-dl-"
-                                  version ".tar.gz"))
-              (sha256
-               (base32
-                "11rzb30ik4all43r7bnsnm35mvs37y7xj3g9r7ig9jr7qlbhllwk"))))
-    (build-system python-build-system)
-    (native-inputs `(("python-setuptools" ,python-setuptools)))
-    (home-page "http://youtube-dl.org")
-    (synopsis "Download videos from YouTube.com and other sites")
-    (description
-     "Youtube-dl is a small command-line program to download videos from
+  (let* ((python-version "3.4")
+         (yt-dl-year "2015")
+         (yt-dl-month "12")
+         (yt-dl-day "09")
+         (make-version-string (lambda (string-list)
+                                (string-join string-list ".")))
+         (make-zero-trimmed-version-string (lambda (string-list)
+                                             (make-version-string
+                                              (map (cut string-trim <> #\0)
+                                                   string-list))))
+         (with-base-dir (lambda (relative-path)
+                          (string-append "lib/python"
+                                         python-version
+                                         "/site-packages/youtube_dl-"
+                                         (make-zero-trimmed-version-string
+                                          (list yt-dl-year
+                                                yt-dl-month
+                                                yt-dl-day))
+                                         "-py"
+                                         python-version
+                                         ".egg/"
+                                         relative-path))))
+    (package
+      (name "youtube-dl")
+      (version
+       (make-version-string (list yt-dl-year
+                                  yt-dl-month
+                                  yt-dl-day)))
+      (source (origin
+                (method url-fetch)
+                (uri (string-append "http://youtube-dl.org/downloads/"
+                                    version "/youtube-dl-"
+                                    version ".tar.gz"))
+                (sha256
+                 (base32
+                  "11rzb30ik4all43r7bnsnm35mvs37y7xj3g9r7ig9jr7qlbhllwk"))))
+      (build-system python-build-system)
+      (native-inputs `(("python-setuptools" ,python-setuptools)))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "fish_complete_path")
+              (files `(,(with-base-dir "etc/fish/completions"))))
+             ;; TODO: fix bash completion
+             ;;(search-path-specification
+             ;; (variable "BASH_COMPLETION") ;we need to fix it
+             ;; (files `(,(with-base-dir "etc/bash_completion.d"))))
+             (search-path-specification
+              (variable "MANPATH")
+              (files `(,(with-base-dir "share/man"))))))
+      (home-page "http://youtube-dl.org")
+      (synopsis "Download videos from YouTube.com and other sites")
+      (description
+       "Youtube-dl is a small command-line program to download videos from
 YouTube.com and a few more sites.")
-    (license license:public-domain)))
+      (license license:public-domain))))
 
 (define-public libbluray
   (package
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: [PATCH] gnu: youtube-dl: Add native-search-paths.
@ 2015-12-13 14:36 Alex Vong
  2015-12-13 16:13 ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: Alex Vong @ 2015-12-13 14:36 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

From 72c15c31d56c0b0e75766869060aba9693fc074e Mon Sep 17 00:00:00 2001
From: Alex Vong <alexvong1995@gmail.com>
Date: Sun, 13 Dec 2015 22:03:39 +0800
Subject: [PATCH] gnu: youtube-dl: Add phase to fix data_files paths so that
 man page and completion files are installed to the right place.

* gnu/packages/video.scm (youtube-dl) [arguments]: Add fix-data-files-paths
phase.
---
 gnu/packages/video.scm | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 76374e2..730348c 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -822,6 +822,29 @@ projects while introducing many more.")
     (build-system python-build-system)
     (native-inputs `(("python-setuptools" ,python-setuptools)))
     (home-page "http://youtube-dl.org")
+    (arguments
+     ;; The problem here is that the data_files paths are relative. Normally,
+     ;; this is fine. However, for some reason, setup.py uses the auto-detected
+     ;; sys.prefix instead of the user-defined "--prefix=FOO". So, we need to
+     ;; get the user-defined prefix in python and patch the data_files paths.
+     `(#:phases (modify-phases %standard-phases
+                  (add-before 'install 'fix-data-files-paths
+                    (lambda* _
+                      (substitute* "setup.py"
+                        (("import sys")
+                         "import sys
+import re
+
+map_ = lambda proc, ls: list(map(proc, ls))
+find = lambda pred, ls: next(filter(pred, ls))
+prefix = find(lambda x: bool(x),
+              map_(lambda string: re.match(r'^--prefix=(.*)$', string),
+                   sys.argv)).group(1)
+")
+                        (("'etc/")
+                         "prefix + '/etc/")
+                        (("'share/")
+                         "prefix + '/share/")))))))
     (synopsis "Download videos from YouTube.com and other sites")
     (description
      "Youtube-dl is a small command-line program to download videos from
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-12-16 11:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13  3:24 [PATCH] gnu: youtube-dl: Add native-search-paths Alex Vong
2015-12-13  4:16 ` Ricardo Wurmus
2015-12-13  4:21   ` Alex Vong
2015-12-13  5:00     ` Alex Vong
2015-12-14  9:09   ` Andreas Enge
2015-12-14 11:24     ` Alex Vong
  -- strict thread matches above, loose matches on Subject: below --
2015-12-13 14:36 Alex Vong
2015-12-13 16:13 ` Ludovic Courtès
2015-12-14 12:20   ` Alex Vong
2015-12-15 12:48     ` Ludovic Courtès
2015-12-16 11:49       ` Alex Vong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).