From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Pierre-Henry F." Subject: Re: [HELP] Packaging mupdf Date: Sun, 03 Mar 2019 08:52:02 +0000 Message-ID: References: <87mumcx6rv.fsf@elephly.net> Reply-To: "Pierre-Henry F." Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:54539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0Mr8-0003Qd-GX for help-guix@gnu.org; Sun, 03 Mar 2019 03:52:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0Mr7-0003Lo-4b for help-guix@gnu.org; Sun, 03 Mar 2019 03:52:22 -0500 Received: from mail4.protonmail.ch ([185.70.40.27]:59585) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h0Mr5-0003Il-Ul for help-guix@gnu.org; Sun, 03 Mar 2019 03:52:20 -0500 In-Reply-To: <87mumcx6rv.fsf@elephly.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Ricardo Wurmus Cc: "help-guix\\@gnu.org" Thank you for your reply! I documented my wondering around below and here is the gist of it: To update the ~freeglut~ package (found with: ~$ guix edit freeglut~) may m= ean to make guix do (the equivalent of) this: #+begin_src sh $ git clone --recursive git://git.ghostscript.com/mupdf.git $ cd mupdf $ git submodule update --init $ tar -zcf freeglut.tar.gz thirdparty/freeglut #+end_src so that the source field in the ~freeglut~ package: #+begin_src scheme (define-public freeglut (package (name "freeglut") (version "3.0.0") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/freeglut/freeglut/" version "/freeglut-" version ".tar.gz")) (sha256 =E2=80=A6 ))) =E2=80=A6)) #+end_src uses this ~freeglut.tar.gz~ instead of: #+begin_src scheme (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/freeglut/freeglut/" version "/freeglut-" version ".tar.gz")) (sha256 =E2=80=A6 ))) #+end_src How to update the package to that it does this? Thanks, PH *** mupdf Build and install ~mupdf~ with: ~$ guix package -i mupdf~ ~mupdf~ doesn't work properly because of [[https://bugs.archlinux.org/t= ask/57227][this bug]]. To make ~mupdf~ work as expected, it should be built against a patched = version of ~freeglut~. Let's check how ~mupdf~ is currently packaged: ~$ guix edit mupdf~. We notice this field that denotes a dependency to ~freeglut~: #+begin_src scheme (inputs `(=E2=80=A6 ("freeglut" ,freeglut) =E2=80=A6)) #+end_src According to the [[https://www.gnu.org/software/guix/manual/en/html_nod= e/Defining-Packages.html#Defining-Packages][documentation]], the ~inputs~ f= ield is a list of key-value pairs where keys are strings and values are packages. So, a ~freeglut~ packag= e should be defined. Let's find it: ~$ guix package -s freeglut~ gives two versions of ~freeglut~, boths of them with this field: ~locat= ion: gnu/packages/gl.scm:93:2~ wich tells us that ~#:use-module (gnu package= s gl)~ should be used where ~mupdf~ package is defined and it is. So, we need: - to update the ~mupdf~ package so that it uses the patched version of = ~freeglut~ - to update the ~freeglut~ package so that it uses patched version of ~= freeglut~ - find where to get the patched version of ~freeglut~ from. **** Patched version of freeglut Googling things gives [[https://bugs.ghostscript.com/show_bug.cgi?id= =3D699079][this link]] with this comment by Tor Andersson: #+begin_quote However, since you mention not being able to copy the selection at all= , you should be aware that you MUST build with OUR copy of FreeGLUT. The standard syst= em FreeGLUT does NOT have copy & paste support. We have added clipboard support to= our fork of FreeGLUT. I have tried to get our additions adopted upstream, but the = maintainers are slow to respond, so please use our version of freeglut when building m= updf. #+end_quote Tor Andersson seems to know what he is talking about since [[http://gi= t.ghostscript.com/?p=3Dmupdf.git;a=3Dsummary][he commits]] to the ~mupdf~ sources. The question becomes: how to fetch =C2=AB OUR copy of= FreeGLUT =C2=BB. Let's fetch ~mupdf~ sources and check the ~freeglut~ history there: #+begin_src sh $ git clone --recursive git://git.ghostscript.com/mupdf.git $ cd mupdf $ git submodule update --init $ cd thirdparty/freeglut $ git log #+end_src We notice in the logs: ~Import freeglut 3.0.0 from tarball.~ and commi= ts by Tor Andersson dealing with things useful for copy-pasting. So, we should modify the ~guix~ package definition of ~freeglut versio= n 3.0.0~ so that it uses this patched version of the ~freeglut~ sources. Since the ~freeglut~ that interests us is a submodule of the ~mupdf~ s= ources, let's refresh our memory with [[https://git-scm.com/book/en/v2/Git-Too= ls-Submodules][git documentation]]. We learned that to get the sources, we should do something like this in the ~freeglut~ guix packa= ge definition: #+id: 25eff785-d077-430e-aa2e-bfeb0eb07285 #+begin_src sh $ git clone --recursive git://git.ghostscript.com/mupdf.git $ cd mupdf $ git submodule update --init #+end_src Then use the sources from there. =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Saturday, March 2, 2019 11:15 PM, Ricardo Wurmus wr= ote: > > > Hi Pierre-Henry, > > > The problem with the way mupdf is package today[2] is that it > > does not include the patched version of freeglut that is > > necessary for the copy-pasting functionality[3]. > > What does work is to follow the build instructions of mupdf[4] > > which boils down to: > > git clone --recursive git://git.ghostscript.com/mupdf.git > > cd mupdf > > git submodule update --init > > sudo apt-get install mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev x= org-dev libxcursor-dev libxrandr-dev libxinerama-dev > > make prefix=3D~/bin/mupdf install > > So, I guess that the objective is to somehow make guix execute > > the above script. > > No, this would not work and would not be desirable. > > Our mupdf package is already built with freeglut. Instead of bundling a > patched version of freeglut with your variant of mupdf it would better > to keep the packages separate. > > Your first step would be to create a package variant of freeglut (use > =E2=80=9Cinherit=E2=80=9D to avoid duplication) that includes the patch = =E2=80=94 or maybe it > would make sense to patch freeglut for all its users, I don=E2=80=99t kno= w. > > Once that is done you can refer to the new freegut variant in your mupdf > variant package. > > Let me get back to the snippet you showed us: > > > git clone --recursive git://git.ghostscript.com/mupdf.git > > We express this with the package=E2=80=99s =E2=80=9Csource=E2=80=9D field= . > > (source (origin > (method git-fetch) > (uri (git-reference > (url "git://git.ghostscript.com/mupdf.git") > (commit the-commit-you-need))) > (file-name (git-file-name name version)) > (sha256 > (base32 > "=E2=80=A6the result of guix hash -rx . in the checkout=E2=80=A6")))) > > Let=E2=80=99s not do the recursive clone here, because we don=E2=80=99t a= ctually want > to include all of the submodules which bundle third party code. > > > cd mupdf > > We can ignore this. The =E2=80=9Cunpack=E2=80=9D build phase takes care o= f this > already. > > > git submodule update --init > > We don=E2=80=99t do that. If we really wanted to fetch submodules we woul= d > specify in the origin above that we want a recursive clone. > > > sudo apt-get install mesa-common-dev libgl1-mesa-dev > > libglu1-mesa-dev xorg-dev libxcursor-dev libxrandr-dev > > libxinerama-dev > > Since we aren=E2=80=99t using Debian we don=E2=80=99t run this ;) > Instead, we express this through the =E2=80=9Cinputs=E2=80=9D and = =E2=80=9Cnative-inputs=E2=80=9D > fields. > > > make prefix=3D~/bin/mupdf install > > The usual steps of the GNU build system (configure, make, make check, > make install) are implemented in the gnu-build-system, which we specify > as the value for the =E2=80=9Cbuild-system=E2=80=9D field. > > I encourage you to take a look at gnu/packages/pdf.scm, which contains a > definition for mupdf. It uses the gnu-build-system and changes its > behaviour via the =E2=80=9Carguments=E2=80=9D field (e.g. to pass extra o= ptions to > =E2=80=9Cmake=E2=80=9D, to delete build phases that don=E2=80=99t make se= nse here, to disable > tests, etc). > > Hope this helps! > > -------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------------ > > Ricardo