diff mbox series

[bug#68577,1/2] gnu: icecat: Improve inheritance.

Message ID bf4ece1c1f3697febf5e5bd06eb34f6e428de23f.1705619435.git.clement@lassieur.org
State New
Headers show
Series gnu: Add Mullvad Browser. | expand

Commit Message

Clément Lassieur Jan. 18, 2024, 11:19 p.m. UTC
* gnu/packages/gnuzilla.scm (make-icecat-minimal): New procedure, export it.
[arguments]: Split the ‘configure’ phase into several phases: ‘setenv’,
‘mozconfig’ and ‘configure’.  In the ‘wrap-program’ and ‘install-icons’
phases, replace "icecat", "browser/branding/official" with ‘#$moz-app-name’
and ‘#$branding-directory’.  Clean the ‘install-icons’ phase to help
inheritance.
(icecat-minimal): Call the ‘make-icecat-minimal’ procedure.
* gnu/packages/tor.scm (make-torbrowser): New procedure.
[base]: New variable corresponding to an ‘icecat-minimal’ with correct
inheritance values.
[arguments]: Replace ‘icecat-minimal’ with ‘base’.  Change "torbrowser", "Tor
Browser", "tb-release", ‘#$version’, ‘#$torbrowser-assets’,
‘#$%torbrowser-locales’ with ‘#$moz-app-name’, ‘#$moz-app-remotingname’,
‘#$branding-directory’, ‘#$base-browser-version’, ‘#$assets’ and ‘#$locales’.
Adapt phases with regard to the ‘icecat-minimal’ changes.  Split the
‘deploy-assets’ and the ‘autoconfig’ phases so to make inheritance easier.
[inputs]: Inherit ‘base’ inputs instead of ‘icecat-minimal’.
(torbrowser): Call the ‘make-torbrowser’ procedure.

Change-Id: I5fcf73e53fe4481a18e13cdeb3515c3dc4430090
---
 gnu/packages/gnuzilla.scm |  66 ++++++++-------
 gnu/packages/tor.scm      | 171 ++++++++++++++++++--------------------
 2 files changed, 116 insertions(+), 121 deletions(-)

Comments

Mark H Weaver Jan. 22, 2024, 6:09 a.m. UTC | #1
Hi Clément,

I see now that in November, you added 'torbrowser', which inherits from
'icecat-minimal'.

> commit 756ba0429e84ee0f8ce30484439b78c00c61d286
> Author: Clément Lassieur <clement@lassieur.org>
> Date:   Sun Nov 12 02:23:27 2023 +0100
> 
>     gnu: Add torbrowser.
>     
>     * gnu/packages/tor.scm (torbrowser): New variable.
>     (torbrowser-assets): New variable.
>     * gnu/packages/browser-extensions.scm (noscript): New variable.
>     (noscript/icecat): New variable.
>     
>     Co-authored-by: André Batista <nandre@riseup.net>
>     Change-Id: I73dc53905e4a028108bb34aae07e44256cf16c85

Did you consult me on this change?  I don't remember seeing anything
about this in my mailbox.

This change concerns me, because it compels me to coordinate with you
when making nontrivial IceCat updates.  As things stand now, it seems
that the 'icecat' and 'torbrowser' packages must be updated together,
in lock step.

Also, do 'torbrowser' and 'mullvad' both comply with the requirements of
the GNU FSDG?  For example, do they support EME?  Do they steer the user
to nonfree software, e.g. nonfree addons.

      Thanks,
        Mark
Clément Lassieur Jan. 22, 2024, 11:25 a.m. UTC | #2
On Mon, Jan 22 2024, Mark H Weaver wrote:

> Hi Clément,
>
> I see now that in November, you added 'torbrowser', which inherits from
> 'icecat-minimal'.
>
>> commit 756ba0429e84ee0f8ce30484439b78c00c61d286
>> Author: Clément Lassieur <clement@lassieur.org>
>> Date:   Sun Nov 12 02:23:27 2023 +0100
>> 
>>     gnu: Add torbrowser.
>>     
>>     * gnu/packages/tor.scm (torbrowser): New variable.
>>     (torbrowser-assets): New variable.
>>     * gnu/packages/browser-extensions.scm (noscript): New variable.
>>     (noscript/icecat): New variable.
>>     
>>     Co-authored-by: André Batista <nandre@riseup.net>
>>     Change-Id: I73dc53905e4a028108bb34aae07e44256cf16c85
>
> Did you consult me on this change?  I don't remember seeing anything
> about this in my mailbox.

Well

- You didn't reply to
  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66408, which was an
  Icecat substantial change, sent on October 8.

- It took you 50 days to reply to
  https://lists.gnu.org/archive/html/gnuzilla-dev/2023-11/index.html
  (And it's not like this mailing list was full of messages.)

- My Tor Browser work was started and pushed before I got your first
  reply.

- The Tor Browser thread is from 2020, so you had plenty of time to look
  at it.

- You are not on the Mozilla Team:
  https://git.savannah.gnu.org/cgit/guix.git/tree/etc/teams.scm.

So I believe it's perfectly understandable that at that time (Novembre -
December 2023) I didn't think it was worth CCing you.

Please note: now that you have replied to me at least once, I'm CCing
you again for the Mullvad work.

> This change concerns me, because it compels me to coordinate with you
> when making nontrivial IceCat updates.  As things stand now, it seems
> that the 'icecat' and 'torbrowser' packages must be updated together,
> in lock step.

In common, we have:
  - the translation packages
  - a few phases

And we are both ESR based.  I don't worry too much about it and worst
case scenario is I'll use our own translation SHA.

That being said, I'm convinced that it's better (at least for Tor
Browser and Mullvad Browser) to not inherit the Icecat package.

> Also, do 'torbrowser' and 'mullvad' both comply with the requirements of
> the GNU FSDG?

I think so, if you think there is something else to do to comply, please
inform us.

> For example, do they support EME?

Of course not.

> Do they steer the user to nonfree software, e.g. nonfree addons.

No.

Well I should probably get rid of Mozzarella because there is a non-free
software there and it looks unmaintained. 
https://lists.gnu.org/archive/html/bug-gnuzilla/2024-01/msg00000.html
https://gitlab.trisquel.org/joeall/mozzarella

>
>       Thanks,
>         Mark
André Batista Jan. 22, 2024, 6:42 p.m. UTC | #3
Hi Mark,

seg 22 jan 2024 às 01:09:21 (1705896561), mhw@netris.org enviou:
> Hi Clément,
> 
> I see now that in November, you added 'torbrowser', which inherits from
> 'icecat-minimal'.
> 
> > commit 756ba0429e84ee0f8ce30484439b78c00c61d286
> > Author: Clément Lassieur <clement@lassieur.org>
> > Date:   Sun Nov 12 02:23:27 2023 +0100
> > 
> >     gnu: Add torbrowser.
> >     
> >     * gnu/packages/tor.scm (torbrowser): New variable.
> >     (torbrowser-assets): New variable.
> >     * gnu/packages/browser-extensions.scm (noscript): New variable.
> >     (noscript/icecat): New variable.
> >     
> >     Co-authored-by: André Batista <nandre@riseup.net>
> >     Change-Id: I73dc53905e4a028108bb34aae07e44256cf16c85
> 
> Did you consult me on this change?  I don't remember seeing anything
> about this in my mailbox.
> 
> This change concerns me, because it compels me to coordinate with you
> when making nontrivial IceCat updates.  As things stand now, it seems
> that the 'icecat' and 'torbrowser' packages must be updated together,
> in lock step.
> 
> Also, do 'torbrowser' and 'mullvad' both comply with the requirements of
> the GNU FSDG?  For example, do they support EME?  Do they steer the user
> to nonfree software, e.g. nonfree addons.

Considering I was cc'ed and part of the thread that led to that patch,
I'll consider myself invited to give a piece of my mind on your
comments.

First things first: when I sent the very first version of this patch, I
didn't use inheritance anywhere and it was actually suggested to me as
an improvement over what I had done[1]. I agreed to it and changed my
patch to inherit from Icecat. Way later, Clément followed on the same
reasoning and previous discussions on the thread. No one opposed it.

Looking back, it is true I should have probably known better and have you
cc'ed right from the start. My code was heavily based on / similar to
Icecat's package definition and so it made sense to avoid duplication.
I didn't know and did not care to look who were the contributors to
Icecat's definition. I see now that I was careless and that my behaviour
could be seen as disrespectful. No disrespect was intended, but I
certainly could have done better and I do apologize for my shortcomings.

Clément's rescue of that thread was a lesson to me in that they made an
effort to put forward all previous work and give clear attribution to
others[2]. I was certainly glad they cc'ed me and gave me attribution
even though I think it would have been legitimate if they had done
otherwise since their code was sufficiently distinct from mine.

Now, do you believe me when I say that there was no ill will towards you
or others?

I ask this because your last comments strike me on the opposite sense.
Risking to add insult to injury, but in the hopes of gaining your help,
I'd say that your comments appear to be assuming ill intention on our
part towards you and somewhat belittle you at the same time.

Why do you assume to be compelled to do anything if you were not even
cc'ed? As things stand, my assumption here is that the burden would be
on us to either ask you directly or to keep a close eye on any changes
done to Icecat. IMO, you certainly wouldn't be to blame if you changed
something on Icecat and torbrowser/mullvad/librewolf had some issue. We
would.

You have put a very good point in saying that it could be better for us
to disentangle those packages to avoid future surprises and lessen
maintainance burden, but the way you wrote it seemed to imply that we
were trying to forcefully push work upon you, with little evidence of
that being the case.

On the other hand, would it really be that much of added work if we were
to ask you to copy us when proposing some changes to Icecat? Would it be
presumptuous or forceful to ask that? In my view it wouldn't as it also
wouldn't be any obligation of yours to comply with it. If you said: "I'll
try to remeber, but cannot guarantee it, so do your part and keep an eye
on Icecat", that would've been fine to me at least.

More than that, it suprises me that after discovering these threads and
having a good amount of knowledge on building Icecat you've decided to
just lash out on us, instead of trying to be of help, reviewing the
proposed patches or letting we learn from our short-sightedness the hard
way.

Maybe you have too much on your plate already, maybe you thought we were
neglectful, irresponsible. Maybe past experiences made you say what you
said. Whatever it is, I feel your approach to it was a bit antagonistic
towards us for the reasons I've put above. You are not compelled to
answer me nor to give any thought to my feelings. You owe me nothing.
However, I know your help would be more valuable to guixen than mine,
were you willing and in a situation to do so. So please, if possible,
help us out. If not, please take care not to put others down or against
you. Even the ablest of programmers can benefit from the good will of
those of lesser abilities. At least that's what I believe and what I
wanted to communicate to you here in the hopes to have a net gain for us
all.

Kind regards,

1. https://lists.gnu.org/archive/html/guix-patches/2020-09/msg00261.html
2. https://lists.gnu.org/archive/html/guix-patches/2023-12/msg00669.html
Mark H Weaver Feb. 3, 2024, 7:28 p.m. UTC | #4
Hi André,

First, let me say that I appreciate you and your contributions to Guix.
I'm sorry that my message made you feel badly.  That's not an apology,
but rather a sincere feeling of sadness that your feelings were hurt.

André Batista <nandre@riseup.net> writes:

> seg 22 jan 2024 às 01:09:21 (1705896561), mhw@netris.org enviou:
>> Hi Clément,
>> 
>> I see now that in November, you added 'torbrowser', which inherits from
>> 'icecat-minimal'.
>> 
>> > commit 756ba0429e84ee0f8ce30484439b78c00c61d286
>> > Author: Clément Lassieur <clement@lassieur.org>
>> > Date:   Sun Nov 12 02:23:27 2023 +0100
>> > 
>> >     gnu: Add torbrowser.
>> >     
>> >     * gnu/packages/tor.scm (torbrowser): New variable.
>> >     (torbrowser-assets): New variable.
>> >     * gnu/packages/browser-extensions.scm (noscript): New variable.
>> >     (noscript/icecat): New variable.
>> >     
>> >     Co-authored-by: André Batista <nandre@riseup.net>
>> >     Change-Id: I73dc53905e4a028108bb34aae07e44256cf16c85
>> 
>> Did you consult me on this change?  I don't remember seeing anything
>> about this in my mailbox.

Please note that this was simply a question, and not a rhetorical one.
I asked the question because I do not want to assume that my failure to
see an email implies that it was not sent to me.  Any email can be lost
due to spam filters, a man-in-the-middle who wishes to prevent delivery,
or because the recipient overlooks it among the torrent of (mostly junk)
mail that many of us receive.

>> This change concerns me, because it compels me to coordinate with you
>> when making nontrivial IceCat updates.  As things stand now, it seems
>> that the 'icecat' and 'torbrowser' packages must be updated together,
>> in lock step.
>> 
>> Also, do 'torbrowser' and 'mullvad' both comply with the requirements of
>> the GNU FSDG?  For example, do they support EME?  Do they steer the user
>> to nonfree software, e.g. nonfree addons.
>
> Considering I was cc'ed and part of the thread that led to that patch,
> I'll consider myself invited to give a piece of my mind on your
> comments.

I'm glad that you did.  It is far better than letting unspoken feelings
fester indefinitely.  I'm sorry that I was too overloaded to respond
sooner.

> First things first: when I sent the very first version of this patch, I
> didn't use inheritance anywhere and it was actually suggested to me as
> an improvement over what I had done[1].
[...]
> 1. https://lists.gnu.org/archive/html/guix-patches/2020-09/msg00261.html

I looked at the messages in that thread from people other than you, but
I was unable to find any suggestion to use inheritance.  Can you point
to the specific message where inheritance was suggested?

What I do see is a suggestion by Ludovic to "think of ways to factorize
code with IceCat".  I agree with that suggestion, but not with the use
of inheritance.  Instead, I suggest creating a new (guix build icecat)
module, and moving some of the code from the build phases of IceCat into
Scheme procedures placed within that module.  Of course, please CC me on
any proposals along those lines.

> Looking back, it is true I should have probably known better and have you
> cc'ed right from the start. My code was heavily based on / similar to
> Icecat's package definition and so it made sense to avoid duplication.
> I didn't know and did not care to look who were the contributors to
> Icecat's definition. I see now that I was careless and that my behaviour
> could be seen as disrespectful. No disrespect was intended, but I
> certainly could have done better and I do apologize for my shortcomings.

For what it's worth, I don't believe that you were "careless" or
"disrespectful", nor do I think that an apology is warranted here.
As Clément correctly pointed out, I was not listed as a member of the
mozilla team, and that reason alone makes it understandable that I would
be overlooked.

FYI, I've just recently added myself to the 'mozilla' team.

> Now, do you believe me when I say that there was no ill will towards you
> or others?

Yes, and I never believed otherwise.  I have neither perceived ill will
from, nor felt ill will towards, you or Clément.

> I ask this because your last comments strike me on the opposite sense.
> Risking to add insult to injury, but in the hopes of gaining your help,
> I'd say that your comments appear to be assuming ill intention on our
> part towards you and somewhat belittle you at the same time.

I made no such assumption.

> Why do you assume to be compelled to do anything if you were not even
> cc'ed? As things stand, my assumption here is that the burden would be
> on us to either ask you directly or to keep a close eye on any changes
> done to Icecat. IMO, you certainly wouldn't be to blame if you changed
> something on Icecat and torbrowser/mullvad/librewolf had some issue. We
> would.

I would not feel compelled *by you*, but rather as an unintended
consequence of your actions, due to my own desire to not break other
packages while updating IceCat.

> On the other hand, would it really be that much of added work if we were
> to ask you to copy us when proposing some changes to Icecat? Would it be
> presumptuous or forceful to ask that?

The problem is partly due to my own (admittedly suboptimal) tendency to
procastinate performing major IceCat updates until shortly before the
previous ESR branch reaches end-of-life.  These major updates, which
occur approximately once per year, usually require substantial changes
to the IceCat package definition.  These changes are likely to break any
other packages that inherit from the IceCat package, unless all of the
inheriting packages are updated in lock-step within a single batch of
commits.

Theoretically, there is a window of 2-3 months when these major IceCat
updates could be done, and therefore it would theoretically be possible
to coordinate a lock-step update of IceCat, TorBrowser, and Mullvad at
the same time.  However, this would be an added burden on me, and I'm
unwilling to commit to doing this.

> More than that, it suprises me that after discovering these threads and
> having a good amount of knowledge on building Icecat you've decided to
> just lash out on us, instead of trying to be of help, reviewing the
> proposed patches or letting we learn from our short-sightedness the hard
> way.

This idea that I "lashed out" at you is unsupported by my actual words.
I think that you have made many assumptions about what I felt about you,
when in fact I merely asked a question, and then proceeded to explain
why the changes created a problem for me.

I do not deny that I was *mildly* displeased at not being informed in
advance about the changes you made.  Of course, I expect to be CC'd on
future updates that relate to the IceCat package, including any changes
that could add more burdens on me when modifying the IceCat package,
given that I feel a responsibility to try my best to avoid breaking
other packages.  However, I do not fault you in any way.

Anyway: thanks again, André and Clément, for your contributions to Guix.
I think well of you both, and I hope that this message will help to
clear up any misunderstandings between us.

    Sincerely,
       Mark
Clément Lassieur Feb. 7, 2024, 3:52 p.m. UTC | #5
On Sat, Feb 03 2024, Mark H Weaver wrote:

> Hi André,
>
> First, let me say that I appreciate you and your contributions to Guix.
> I'm sorry that my message made you feel badly.  That's not an apology,
> but rather a sincere feeling of sadness that your feelings were hurt.
>
> André Batista <nandre@riseup.net> writes:
>
>> seg 22 jan 2024 às 01:09:21 (1705896561), mhw@netris.org enviou:
>>> Hi Clément,
>>> 
>>> I see now that in November, you added 'torbrowser', which inherits from
>>> 'icecat-minimal'.
>>> 
>>> > commit 756ba0429e84ee0f8ce30484439b78c00c61d286
>>> > Author: Clément Lassieur <clement@lassieur.org>
>>> > Date:   Sun Nov 12 02:23:27 2023 +0100
>>> > 
>>> >     gnu: Add torbrowser.
>>> >     
>>> >     * gnu/packages/tor.scm (torbrowser): New variable.
>>> >     (torbrowser-assets): New variable.
>>> >     * gnu/packages/browser-extensions.scm (noscript): New variable.
>>> >     (noscript/icecat): New variable.
>>> >     
>>> >     Co-authored-by: André Batista <nandre@riseup.net>
>>> >     Change-Id: I73dc53905e4a028108bb34aae07e44256cf16c85
>>> 
>>> Did you consult me on this change?  I don't remember seeing anything
>>> about this in my mailbox.
>
> Please note that this was simply a question, and not a rhetorical one.
> I asked the question because I do not want to assume that my failure to
> see an email implies that it was not sent to me.  Any email can be lost
> due to spam filters, a man-in-the-middle who wishes to prevent delivery,
> or because the recipient overlooks it among the torrent of (mostly junk)
> mail that many of us receive.
>
>>> This change concerns me, because it compels me to coordinate with you
>>> when making nontrivial IceCat updates.  As things stand now, it seems
>>> that the 'icecat' and 'torbrowser' packages must be updated together,
>>> in lock step.
>>> 
>>> Also, do 'torbrowser' and 'mullvad' both comply with the requirements of
>>> the GNU FSDG?  For example, do they support EME?  Do they steer the user
>>> to nonfree software, e.g. nonfree addons.
>>
>> Considering I was cc'ed and part of the thread that led to that patch,
>> I'll consider myself invited to give a piece of my mind on your
>> comments.
>
> I'm glad that you did.  It is far better than letting unspoken feelings
> fester indefinitely.  I'm sorry that I was too overloaded to respond
> sooner.
>
>> First things first: when I sent the very first version of this patch, I
>> didn't use inheritance anywhere and it was actually suggested to me as
>> an improvement over what I had done[1].
> [...]
>> 1. https://lists.gnu.org/archive/html/guix-patches/2020-09/msg00261.html
>
> I looked at the messages in that thread from people other than you, but
> I was unable to find any suggestion to use inheritance.  Can you point
> to the specific message where inheritance was suggested?
>
> What I do see is a suggestion by Ludovic to "think of ways to factorize
> code with IceCat".  I agree with that suggestion, but not with the use
> of inheritance.  Instead, I suggest creating a new (guix build icecat)
> module, and moving some of the code from the build phases of IceCat into
> Scheme procedures placed within that module.  Of course, please CC me on
> any proposals along those lines.
>
>> Looking back, it is true I should have probably known better and have you
>> cc'ed right from the start. My code was heavily based on / similar to
>> Icecat's package definition and so it made sense to avoid duplication.
>> I didn't know and did not care to look who were the contributors to
>> Icecat's definition. I see now that I was careless and that my behaviour
>> could be seen as disrespectful. No disrespect was intended, but I
>> certainly could have done better and I do apologize for my shortcomings.
>
> For what it's worth, I don't believe that you were "careless" or
> "disrespectful", nor do I think that an apology is warranted here.
> As Clément correctly pointed out, I was not listed as a member of the
> mozilla team, and that reason alone makes it understandable that I would
> be overlooked.
>
> FYI, I've just recently added myself to the 'mozilla' team.
>
>> Now, do you believe me when I say that there was no ill will towards you
>> or others?
>
> Yes, and I never believed otherwise.  I have neither perceived ill will
> from, nor felt ill will towards, you or Clément.
>
>> I ask this because your last comments strike me on the opposite sense.
>> Risking to add insult to injury, but in the hopes of gaining your help,
>> I'd say that your comments appear to be assuming ill intention on our
>> part towards you and somewhat belittle you at the same time.
>
> I made no such assumption.
>
>> Why do you assume to be compelled to do anything if you were not even
>> cc'ed? As things stand, my assumption here is that the burden would be
>> on us to either ask you directly or to keep a close eye on any changes
>> done to Icecat. IMO, you certainly wouldn't be to blame if you changed
>> something on Icecat and torbrowser/mullvad/librewolf had some issue. We
>> would.
>
> I would not feel compelled *by you*, but rather as an unintended
> consequence of your actions, due to my own desire to not break other
> packages while updating IceCat.
>
>> On the other hand, would it really be that much of added work if we were
>> to ask you to copy us when proposing some changes to Icecat? Would it be
>> presumptuous or forceful to ask that?
>
> The problem is partly due to my own (admittedly suboptimal) tendency to
> procastinate performing major IceCat updates until shortly before the
> previous ESR branch reaches end-of-life.  These major updates, which
> occur approximately once per year, usually require substantial changes
> to the IceCat package definition.  These changes are likely to break any
> other packages that inherit from the IceCat package, unless all of the
> inheriting packages are updated in lock-step within a single batch of
> commits.
>
> Theoretically, there is a window of 2-3 months when these major IceCat
> updates could be done, and therefore it would theoretically be possible
> to coordinate a lock-step update of IceCat, TorBrowser, and Mullvad at
> the same time.  However, this would be an added burden on me, and I'm
> unwilling to commit to doing this.
>
>> More than that, it suprises me that after discovering these threads and
>> having a good amount of knowledge on building Icecat you've decided to
>> just lash out on us, instead of trying to be of help, reviewing the
>> proposed patches or letting we learn from our short-sightedness the hard
>> way.
>
> This idea that I "lashed out" at you is unsupported by my actual words.
> I think that you have made many assumptions about what I felt about you,
> when in fact I merely asked a question, and then proceeded to explain
> why the changes created a problem for me.
>
> I do not deny that I was *mildly* displeased at not being informed in
> advance about the changes you made.  Of course, I expect to be CC'd on
> future updates that relate to the IceCat package, including any changes
> that could add more burdens on me when modifying the IceCat package,
> given that I feel a responsibility to try my best to avoid breaking
> other packages.  However, I do not fault you in any way.
>
> Anyway: thanks again, André and Clément, for your contributions to Guix.
> I think well of you both, and I hope that this message will help to
> clear up any misunderstandings between us.

Thank you Mark for this message.  I was a bit rude in the one I sent you
just before (I indeed thought your question was rhetorical); for this I
apologize.  I hope we can work together to continue giving Guix high
quality web browsers, striving for privacy and freedom.

Kind regards,
Clément
diff mbox series

Patch

diff --git a/gnu/packages/gnuzilla.scm b/gnu/packages/gnuzilla.scm
index e3bc625bc0f5..71bf9ca99bbd 100644
--- a/gnu/packages/gnuzilla.scm
+++ b/gnu/packages/gnuzilla.scm
@@ -99,7 +99,8 @@  (define-module (gnu packages gnuzilla)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages sqlite)
   #:autoload (json parser) (json->scm)
-  #:export (all-mozilla-locales))
+  #:export (all-mozilla-locales
+            make-icecat-minimal))
 
 (define-public mozjs
   (package
@@ -720,7 +721,9 @@  (define icecat-source
                         "--sort=name"
                         icecat-dir)))))))))
 
