From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] profiles: Let canonicalize-profile return an absolute path. Date: Wed, 11 Jul 2018 13:06:22 +0200 Message-ID: <87tvp6m3pt.fsf@gnu.org> References: <87fu106vzk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdCx2-0007fO-5V for guix-devel@gnu.org; Wed, 11 Jul 2018 07:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdCx1-0001Cu-6r for guix-devel@gnu.org; Wed, 11 Jul 2018 07:06:28 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdCx1-0001Co-0N for guix-devel@gnu.org; Wed, 11 Jul 2018 07:06:27 -0400 In-Reply-To: <87fu106vzk.fsf@gnu.org> (Roel Janssen's message of "Tue, 03 Jul 2018 19:59:43 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Roel Janssen Cc: guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Roel, Roel Janssen skribis: > I'd like to change the way the symlinks to custom profiles are created. > Here's what currently happens: > > $ guixr package -i hello -p guix-profiles/test > $ ls -l guix-profiles > lrwxrwxrwx. 1 user group 25 Jul 3 19:53 test -> guix-profiles/test-1-link > lrwxrwxrwx. 1 user group 51 Jul 3 19:53 test-1-link -> /gnu/store/...6qb= aps-profile > > Now, that symlink is broken. > Instead, I'd like to have it always use absolute paths: How about instead making the link to the generation file (=E2=80=9Ctest-1-l= ink=E2=80=9D) always a relative symlink? Like this: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix package -p foo/x -i sed [...] $ ls -l foo/* lrwxrwxrwx 1 ludo users 8 Jul 11 13:03 foo/x -> x-1-link lrwxrwxrwx 1 ludo users 51 Jul 11 13:03 foo/x-1-link -> /gnu/store/qp6dqlbs= f0pw9p9fwc3gzdcaxx40rn9v-profile --8<---------------cut here---------------end--------------->8--- Patch below. FWIW I prefer avoiding =E2=80=98canonicalize-path=E2=80=99 in general becau= se it=E2=80=99s inefficient and because it can surprise the user: you can end up with a long file name that you didn=E2=80=99t type in, or you can have ENOENT erro= rs because =E2=80=98canonicalize-path=E2=80=99 requires the given file to exis= t. WDYT? Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/profiles.scm b/guix/profiles.scm index d2a794b18..f34f4fcff 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1521,7 +1521,7 @@ the generation that was current before switching." (profile profile) (generation number))))) (else - (switch-symlinks profile generation) + (switch-symlinks profile (basename generation)) current)))) (define (switch-to-previous-generation profile) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 29829f52c..b38a55d01 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -190,7 +190,7 @@ do not treat collisions in MANIFEST as an error." (let* ((entries (manifest-entries manifest)) (count (length entries))) (switch-symlinks name prof) - (switch-symlinks profile name) + (switch-symlinks profile (basename name)) (unless (string=? profile %current-profile) (register-gc-root store name)) (format #t (N_ "~a package in profile~%" diff --git a/tests/guix-package.sh b/tests/guix-package.sh index 3b3fa35cd..3833b568a 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -215,7 +215,7 @@ do guix package --bootstrap --roll-back ! test -f "$HOME/.guix-profile/bin" ! test -f "$HOME/.guix-profile/lib" - test "`readlink "$default_profile"`" = "$default_profile-0-link" + test "`readlink "$default_profile"`" = "`basename $default_profile-0-link`" done # Check whether '-p ~/.guix-profile' makes any difference. --=-=-=--