You are not logged in.

#1 2008-02-21 15:20:01

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

firebrand - a script to brand firefox without recompiling

This is the initial thread for firebrand, a script for branding firefox without recompilation. Firebrand is a simple bash script, which replaces some text strings and the icons in an already installed instance of the firefox package.

There are several versions/revisions of the script in this thread, but they can basically be divided into two "main" versions, or "branches" if you will. The earlier version needs to be updated for each new Firefox release. The later version is coded more generally, and should work for all Firefox versions.

The latest general script is mekwall's revision of my latest version of the script, updated to use the proper icons. You can either use the PKGBUILD in the AUR (creds to Lucky) or just download the script in mekwall's post. If you do the latter, you need to make it executable before you run it, chmod +x firebrand, and then run ./firebrand. You need to be root for it to work properly.

Lucky, who added the script to AUR, also started a git repository.

To revert Firefox to the original branding, simply reinstall the firefox package.

If the general version doesn't work (for instance, you still see the codename or the non-branded icon anywhere), try litemotiv's version. litemotiv's script is based on the earlier script, which needs to be updated for each new Firefox version. To make litemotiv's version work for other Firefox versions than 3.0, edit the FIREFOXDIR, FIREFOXSTRING and FIREFOXSTRINGPREFS variables in the script; the following example is for Firefox 3.5, codename "Shiretoko":

FIREFOXDIR=/usr/lib/firefox-3.5
FIREFOXSTRING="Shiretoko"
FIREFOXSTRINGPREFS="Shiretoko"

According to hit, firebrand is available in archlinux.fr's repository, but the repos contains the earlier script, i.e. the version which has to be updated for each new Firefox version.




---------------- History note ----------------

This thread was started on 2008-02-21, as I had some questions on the proper way to put firebrand on the AUR, which is why this thread is in this not-so-suitable subforum. The subsequent discussion made me rewrite the script somewhat and post it as a stand-alone script. The initial wording of this post is a little redundant now, but is kept below for the integrity of this thread.

The version below in this post is not the latest version; see above.



---------------- Initial thread start below ----------------


Hi,

Prompted by this discussion I decided to make available (on the AUR) my small script that brands firefox without recompilation. With some sed:ing and copying it simply replaces the "Bon Echo" string from some files and replaces the Bon Echo icons with the official one(s) in an existing installation of firefox*. Afterwards it is just to restart firefox (and perhaps the DE to replace the firefox icon) and rejoice smile

--------------------------
* Yes, replaces. To go back to the original Bon Echo "brand", simply reinstall firefox.
--------------------------

I have two questions, though:

1. Would the script end up in some legal grey-zone? The PKGBUILD does not itself contain any icons, but downloads them from a publicly available source repository for firefox. I myself at least think that no one here would object, since we already have the firefox-branded PKGBUILD in the AUR. ...or firefox-branded gets new company in the ...zone tongue

2. Since this is just a script I have made for my own personal... peace of mind, I have no URL to supply for the package. Does this matter?


Below are both the PKGBUILD and the firebrand script if anyone is interested:

EDIT: Added depends...

pkgname=firebrand
pkgver=20080221
pkgrel=1
pkgdesc="A script to brand firefox without recompiling."
arch=('i686' 'x86_64')
license=('GPL')
depends=('zip' 'unzip' 'imagemagick')

source=('firebrand.sh' 
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/mozicon50.xpm?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/mozicon16.xpm?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/mozicon128.png?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/document.png?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/content/icon48.png?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/content/icon64.png?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/content/about.png?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/content/aboutCredits.png?raw=1'
        'http://lxr.mozilla.org/seamonkey/source/other-licenses/branding/firefox/content/aboutFooter.png?raw=1')

md5sums=('2e9481ba02dfc3dc1f0fd02e07ccde98'
         '68fb3d9d3a91f3e99947b15c3cb03429'
         'd8b1c9e81222dd7df6d3c59ba205723d'
         'ff03ef6903c8f067dc5459c901b0b5a8'
         'b2a2dc01f2693d3e0eb47c7314783566'
         'da566d6e494d547e7ef4eba183e49603'
         '04a0735c7e33b0831975dca3d1c3e078'
         'ed27277ed6cc3fa83a256188b5699541'
         'd45dbd72b71abdd3d3f3e870ea90a03f'
         '8b1a1daff0845fca259575ca65046a1b')

build() {
  mkdir -p "$pkgdir/usr/bin"
  mkdir -p "$pkgdir/usr/share/firebrand"

  install -m755 "$srcdir/firebrand.sh" "$pkgdir/usr/bin/firebrand"

  install -m644 "$srcdir/mozicon50.xpm?raw=1" "$pkgdir/usr/share/firebrand/default.xpm"
  install -m644 "$srcdir/mozicon50.xpm?raw=1" "$pkgdir/usr/share/firebrand/mozicon50.xpm"
  install -m644 "$srcdir/mozicon16.xpm?raw=1" "$pkgdir/usr/share/firebrand/mozicon16.xpm"
  install -m644 "$srcdir/mozicon128.png?raw=1" "$pkgdir/usr/share/firebrand/mozicon128.png"
  install -m644 "$srcdir/document.png?raw=1" "$pkgdir/usr/share/firebrand/document.png"
  install -m644 "$srcdir/icon48.png?raw=1" "$pkgdir/usr/share/firebrand/icon48.png"
  install -m644 "$srcdir/icon64.png?raw=1" "$pkgdir/usr/share/firebrand/icon64.png"
  install -m644 "$srcdir/about.png?raw=1" "$pkgdir/usr/share/firebrand/about.png"
  install -m644 "$srcdir/aboutCredits.png?raw=1" "$pkgdir/usr/share/firebrand/aboutCredits.png"
  install -m644 "$srcdir/aboutFooter.png?raw=1" "$pkgdir/usr/share/firebrand/aboutFooter.png"
}