-(define-public icecat-minimal
+(define* (make-icecat-minimal #:key
+                              moz-app-name
+                              branding-directory)
   (package
     (name "icecat-minimal")
     (version %icecat-version)
@@ -1013,16 +1016,11 @@  (define-public icecat-minimal
               (substitute* "build/RunCbindgen.py"
                 (("\"--frozen\",") ""))))
           (delete 'bootstrap)
-          (replace 'configure
+          (add-before 'configure 'setenv
             ;; configure does not work followed by both "SHELL=..." and
             ;; "CONFIG_SHELL=..."; set environment variables instead
-            (lambda* (#:key outputs configure-flags #:allow-other-keys)
-              (let* ((bash (which "bash"))
-                     (abs-srcdir (getcwd))
-                     (flags `(,(string-append "--prefix=" #$output)
-                              ,(string-append "--with-l10n-base="
-                                              abs-srcdir "/l10n")
-                              ,@configure-flags)))
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((bash (which "bash")))
                 (setenv "SHELL" bash)
                 (setenv "CONFIG_SHELL" bash)
 
@@ -1048,16 +1046,23 @@  (define-public icecat-minimal
                 (setenv "MOZBUILD_STATE_PATH"
                         (string-append (getcwd) "/.mozbuild"))
 
-                (format #t "build directory: ~s~%" (getcwd))
+                (format #t "build directory: ~s~%" (getcwd)))))
+          (add-before 'configure 'mozconfig
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (let ((flags `(,(string-append "--prefix=" #$output)
+                             ,(string-append "--with-l10n-base="
+                                             (getcwd) "/l10n")
+                             ,@configure-flags)))
                 (format #t "configure flags: ~s~%" flags)
 
                 (call-with-output-file "mozconfig"
                   (lambda (port)
                     (for-each (lambda (flag)
                                 (format port "ac_add_options ~a\n" flag))
-                              flags)))
-
-                (invoke "./mach" "configure"))))
+                              flags))))))
+          (replace 'configure
+            (lambda _
+              (invoke "./mach" "configure")))
           (replace 'build
             (lambda* (#:key (make-flags '()) (parallel-build? #t)
                       #:allow-other-keys)
@@ -1093,8 +1098,7 @@  (define-public icecat-minimal
                             (string-append #$output "/bin"))))
           (add-after 'install 'wrap-program
             (lambda* (#:key inputs #:allow-other-keys)
-              (let* ((lib (string-append #$output "/lib"))
-                     (gtk #$(this-package-input "gtk+"))
+              (let* ((gtk #$(this-package-input "gtk+"))
                      (gtk-share (string-append gtk "/share"))
                      (ld-libs '#$(cons
                                   (file-append
@@ -1112,7 +1116,8 @@  (define-public icecat-minimal
                                          ;; For the integration of native notifications
                                          ;; (same reason as icedove)
                                          "libnotify")))))
-                (wrap-program (car (find-files lib "^icecat$"))
+                (wrap-program (format #f "~a/lib/~a/~a"
+                                      #$output #$moz-app-name #$moz-app-name)
                   `("XDG_DATA_DIRS" prefix (,gtk-share))
                   ;; The following line is commented out because the icecat
                   ;; package on guix has been observed to be unstable when
@@ -1134,18 +1139,17 @@  (define-public icecat-minimal
                    "StartupNotify=true\nStartupWMClass=Icecat"))
                 (install-file desktop-file applications))))
           (add-after 'install-desktop-entry 'install-icons
-            (lambda _
-              (with-directory-excursion "browser/branding/official"
-                (for-each
-                 (lambda (file)
-                   (let* ((size (string-filter char-numeric? file))
-                          (icons (string-append #$output "/share/icons/hicolor/"
-                                                size "x" size "/apps")))
-                     (mkdir-p icons)
-                     (copy-file file (string-append icons "/icecat.png"))))
-                 '("default16.png" "default22.png" "default24.png"
-                   "default32.png" "default48.png" "content/icon64.png"
-                   "mozicon128.png" "default256.png"))))))))
+            (lambda* (#:key inputs #:allow-other-keys)
+              (for-each
+               (lambda (size)
+                 (let ((oldpath (string-append
+                                 #$branding-directory "/default" size ".png"))
+                       (newpath (string-append
+                                 #$output "/share/icons/hicolor/" size "x"
+                                 size "/apps/" #$moz-app-name ".png")))
+                   (mkdir-p (dirname newpath))
+                   (copy-file oldpath newpath)))
+               '("16" "22" "24" "32" "48" "64" "128" "256")))))))
     (native-search-paths
      (list (search-path-specification
             (variable "ICECAT_SYSTEM_DIR")
@@ -1169,6 +1173,10 @@  (define-public icecat-minimal
        (cpe-name . "firefox_esr")
        (cpe-version . ,(first (string-split version #\-)))))))
 
+(define-public icecat-minimal
+  (make-icecat-minimal #:moz-app-name "icecat"
+                       #:branding-directory "browser/branding/official"))
+
 (define %icecat-locales
   '("ach" "af" "an" "ar" "ast" "az" "be" "bg" "bn" "br" "bs" "ca" "cak"
     "ca-valencia" "cs" "cy" "da" "de" "dsb" "el" "en-CA" "en-GB" "eo" "es-AR"
diff --git a/gnu/packages/tor.scm b/gnu/packages/tor.scm
index 604be621157c..6eb0c7609f0b 100644
--- a/gnu/packages/tor.scm
+++ b/gnu/packages/tor.scm
@@ -562,9 +562,18 @@  (define torbrowser-assets
 Browser.")
     (license license:silofl1.1)))
 
-(define-public torbrowser
+(define* (make-torbrowser #:key
+                          moz-app-name
+                          moz-app-remotingname
+                          branding-directory
+                          assets
+                          locales
+                          base-browser-version)
+  (define base (make-icecat-minimal
+                #:moz-app-name moz-app-name
+                #:branding-directory branding-directory))
   (package
-    (inherit icecat-minimal)
+    (inherit base)
     (name "torbrowser")
     (version %torbrowser-version)
     (source
@@ -580,42 +589,45 @@  (define-public torbrowser
          "1c0p8aya7sh7nmawngkyzx2r02mvl9nd53hx2bl0jwvsj1vxxhca"))))
     (build-system mozilla-build-system)
     (arguments
-     (substitute-keyword-arguments (package-arguments icecat-minimal)
+     (substitute-keyword-arguments (package-arguments base)
        ((#:configure-flags flags '())
         #~(cons*
            "--without-relative-data-dir" ;store is read-only
            "--disable-base-browser-update"
            ;; Default is "default", which is the same as "nightly".
            "--enable-update-channel=release"
-           "--with-user-appdir=.torbrowser"
-           "--with-branding=browser/branding/tb-release"
+           ;; This is useless right now but it might be used in the future.
+           ;; (See nsAppFileLocationProvider.cpp.)
+           (string-append "--with-user-appdir=." #$moz-app-name)
+           (string-append "--with-branding=" #$branding-directory)
            (string-append "--prefix=" #$output)
-           (string-append "--with-base-browser-version=" #$version)
+           (string-append "--with-base-browser-version="
+                          #$base-browser-version)
            #$flags))
        ((#:phases phases)
         #~(modify-phases #$phases
-            (add-before 'configure 'setenv
+            (replace 'setenv
               (lambda _
                 (setenv "CONFIG_SHELL" (which "bash"))
                 ;; Install location is prefix/lib/$MOZ_APP_NAME.  Also
                 ;; $MOZ_APP_NAME is the executable name.  Default is
                 ;; "firefox".
-                (setenv "MOZ_APP_NAME" "torbrowser")
+                (setenv "MOZ_APP_NAME" #$moz-app-name)
                 ;; Profile location (relative to "~/.").  Default is
                 ;; lower($MOZ_APP_VENDOR/$MOZ_APP_BASENAME), which is:
                 ;; ~/.tor project/firefox.
-                (setenv "MOZ_APP_PROFILE" "torbrowser/browser")
+                (setenv "MOZ_APP_PROFILE" #$(in-vicinity
+                                             moz-app-name "browser"))
                 ;; WM_CLASS (default is "$MOZ_APP_NAME-$MOZ_UPDATE_CHANNEL").
-                (setenv "MOZ_APP_REMOTINGNAME" "Tor Browser")
+                (setenv "MOZ_APP_REMOTINGNAME" #$moz-app-remotingname)
                 ;; Persistent state directory for the build system (default is
                 ;; $HOME/.mozbuild).
                 (setenv "MOZBUILD_STATE_PATH"
                         (in-vicinity (getcwd) ".mozbuild"))
-                (setenv "MOZ_CHROME_MULTILOCALE"
-                        (string-join '#$%torbrowser-locales))
+                (setenv "MOZ_CHROME_MULTILOCALE" (string-join '#$locales))
                 ;; Make build reproducible.
                 (setenv "MOZ_BUILD_DATE" #$%moz-build-date)))
-            (add-before 'configure 'mozconfig
+            (replace 'mozconfig
               (lambda* (#:key configure-flags #:allow-other-keys)
                 (with-output-to-file "mozconfig"
                   (lambda ()
@@ -623,9 +635,6 @@  (define-public torbrowser
                     (for-each (lambda (flag)
                                 (format #t "ac_add_options ~a~%" flag))
                               configure-flags)))))
-            (replace 'configure
-              (lambda _
-                (invoke "./mach" "configure")))
             ;; See tor-browser-build/projects/firefox/build.
             (add-before 'configure 'copy-firefox-locales
               (lambda _
@@ -637,7 +646,7 @@  (define-public torbrowser
                                                (string-suffix? lang path))
                                              '#$all-mozilla-locales)
                                        (in-vicinity l10ncentral lang)))
-                   '#$%torbrowser-locales))))
+                   '#$locales))))
             (add-after 'copy-firefox-locales 'copy-basebrowser-locales
               (lambda _
                 (let ((l10ncentral ".mozbuild/l10n-central"))
@@ -661,7 +670,7 @@  (define-public torbrowser
                              "translation-base-browser/~a/*"
                              "~a/~a/browser/chrome/browser/"))
                        lang l10ncentral lang)))
-                   '#$%torbrowser-locales))))
+                   '#$locales))))
             (add-after 'copy-basebrowser-locales 'copy-torbrowser-locales
               (lambda _
                 (let ((l10ncentral ".mozbuild/l10n-central"))
@@ -698,7 +707,7 @@  (define-public torbrowser
                        (format port "  locale/~a/ (chrome/locale/~a/*)~%"
                                lang lang)
                        (close port)))
-                   '#$%torbrowser-locales))))
+                   '#$locales))))
             (add-before 'build 'fix-addons-placeholder
               (lambda _
                 (substitute*
@@ -717,13 +726,24 @@  (define-public torbrowser
               (lambda _
                 (system (string-join '("./mach package-multi-locale --locales"
                                        "en-US $MOZ_CHROME_MULTILOCALE")))))
-            (add-after 'install 'deploy-assets
+            (add-after 'install 'deploy-fonts
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((lib (string-append #$output "/lib/" #$moz-app-name)))
+                  ;; Fonts
+                  (copy-recursively (in-vicinity #$assets "fontconfig")
+                                    (in-vicinity lib "fontconfig"))
+                  (substitute* (in-vicinity lib "fontconfig/fonts.conf")
+                    (("<dir>fonts</dir>")
+                     (format #f "<dir>~a</dir>" (in-vicinity lib "fonts"))))
+                  (delete-file-recursively (in-vicinity lib "fonts"))
+                  (copy-recursively (in-vicinity #$assets "fonts")
+                                    (in-vicinity lib "fonts")))))
+            (add-after 'deploy-fonts 'deploy-tor-assets
               (lambda* (#:key inputs #:allow-other-keys)
                 (let ((lib (in-vicinity #$output "lib/torbrowser"))
                       (tor #$(this-package-input "tor-client")))
                   ;; TorBrowser/Data/Tor/torrc-defaults
-                  (copy-recursively (in-vicinity
-                                     #$torbrowser-assets "TorBrowser")
+                  (copy-recursively (in-vicinity #$assets "TorBrowser")
                                     (in-vicinity lib "TorBrowser"))
                   (substitute*
                       (in-vicinity lib "TorBrowser/Data/Tor/torrc-defaults")
@@ -733,20 +753,10 @@  (define-public torbrowser
                   ;; The geoip and geoip6 files are in the same directory as
                   ;; torrc-defaults.  (See TorProcess.sys.mjs.)
                   (mkdir-p (in-vicinity lib "TorBrowser/Data/Tor"))
-                  (copy-file (in-vicinity tor "share/tor/geoip")
-                             (in-vicinity lib "TorBrowser/Data/Tor/geoip"))
                   (copy-file (in-vicinity tor "share/tor/geoip6")
                              (in-vicinity lib "TorBrowser/Data/Tor/geoip6"))
-                  ;; Fonts
-                  (copy-recursively (in-vicinity
-                                     #$torbrowser-assets "fontconfig")
-                                    (in-vicinity lib "fontconfig"))
-                  (substitute* (in-vicinity lib "fontconfig/fonts.conf")
-                    (("<dir>fonts</dir>")
-                     (format #f "<dir>~a</dir>" (in-vicinity lib "fonts"))))
-                  (delete-file-recursively (in-vicinity lib "fonts"))
-                  (copy-recursively (in-vicinity #$torbrowser-assets "fonts")
-                                    (in-vicinity lib "fonts")))))
+                  (copy-file (in-vicinity tor "share/tor/geoip")
+                             (in-vicinity lib "TorBrowser/Data/Tor/geoip")))))
             (replace 'build-sandbox-whitelist
               (lambda* (#:key inputs #:allow-other-keys)
                 (define (runpath-of lib)
@@ -773,8 +783,8 @@  (define-public torbrowser
                       (display whitelist-string))))))
             (add-after 'install 'autoconfig
               (lambda* (#:key inputs #:allow-other-keys)
-                (let ((lib (in-vicinity #$output "lib/torbrowser"))
-                      (config-file "tor-browser.cfg"))
+                (let ((lib (string-append #$output "/lib/" #$moz-app-name))
+                      (config-file (string-append #$moz-app-name ".cfg")))
                   (with-output-to-file (in-vicinity
                                         lib "defaults/pref/autoconfig.js")
                     (lambda ()
@@ -786,13 +796,6 @@  (define-public torbrowser
                   (with-output-to-file (in-vicinity lib config-file)
                     (lambda ()
                       (format #t "// first line must be a comment~%")
-                      (format #t "pref(~s, ~s);~%"
-                              "extensions.torlauncher.torrc-defaults_path"
-                              (in-vicinity
-                               lib "TorBrowser/Data/Tor/torrc-defaults"))
-                      (format #t "pref(~s, ~s);~%"
-                              "extensions.torlauncher.tor_path"
-                              (search-input-file inputs "bin/tor"))
                       ;; Required for Guix packaged extensions
                       ;; SCOPE_PROFILE=1, SCOPE_APPLICATION=4, SCOPE_SYSTEM=8
                       ;; Default is 5.
@@ -821,64 +824,40 @@  (define-public torbrowser
                       (format #t "pref(~s, ~s);~%"
                               "lightweightThemes.getMoreURL"
                               "https://gnuzilla.gnu.org/mozzarella"))))))
-            (replace 'wrap-program
+            (add-after 'autoconfig 'autoconfig-tor
               (lambda* (#:key inputs #:allow-other-keys)
-                (let* ((gtk #$(this-package-input "gtk+"))
-                       (gtk-share (string-append gtk "/share"))
-                       (fonts.conf (in-vicinity
-                                    #$output
-                                    "lib/torbrowser/fontconfig/fonts.conf"))
-                       (ld-libs '#$(cons
-                                    (file-append
-                                     (this-package-input "libcanberra")
-                                     "/lib/gtk-3.0/modules")
-                                    (map
-                                     (lambda (label)
-                                       (file-append
-                                        (this-package-input label) "/lib"))
-                                     '("libpng-apng"
-                                       "libxscrnsaver"
-                                       "mesa"
-                                       "pciutils"
-                                       "mit-krb5"
-                                       "eudev"
-                                       "pulseaudio"
-                                       "libnotify")))))
-                  (wrap-program
-                      (in-vicinity #$output "lib/torbrowser/torbrowser")
-                    `("XDG_DATA_DIRS" prefix (,gtk-share))
-                    `("LD_LIBRARY_PATH" prefix ,ld-libs)
+                (let ((lib (in-vicinity #$output "lib/torbrowser"))
+                      (config-file (string-append #$moz-app-name ".cfg")))
+                  (let ((port (open-file (in-vicinity lib config-file) "a")))
+                    (format port "pref(~s, ~s);~%"
+                            "extensions.torlauncher.torrc-defaults_path"
+                            (in-vicinity
+                             lib "TorBrowser/Data/Tor/torrc-defaults"))
+                    (format port "pref(~s, ~s);~%"
+                            "extensions.torlauncher.tor_path"
+                            (search-input-file inputs "bin/tor"))
+                    (close port)))))
+            (add-after 'wrap-program 'wrap-fonts
+              (lambda _
+                (let ((fonts.conf (format #f "~a/lib/~a/fontconfig/fonts.conf"
+                                          #$output #$moz-app-name)))
+                  (wrap-program (format #f "~a/lib/~a/~a"
+                                        #$output
+                                        #$moz-app-name #$moz-app-name)
                     `("FONTCONFIG_FILE" prefix (,fonts.conf))))))
             (replace 'install-desktop-entry
               (lambda _
                 (let ((apps (in-vicinity #$output "share/applications")))
                   (mkdir-p apps)
                   (make-desktop-entry-file
-                   (in-vicinity apps "torbrowser.desktop")
-                   #:name "Tor Browser"
-                   #:exec
-                   (format #f "~a %u" (in-vicinity #$output "bin/torbrowser"))
-                   #:comment
-                   "Tor Browser is +1 for privacy and -1 for mass surveillance"
+                   (string-append apps #$moz-app-name ".desktop")
+                   #:name #$moz-app-remotingname
+                   #:exec (format #f "~a/bin/~a %u" #$output #$moz-app-name)
                    #:categories '("Network" "WebBrowser" "Security")
-                   #:startup-w-m-class "Tor Browser"
-                   #:icon "tor-browser"))))
-            (replace 'install-icons
-              (lambda* (#:key inputs #:allow-other-keys)
-                (for-each
-                 (lambda (size)
-                   (let ((oldpath (string-append
-                                   "browser/branding/tb-release/default"
-                                   size ".png"))
-                         (newpath (string-append #$output
-                                                 "/share/icons/hicolor/"
-                                                 size "x" size "/apps")))
-                     (mkdir-p newpath)
-                     (copy-file oldpath
-                                (in-vicinity newpath "tor-browser.png"))))
-                 '("16" "22" "24" "32" "48" "64" "128" "256"))))))))
+                   #:startup-w-m-class #$moz-app-remotingname
+                   #:icon #$moz-app-name))))))))
     (inputs
-     (modify-inputs (package-inputs icecat-minimal)
+     (modify-inputs (package-inputs base)
        (append go-gitlab-torproject-org-tpo-anti-censorship-pluggable-transports-lyrebird
                tor-client)))
     (propagated-inputs
@@ -892,3 +871,11 @@  (define-public torbrowser
 attacks on the privacy of Tor users.")
     (license license:mpl2.0)))       ;And others, see
                                      ;toolkit/content/license.html
+
+(define-public torbrowser
+  (make-torbrowser #:moz-app-name "torbrowser"
+                   #:moz-app-remotingname "Tor Browser"
+                   #:branding-directory "browser/branding/tb-release"
+                   #:assets torbrowser-assets
+                   #:locales %torbrowser-locales
+                   #:base-browser-version %torbrowser-version))