# vim:set ts=2 sw=2 et:
#!/bin/sh

FIREFOXDIR=/usr/lib/firefox
CHROMEDIR=$FIREFOXDIR/chrome
NEWICONSDIR=/usr/share/firebrand



die () {
    EXITCODE="${1:-9}"
    MESSAGE="$2"

    echo -e "\n$MESSAGE"

    exit $EXITCODE
}



TEMPDIR=$(mktemp -d -t firebrand-XXXXXXXX)

if [ $? -ne 0 ] ; then
    die 1 "Could not create temporary directory."
    
fi



echo -e "\033[1mRE-BRANDING chrome/en-US.jar\033[0m"
echo -n " - Unzipping en-US.jar to ${TEMPDIR}... "
unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd locale/branding/brand.properties && echo "Done." || die 1 "Could not unzip branding files."

for FILE in $TEMPDIR/locale/branding/* ; do
    sed -i 's|Bon Echo|Firefox|g' "$FILE" && echo " - Successfully edited ${FILE}" || die 1 "Could not edit ${FILE}."
done

echo " - Replacing branding files in en-US.jar"
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/en-US.jar" locale/branding/* )



echo -e "\033[1mRE-BRANDING chrome/browser.jar\033[0m"
echo " - Replacing branded icons in browser.jar"
mkdir -p "$TEMPDIR/content/branding"
cp "$NEWICONSDIR"/{about.png,aboutCredits.png,aboutFooter.png,icon48.png,icon64.png} "$TEMPDIR/content/branding/"
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/browser.jar" content/branding/* )



echo -e "\033[1mRE-BRANDING defaults/pref/firefox.js\033[0m"
sed -i 's|BonEcho|Firefox|g' $FIREFOXDIR/defaults/pref/firefox.js && echo " - Successfully edited $FIREFOXDIR/defaults/pref/firefox.js." || die 1 "Could not edit $FIREFOXDIR/defaults/pref/firefox.js."



echo -e "\033[1mReplacing icons...\033[0m"
cp "$NEWICONSDIR/default.xpm" $FIREFOXDIR/chrome/icons/default/
cp "$NEWICONSDIR"/{default.xpm,document.png,mozicon128.png,mozicon16.xpm,mozicon50.xpm} $FIREFOXDIR/icons/

chmod 644 $FIREFOXDIR/chrome/icons/default/default.xpm $FIREFOXDIR/icons/*
chown root:root $FIREFOXDIR/chrome/icons/default/default.xpm $FIREFOXDIR/icons/*


convert "$NEWICONSDIR/default.xpm" /usr/share/pixmaps/firefox.png
chmod 644 /usr/share/pixmaps/firefox.png 
chown root:root /usr/share/pixmaps/firefox.png

Last edited by Bebo (2010-02-15 21:16:21)

Offline

#2 2008-02-21 17:19:02

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: firebrand - a script to brand firefox without recompiling

It works.  You should probably add "unzip" and "imagemagick" as dependencies to the pkgbuild... 

Also -- why the PKGBUILD method?  I  think it would work nicer as a standalone script that downloads the appropriate files to /tmp somewhere, rebrands and that's it.  With a standalone script you wouldn't have to worry so much about the potential legal issues either...

Offline

#3 2008-02-21 17:47:58

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

Thanks for the pointers on the depends - I completely forgot that I used zip/unzip and convert smile

Well, I was thinking of just posting the script on the forum, but I couldn't decide how to handle the images. When I wrote the script I just downloaded the firefox source with from/with ABS and copied them into /usr/local/share/firebrand (since I put all my scripts and stuff in /usr/local), but when I thought of making the script, ehm, public, I had to decide between rewriting the script to make it download the images itself or put a PKGBUILD in AUR. In the end, I thought AUR would be simplest. After reading your comment, I'm not sure smile

Offline

#4 2008-02-21 23:49:49

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

Very well then... smile Here is a stand-alone script, that takes care of the icon downloading itself. I made it slightly more verbose than the script in my first post so people know what's going on a little bit more. I'll add a short section on it in the Firefox wiki page.

Here it is:

#!/bin/sh
#
# firebrand - a script to brand firefox without recompilation
#
# NOTE 1: It has only been tested on Firefox 2.x.
# NOTE 2: It will only work on "Bon Echo" branded firefoxes.
#
# This script replaces and changes (a few) files in an existing firefox 
# installation. Run it after a firefox installation or upgrade, and restart 
# firefox. The program icon may not be (visibly) replaced until your desktop 
# environment is restarted.
#
# To revert to the original Bon Echo brand, simply reinstall firefox.
#
# Dependencies: curl, zip, unzip, imagemagick
#


FIREFOXDIR=/usr/lib/firefox             # Where firefox's data files resides.
NEWICONSDIR=""                          # If empty, the script uses a temporary directory for the replacement icons.
                                        # If you want to avoid downloading the icons every time you rebrand firefox,
                                        # point NEWICONSDIR to a suitable directory.
SOURCEBASE="http://lxr.mozilla.org/seamonkey/source" # The URL under which the "other-licenses" directory resides.

CHROMEDIR=$FIREFOXDIR/chrome            # Simply the firefox chrome directory.



die() {
    EXITCODE="${1:-9}"
    MESSAGE="$2"

    echo -e "\n$MESSAGE"

    exit $EXITCODE
}



get_icon() {
    local ICON="$1"
    local SOURCEFILE="$2"

    echo -n " - $ICON"

    if [ -e "$NEWICONSDIR/$ICON" ] ; then
        if [ -f "$NEWICONSDIR/$ICON" ] ; then
            echo " is present."
            return 0
        else
            echo " is present but is not a file. Quitting."
            exit 1
        fi
    fi

    echo -n ": Downloading... "
    if curl -sS "${SOURCEBASE}${SOURCEFILE}" > "$NEWICONSDIR/$ICON" ; then
        echo "Done."
        return 0
    else
        exit 1
    fi
}



TEMPDIR=$(mktemp -d -t firebrand-work-XXXXXXXX)

if [ $? -ne 0 ] ; then
    die 1 "Could not create temporary work directory."
fi

if [ "x$NEWICONSDIR" == "x" ] ; then
    NEWICONSDIR=$(mktemp -d -t firebrand-icon-XXXXXXXX)

    if [ $? -ne 0 ] ; then
        die 1 "Could not create temporary icon directory."
    fi
else
    [ -e "$NEWICONSDIR" ] || mkdir -p "$NEWICONSDIR" || die 1 "Could not create icon directory $NEWICONSDIR."
fi



echo -e "\033[1mChecking replacement icons\033[0m"
get_icon "mozicon50.xpm"    "/other-licenses/branding/firefox/mozicon50.xpm?raw=1"
get_icon "mozicon16.xpm"    "/other-licenses/branding/firefox/mozicon16.xpm?raw=1"
get_icon "mozicon128.png"   "/other-licenses/branding/firefox/mozicon128.png?raw=1"
get_icon "document.png"     "/other-licenses/branding/firefox/document.png?raw=1"
get_icon "icon48.png"       "/other-licenses/branding/firefox/content/icon48.png?raw=1"
get_icon "icon64.png"       "/other-licenses/branding/firefox/content/icon64.png?raw=1"
get_icon "about.png"        "/other-licenses/branding/firefox/content/about.png?raw=1"
get_icon "aboutCredits.png" "/other-licenses/branding/firefox/content/aboutCredits.png?raw=1"
get_icon "aboutFooter.png"  "/other-licenses/branding/firefox/content/aboutFooter.png?raw=1"
cp "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default.xpm"



echo -e "\033[1mBranding chrome/en-US.jar\033[0m"
echo -n " - Unzipping branding files in chrome/en-US.jar to temporary directory... "
unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd locale/branding/brand.properties && echo "Done." || die 1 "Failed."

for FILE in $TEMPDIR/locale/branding/* ; do
    sed -i 's|Bon Echo|Firefox|g' "$FILE" && echo " - Successfully edited ${FILE}" || die 1 "Could not edit ${FILE}."
done

echo -n " - Replacing old branding files in chrome/en-US.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/en-US.jar" locale/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding chrome/browser.jar\033[0m"
echo -n " - Making new branding icon structure in temporary directory... "
mkdir -p "$TEMPDIR/content/branding" || die 1 "Could not create $TEMPDIR/content/branding."
cp "$NEWICONSDIR"/{about.png,aboutCredits.png,aboutFooter.png,icon48.png,icon64.png} "$TEMPDIR/content/branding/" || die 1 "Could not copy new icons to $TEMPDIR/content/branding/."
echo "Done."
echo -n " - Replacing old branding icon structure in chrome/browser.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/browser.jar" content/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding defaults/pref/firefox.js\033[0m"
sed -i 's|BonEcho|Firefox|g' $FIREFOXDIR/defaults/pref/firefox.js && echo " - Successfully edited $FIREFOXDIR/defaults/pref/firefox.js." || die 1 "Could not edit $FIREFOXDIR/defaults/pref/firefox.js."



echo -e "\033[1mBranding icons\033[0m"
echo -n " - Replacing chrome/icons/default/default.xpm... "
cp "$NEWICONSDIR/default.xpm" $FIREFOXDIR/chrome/icons/default/ && echo "Done." || die 1 "Failed."
echo -n " - Replacing branding icons in icons/... "
cp "$NEWICONSDIR"/{default.xpm,document.png,mozicon128.png,mozicon16.xpm,mozicon50.xpm} $FIREFOXDIR/icons/ && echo "Done." || die 1 "Failed."

chmod 644 $FIREFOXDIR/chrome/icons/default/default.xpm $FIREFOXDIR/icons/*
chown root:root $FIREFOXDIR/chrome/icons/default/default.xpm $FIREFOXDIR/icons/*

echo -n " - Replacing /usr/share/pixmaps/firefox.png: "
convert "$NEWICONSDIR/default.xpm" /usr/share/pixmaps/firefox.png && echo "Done." || die 1 "Failed."
chmod 644 /usr/share/pixmaps/firefox.png 
chown root:root /usr/share/pixmaps/firefox.png

Offline

#5 2008-04-03 20:17:17

Alsvartr
Member
From: Moscow
Registered: 2008-04-03
Posts: 6

Re: firebrand - a script to brand firefox without recompiling

Thanks, great script. It works for firefox3 as well with some corrections.

Offline

#6 2008-04-03 21:18:56

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

Oh, great! Thanks for testing smile

Offline

#7 2008-04-03 21:56:57

SpookyET
Member
Registered: 2008-01-27
Posts: 410

Re: firebrand - a script to brand firefox without recompiling

There is a lot of confusion about the branding.
If you do not patch firefox, or you get mozilla to check your patches, you can brand it. Full stop.

Offline

#8 2008-04-03 22:19:05

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

SpookyET wrote:

There is a lot of confusion about the branding.
If you do not patch firefox, or you get mozilla to check your patches, you can brand it. Full stop.

What? Sorry, I'm very tired now, but I really don't understand what you mean. Venturing a guess here: do you mean that I, in your opinion, should not have called the script "firebrand" and/or not refer to this icon-and-text replacing as "branding"? People can call this script whatever they want, perhaps replace-bonecho-stuff-with-firefox-stuff.sh, it's highly unimportant.

Pardon the sarcastic tone.

Offline

#9 2008-04-04 01:11:07

SpookyET
Member
Registered: 2008-01-27
Posts: 410

Re: firebrand - a script to brand firefox without recompiling

Bebo wrote:
SpookyET wrote:

There is a lot of confusion about the branding.
If you do not patch firefox, or you get mozilla to check your patches, you can brand it. Full stop.

What? Sorry, I'm very tired now, but I really don't understand what you mean. Venturing a guess here: do you mean that I, in your opinion, should not have called the script "firebrand" and/or not refer to this icon-and-text replacing as "branding"? People can call this script whatever they want, perhaps replace-bonecho-stuff-with-firefox-stuff.sh, it's highly unimportant.

Pardon the sarcastic tone.

No, I was talking about about Bon Echo, and when you are aloud to use the Firefox logo and call it "Mozilla Firefox."

Offline

#10 2008-04-04 07:08:20

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

Okay, I see. Yes, that might be interesting to know for people considering using this script. (The script was written with no confusion at all regarding the Mozilla Firefox vs Bon Echo license rule(s), though.)

Offline

#11 2008-04-05 01:28:11

babypuncher
Member
From: .au
Registered: 2007-03-12
Posts: 114
Website

Re: firebrand - a script to brand firefox without recompiling

Alsvartr wrote:

Thanks, great script. It works for firefox3 as well with some corrections.

Please share, Sir.

Offline

#12 2008-04-16 18:00:40

Alsvartr
Member
From: Moscow
Registered: 2008-04-03
Posts: 6

Re: firebrand - a script to brand firefox without recompiling

#!/bin/sh
#
# firebrand - a script to brand firefox without recompilation
#
# NOTE 1: It has only been tested on Firefox 2.x.
# NOTE 2: It will only work on "Bon Echo" branded firefoxes.
#
# This script replaces and changes (a few) files in an existing firefox 
# installation. Run it after a firefox installation or upgrade, and restart 
# firefox. The program icon may not be (visibly) replaced until your desktop 
# environment is restarted.
#
# To revert to the original Bon Echo brand, simply reinstall firefox.
#
# Dependencies: curl, zip, unzip, imagemagick
#


FIREFOXDIR=/opt/mozilla/lib/firefox3             # Where firefox's data files resides.
NEWICONSDIR=""                          # If empty, the script uses a temporary directory for the replacement icons.
                                        # If you want to avoid downloading the icons every time you rebrand firefox,
                                        # point NEWICONSDIR to a suitable directory.
SOURCEBASE="http://lxr.mozilla.org/seamonkey/source" # The URL under which the "other-licenses" directory resides.

CHROMEDIR=$FIREFOXDIR/chrome            # Simply the firefox chrome directory.



die() {
    EXITCODE="${1:-9}"
    MESSAGE="$2"

    echo -e "\n$MESSAGE"

    exit $EXITCODE
}



get_icon() {
    local ICON="$1"
    local SOURCEFILE="$2"

    echo -n " - $ICON"

    if [ -e "$NEWICONSDIR/$ICON" ] ; then
        if [ -f "$NEWICONSDIR/$ICON" ] ; then
            echo " is present."
            return 0
        else
            echo " is present but is not a file. Quitting."
            exit 1
        fi
    fi

    echo -n ": Downloading... "
    if curl -sS "${SOURCEBASE}${SOURCEFILE}" > "$NEWICONSDIR/$ICON" ; then
        echo "Done."
        return 0
    else
        exit 1
    fi
}



TEMPDIR=$(mktemp -d -t firebrand-work-XXXXXXXX)

if [ $? -ne 0 ] ; then
    die 1 "Could not create temporary work directory."
fi

if [ "x$NEWICONSDIR" == "x" ] ; then
    NEWICONSDIR=$(mktemp -d -t firebrand-icon-XXXXXXXX)

    if [ $? -ne 0 ] ; then
        die 1 "Could not create temporary icon directory."
    fi
else
    [ -e "$NEWICONSDIR" ] || mkdir -p "$NEWICONSDIR" || die 1 "Could not create icon directory $NEWICONSDIR."
fi



echo -e "\033[1mChecking replacement icons\033[0m"
get_icon "mozicon50.xpm"    "/other-licenses/branding/firefox/mozicon50.xpm?raw=1"
get_icon "mozicon16.xpm"    "/other-licenses/branding/firefox/mozicon16.xpm?raw=1"
get_icon "mozicon128.png"   "/other-licenses/branding/firefox/mozicon128.png?raw=1"
get_icon "document.png"     "/other-licenses/branding/firefox/document.png?raw=1"
get_icon "icon48.png"       "/other-licenses/branding/firefox/content/icon48.png?raw=1"
get_icon "icon64.png"       "/other-licenses/branding/firefox/content/icon64.png?raw=1"
get_icon "about.png"        "/other-licenses/branding/firefox/content/about.png?raw=1"
get_icon "aboutCredits.png" "/other-licenses/branding/firefox/content/aboutCredits.png?raw=1"
get_icon "aboutFooter.png"  "/other-licenses/branding/firefox/content/aboutFooter.png?raw=1"
cp "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default.xpm"



echo -e "\033[1mBranding chrome/en-US.jar\033[0m"
echo -n " - Unzipping branding files in chrome/en-US.jar to temporary directory... "
unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd locale/branding/brand.properties && echo "Done." || die 1 "Failed."

for FILE in $TEMPDIR/locale/branding/* ; do
    sed -i 's|Minefield|Firefox|g' "$FILE" && echo " - Successfully edited ${FILE}" || die 1 "Could not edit ${FILE}."
done

echo -n " - Replacing old branding files in chrome/en-US.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/en-US.jar" locale/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding chrome/browser.jar\033[0m"
echo -n " - Making new branding icon structure in temporary directory... "
mkdir -p "$TEMPDIR/content/branding" || die 1 "Could not create $TEMPDIR/content/branding."
cp "$NEWICONSDIR"/{about.png,aboutCredits.png,aboutFooter.png,icon48.png,icon64.png} "$TEMPDIR/content/branding/" || die 1 "Could not copy new icons to $TEMPDIR/content/branding/."
echo "Done."
echo -n " - Replacing old branding icon structure in chrome/browser.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/browser.jar" content/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding defaults/pref/firefox.js\033[0m"
sed -i 's|Minefield|Firefox|g' $FIREFOXDIR/defaults/pref/firefox.js && echo " - Successfully edited $FIREFOXDIR/defaults/pref/firefox.js." || die 1 "Could not edit $FIREFOXDIR/defaults/pref/firefox.js."



echo -e "\033[1mBranding icons\033[0m"
echo -n " - Replacing chrome/icons/default/default.xpm... "
cp "$NEWICONSDIR/default.xpm" $FIREFOXDIR/chrome/icons/default/ && echo "Done." || die 1 "Failed."
echo -n " - Replacing branding icons in icons/... "
cp "$NEWICONSDIR"/{default.xpm,document.png,mozicon128.png,mozicon16.xpm,mozicon50.xpm} $FIREFOXDIR/icons/ && echo "Done." || die 1 "Failed."

chmod 644 $FIREFOXDIR/chrome/icons/default/default.xpm $FIREFOXDIR/icons/*
chown root:root $FIREFOXDIR/chrome/icons/default/default.xpm $FIREFOXDIR/icons/*

echo -n " - Replacing /usr/share/pixmaps/firefox.png: "
convert "$NEWICONSDIR/default.xpm" /usr/share/pixmaps/firefox.png && echo "Done." || die 1 "Failed."
chmod 644 /usr/share/pixmaps/firefox.png 
chown root:root /usr/share/pixmaps/firefox.png

Offline

#13 2008-06-01 20:19:43

Distro-jumper
Member
Registered: 2008-01-23
Posts: 30

Re: firebrand - a script to brand firefox without recompiling

When running:

sh firebrand

I get:

Branding chrome/en-US.jar
- Unzipping branding files in chrome/en-US.jar to temporary
directory... firebrand: line 123: locale/branding/brand.properties: No such file or directory

Failed.

Any ideas?

Thanks,
/Bob

Offline

#14 2008-06-01 21:22:32

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

Hm, a bit odd. What firefox package are you using?

You can verify the (non)existence of the brand.properties file by

unzip -l /usr/lib/firefox/chrome/en-US.jar | grep brand

If the resulting list contains locale/branding/brand.properties, it is there, and strange stuff is happening. (Maybe it has moved somewhere else?) Otherwise, you can just remove "locale/branding/brand.properties" from the line where the error occur - that is, change

unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd locale/branding/brand.properties && echo "Done." || die 1 "Failed."

to

unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd && echo "Done." || die 1 "Failed."

Offline

#15 2008-06-19 14:08:27

equilibrium
Member
From: EU
Registered: 2008-06-18
Posts: 80
Website

Re: firebrand - a script to brand firefox without recompiling

cool script smile

the icon and "bon echo" at the top of the screen was annoying sad


Archlinux x86_64 | Github | acer chromebook c7 (arch)

Offline

#16 2008-06-19 17:59:09

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: firebrand - a script to brand firefox without recompiling

Just to let you know, bsdtar (in libarchive, a pacman dep) has some zip support, so it is possible that you do not need unzip. I am not sure if it works 100%, but it would be worth a try.

Offline

#17 2008-06-19 19:38:01

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

equilibrium wrote:

cool script smile

the icon and "bon echo" at the top of the screen was annoying sad

Thanks, yes, that was the exact reason I wrote it smile


Daenyth wrote:

Just to let you know, bsdtar (in libarchive, a pacman dep) has some zip support, so it is possible that you do not need unzip. I am not sure if it works 100%, but it would be worth a try.

Ah, yes, according to the bsdtar man page it should support zip. Maybe I'll get around to switching to bsdtar when I upgrade to ff 3 (soon, hopfully).

Offline

#18 2008-06-28 20:46:46

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

If anyone is interested, here's firebrand for Firefox 3 in the extra repository. Hopefully I haven't missed any "Minefield" string or icon.


#!/bin/sh
#
# firebrand - a script to brand firefox without recompilation
#
# NOTE: It will only work on "Minefield" branded firefoxes.
#
# This script replaces and changes (a few) files in an existing firefox 
# installation. Run it after a firefox installation or upgrade, and restart 
# firefox. The program icon may not be (visibly) replaced until your desktop 
# environment is restarted.
#
# To revert to the original Minefield brand, simply reinstall firefox.
#
# Dependencies: curl, zip, unzip, imagemagick
#


FIREFOXDIR=/usr/lib/firefox-3.0             # Where firefox's data files resides.
NEWICONSDIR=""                              # If empty, the script uses a temporary directory for the replacement icons.
                                            # If you want to avoid downloading the icons every time you rebrand firefox,
                                            # point NEWICONSDIR to a suitable directory.
SOURCEBASE="http://lxr.mozilla.org/seamonkey/source" # The URL under which the "other-licenses" directory resides.

CHROMEDIR=$FIREFOXDIR/chrome                # Simply the firefox chrome directory.



die() {
    EXITCODE="${1:-9}"
    MESSAGE="$2"

    echo -e "\n$MESSAGE"

    exit $EXITCODE
}



get_icon() {
    local ICON="$1"
    local SOURCEFILE="$2"

    echo -n " - $ICON"

    if [ -e "$NEWICONSDIR/$ICON" ] ; then
        if [ -f "$NEWICONSDIR/$ICON" ] ; then
            echo " is present."
            return 0
        else
            echo " is present but is not a file. Quitting."
            exit 1
        fi
    fi

    echo -n ": Downloading... "
    if curl -sS "${SOURCEBASE}${SOURCEFILE}" > "$NEWICONSDIR/$ICON" ; then
        echo "Done."
        return 0
    else
        exit 1
    fi
}



TEMPDIR=$(mktemp -d -t firebrand-work-XXXXXXXX)

if [ $? -ne 0 ] ; then
    die 1 "Could not create temporary work directory."
fi

if [ "x$NEWICONSDIR" == "x" ] ; then
    NEWICONSDIR=$(mktemp -d -t firebrand-icon-XXXXXXXX)

    if [ $? -ne 0 ] ; then
        die 1 "Could not create temporary icon directory."
    fi
else
    [ -e "$NEWICONSDIR" ] || mkdir -p "$NEWICONSDIR" || die 1 "Could not create icon directory $NEWICONSDIR."
fi



echo -e "\033[1mChecking replacement icons\033[0m"
get_icon "mozicon50.xpm"    "/other-licenses/branding/firefox/mozicon50.xpm?raw=1"
get_icon "mozicon16.xpm"    "/other-licenses/branding/firefox/mozicon16.xpm?raw=1"
get_icon "mozicon128.png"   "/other-licenses/branding/firefox/mozicon128.png?raw=1"
get_icon "document.png"     "/other-licenses/branding/firefox/document.png?raw=1"
get_icon "icon48.png"       "/other-licenses/branding/firefox/content/icon48.png?raw=1"
get_icon "icon64.png"       "/other-licenses/branding/firefox/content/icon64.png?raw=1"
get_icon "about.png"        "/other-licenses/branding/firefox/content/about.png?raw=1"
get_icon "aboutCredits.png" "/other-licenses/branding/firefox/content/aboutCredits.png?raw=1"
get_icon "aboutFooter.png"  "/other-licenses/branding/firefox/content/aboutFooter.png?raw=1"
cp "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default.xpm"
convert -resize 48x48 "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default48.png"
convert -resize 32x32 "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default32.png"
convert -resize 16x16 "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default16.png"



echo -e "\033[1mBranding chrome/en-US.jar\033[0m"
echo -n " - Unzipping branding files in chrome/en-US.jar to temporary directory... "
unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd locale/branding/brand.properties && echo "Done." || die 1 "Failed."

for FILE in $TEMPDIR/locale/branding/* ; do
    sed -i 's|Minefield|Firefox|g' "$FILE" && echo " - Successfully edited ${FILE}" || die 1 "Could not edit ${FILE}."
done

echo -n " - Replacing old branding files in chrome/en-US.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/en-US.jar" locale/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding chrome/browser.jar\033[0m"
echo -n " - Making new branding icon structure in temporary directory... "
mkdir -p "$TEMPDIR/content/branding" || die 1 "Could not create $TEMPDIR/content/branding."
cp "$NEWICONSDIR"/{about.png,aboutCredits.png,aboutFooter.png,icon48.png,icon64.png} "$TEMPDIR/content/branding/" || die 1 "Could not copy new icons to $TEMPDIR/content/branding/."
echo "Done."
echo -n " - Replacing old branding icon structure in chrome/browser.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/browser.jar" content/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding defaults/preferences/firefox.js\033[0m"
sed -i "s|Minefield|Firefox|g" $FIREFOXDIR/defaults/preferences/firefox.js && echo " - Successfully edited $FIREFOXDIR/defaults/preferences/firefox.js." || die 1 "Could not edit $FIREFOXDIR/defaults/preferences/firefox.js."



echo -e "\033[1mBranding icons\033[0m"
echo -n " - Replacing icons in chrome/icons/default/... "
cp "$NEWICONSDIR"/{default48.png,default32.png,default16.png} $FIREFOXDIR/chrome/icons/default/ && echo "Done." || die 1 "Failed."

echo -n " - Replacing icons in icons/... "
cp "$NEWICONSDIR"/{document.png,mozicon128.png,mozicon16.xpm,mozicon50.xpm} $FIREFOXDIR/icons/ && echo "Done." || die 1 "Failed."

chmod 644 $FIREFOXDIR/chrome/icons/default/* $FIREFOXDIR/icons/*
chown root:root $FIREFOXDIR/chrome/icons/default/* $FIREFOXDIR/icons/*

echo -n " - Replacing /usr/share/pixmaps/firefox.png: "
convert "$NEWICONSDIR/default.xpm" /usr/share/pixmaps/firefox.png && echo "Done." || die 1 "Failed."
chmod 644 /usr/share/pixmaps/firefox.png 
chown root:root /usr/share/pixmaps/firefox.png

(I have not replaced either of zip or unzip with bsdtar, since bsdtar apparently can't create zip archives - so I got lazy.)

Offline

#19 2008-06-28 21:08:12

Sp4rkR4t
Member
From: Southampton
Registered: 2008-05-06
Posts: 110

Re: firebrand - a script to brand firefox without recompiling

Thanks for the update bebo.

Offline

#20 2008-06-28 21:46:07

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: firebrand - a script to brand firefox without recompiling

Just for info, the firefox-branded package from AUR takes less than 2 minutes to be compiled and built now.
It's the same as the official Arch package with the branded option enabled.
So in my opinion, this script is no more necessary.

Last edited by berbae (2008-06-28 21:49:41)

Offline

#21 2008-07-18 22:29:16

ozar
Member
From: USA
Registered: 2005-02-18
Posts: 1,686

Re: firebrand - a script to brand firefox without recompiling

The script works just fine on 'Gran Paradiso' with a few minor edits.


oz

Offline

#22 2008-07-20 20:12:46

coutinho
Member
Registered: 2008-07-20
Posts: 4

Re: firebrand - a script to brand firefox without recompiling

I made some changes that make conforming to new firefox versions easier. Simply change FIREFOXDIR to point to the new dir and FIREFOXSTRING with the new codename. This one is already set up for Gran Paradiso (firefox-3.0.1).
edit: FIREFOXSTRINGPREFS is the codename as it appears in the preferences, usually without spaces.  (may be the same as FIREFOXSTRING, as with Minefield)

#!/bin/sh
#
# firebrand - a script to brand firefox without recompilation
#
#
# This script replaces and changes (a few) files in an existing firefox 
# installation. Run it after a firefox installation or upgrade, and restart 
# firefox. The program icon may not be (visibly) replaced until your desktop 
# environment is restarted.
#
# To revert to the original brand, simply reinstall firefox.
#
# Dependencies: curl, zip, unzip, imagemagick
#

#FIREFOXDIR: Where firefox's data files resides.

# Bon Echo:
#FIREFOXDIR=/usr/lib/firefox
#FIREFOXSTRING="Bon Echo"
#FIREFOXSTRINGPREFS="BonEcho"

# Minefield:
#FIREFOXDIR=/usr/lib/firefox-3.0
#FIREFOXSTRING="Minefield"
#FIREFOXSTRINGPREFS="Minefield"

# Gran Paradiso:
FIREFOXDIR=/usr/lib/firefox-3.0.1
FIREFOXSTRING="Gran Paradiso"
FIREFOXSTRINGPREFS="GranParadiso"

NEWICONSDIR=""                              # If empty, the script uses a temporary directory for the replacement icons.
                                            # If you want to avoid downloading the icons every time you rebrand firefox,
                                            # point NEWICONSDIR to a suitable directory.

SOURCEBASE="http://lxr.mozilla.org/seamonkey/source" # The URL under which the "other-licenses" directory resides.


CHROMEDIR=$FIREFOXDIR/chrome                # Simply the firefox chrome directory.



die() {
    EXITCODE="${1:-9}"
    MESSAGE="$2"

    echo -e "\n$MESSAGE"

    exit $EXITCODE
}



get_icon() {
    local ICON="$1"
    local SOURCEFILE="$2"

    echo -n " - $ICON"

    if [ -e "$NEWICONSDIR/$ICON" ] ; then
        if [ -f "$NEWICONSDIR/$ICON" ] ; then
            echo " is present."
            return 0
        else
            echo " is present but is not a file. Quitting."
            exit 1
        fi
    fi

    echo -n ": Downloading... "
    if curl -sS "${SOURCEBASE}${SOURCEFILE}" > "$NEWICONSDIR/$ICON" ; then
        echo "Done."
        return 0
    else
        exit 1
    fi
}



TEMPDIR=$(mktemp -d -t firebrand-work-XXXXXXXX)

if [ $? -ne 0 ] ; then
    die 1 "Could not create temporary work directory."
fi

if [ "x$NEWICONSDIR" == "x" ] ; then
    NEWICONSDIR=$(mktemp -d -t firebrand-icon-XXXXXXXX)

    if [ $? -ne 0 ] ; then
        die 1 "Could not create temporary icon directory."
    fi
else
    [ -e "$NEWICONSDIR" ] || mkdir -p "$NEWICONSDIR" || die 1 "Could not create icon directory $NEWICONSDIR."
fi



echo -e "\033[1mChecking replacement icons\033[0m"
get_icon "mozicon50.xpm"    "/other-licenses/branding/firefox/mozicon50.xpm?raw=1"
get_icon "mozicon16.xpm"    "/other-licenses/branding/firefox/mozicon16.xpm?raw=1"
get_icon "mozicon128.png"   "/other-licenses/branding/firefox/mozicon128.png?raw=1"
get_icon "document.png"     "/other-licenses/branding/firefox/document.png?raw=1"
get_icon "icon48.png"       "/other-licenses/branding/firefox/content/icon48.png?raw=1"
get_icon "icon64.png"       "/other-licenses/branding/firefox/content/icon64.png?raw=1"
get_icon "about.png"        "/other-licenses/branding/firefox/content/about.png?raw=1"
get_icon "aboutCredits.png" "/other-licenses/branding/firefox/content/aboutCredits.png?raw=1"
get_icon "aboutFooter.png"  "/other-licenses/branding/firefox/content/aboutFooter.png?raw=1"
cp "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default.xpm"
convert -resize 48x48 "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default48.png"
convert -resize 32x32 "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default32.png"
convert -resize 16x16 "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default16.png"



echo -e "\033[1mBranding chrome/en-US.jar\033[0m"
echo -n " - Unzipping branding files in chrome/en-US.jar to temporary directory... "
unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd locale/branding/brand.properties && echo "Done." || die 1 "Failed."

for FILE in $TEMPDIR/locale/branding/* ; do
    sed -i "s|$FIREFOXSTRING|Firefox|g" "$FILE" && echo " - Successfully edited ${FILE}" || die 1 "Could not edit ${FILE}."
done

echo -n " - Replacing old branding files in chrome/en-US.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/en-US.jar" locale/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding chrome/browser.jar\033[0m"
echo -n " - Making new branding icon structure in temporary directory... "
mkdir -p "$TEMPDIR/content/branding" || die 1 "Could not create $TEMPDIR/content/branding."
cp "$NEWICONSDIR"/{about.png,aboutCredits.png,aboutFooter.png,icon48.png,icon64.png} "$TEMPDIR/content/branding/" || die 1 "Could not copy new icons to $TEMPDIR/content/branding/."
echo "Done."
echo -n " - Replacing old branding icon structure in chrome/browser.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/browser.jar" content/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding defaults/preferences/firefox.js\033[0m"
sed -i "s|$FIREFOXSTRINGPREFS|Firefox|g" $FIREFOXDIR/defaults/preferences/firefox.js && echo " - Successfully edited $FIREFOXDIR/defaults/preferences/firefox.js." || die 1 "Could not edit $FIREFOXDIR/defaults/preferences/firefox.js."



echo -e "\033[1mBranding icons\033[0m"
echo -n " - Replacing icons in chrome/icons/default/... "
cp "$NEWICONSDIR"/{default48.png,default32.png,default16.png} $FIREFOXDIR/chrome/icons/default/ && echo "Done." || die 1 "Failed."

echo -n " - Replacing icons in icons/... "
cp "$NEWICONSDIR"/{document.png,mozicon128.png,mozicon16.xpm,mozicon50.xpm} $FIREFOXDIR/icons/ && echo "Done." || die 1 "Failed."

chmod 644 $FIREFOXDIR/chrome/icons/default/* $FIREFOXDIR/icons/*
chown root:root $FIREFOXDIR/chrome/icons/default/* $FIREFOXDIR/icons/*

echo -n " - Replacing /usr/share/pixmaps/firefox.png: "
convert "$NEWICONSDIR/default.xpm" /usr/share/pixmaps/firefox.png && echo "Done." || die 1 "Failed."
chmod 644 /usr/share/pixmaps/firefox.png 
chown root:root /usr/share/pixmaps/firefox.png

Last edited by coutinho (2008-07-20 20:32:23)

Offline

#23 2008-07-20 21:05:56

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: firebrand - a script to brand firefox without recompiling

Great! I did adapt my script at home for Gran Paradiso some days ago, but I haven't had the time to post it (not sure that so may are interested* hmm). Now I don't have to - your update was even better than what I did smile

Hm, maybe we can get it to autodetect the brand...


______________
* I like it a lot though, it is still faster and simpler than compiling the firefox-branded package wink

Offline

#24 2008-07-21 00:31:19

coutinho
Member
Registered: 2008-07-20
Posts: 4

Re: firebrand - a script to brand firefox without recompiling

Thanks! By the way, thanks a lot for the script, I think its mighty useful and way simpler and faster than recompiling firefox...

Offline

#25 2008-07-31 10:32:52

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: firebrand - a script to brand firefox without recompiling

Used to work, but for some reason it broke.

Checking replacement icons
 - mozicon50.xpm: Downloading... Done.
 - mozicon16.xpm: Downloading... Done.
 - mozicon128.png: Downloading... Done.
 - document.png: Downloading... Done.
 - icon48.png: Downloading... Done.
 - icon64.png: Downloading... Done.
 - about.png: Downloading... Done.
 - aboutCredits.png: Downloading... Done.
 - aboutFooter.png: Downloading... Done.
convert: Improper image header `/tmp/firebrand-icon-gfgSsL4O/mozicon50.xpm'.
convert: missing an image filename `/tmp/firebrand-icon-gfgSsL4O/default48.png'.
convert: Improper image header `/tmp/firebrand-icon-gfgSsL4O/mozicon50.xpm'.
convert: missing an image filename `/tmp/firebrand-icon-gfgSsL4O/default32.png'.
convert: Improper image header `/tmp/firebrand-icon-gfgSsL4O/mozicon50.xpm'.
convert: missing an image filename `/tmp/firebrand-icon-gfgSsL4O/default16.png'.
Branding chrome/en-US.jar
 - Unzipping branding files in chrome/en-US.jar to temporary directory... Done.
 - Successfully edited /tmp/firebrand-work-ChadPzs4/locale/branding/brand.dtd
 - Successfully edited /tmp/firebrand-work-ChadPzs4/locale/branding/brand.properties
 - Replacing old branding files in chrome/en-US.jar... Done.
Branding chrome/browser.jar
 - Making new branding icon structure in temporary directory... Done.
 - Replacing old branding icon structure in chrome/browser.jar... Done.
Branding defaults/preferences/firefox.js
 - Successfully edited /usr/lib/firefox-3.0/defaults/preferences/firefox.js.
Branding icons
 - Replacing icons in chrome/icons/default/... cp: cannot stat `/tmp/firebrand-icon-gfgSsL4O/default48.png': No such file or directory
cp: cannot stat `/tmp/firebrand-icon-gfgSsL4O/default32.png': No such file or directory
cp: cannot stat `/tmp/firebrand-icon-gfgSsL4O/default16.png': No such file or directory

Failed.

Offline

Board footer

Powered by FluxBB