roachfiend.com

  • firefox extensions
  • tutorials
  • faq
  • March 9, 2005

    Enabling Extension Updates

    Filed under: tutorials — Eric @ 5:16 pm

    So you’ve learned how to write your own extension. This tutorial will show you how to keep your users up to date with your latest version automatically.

    One of the cool things about having an update feature in your extension is the user won’t have to check your homepage all the time to see if there’s a new version available. Firefox will let them know that a new version is available as soon as you update it, thanks to a file called update.rdf.

    update.rdf resides on your server’s directory; in my case, it’s here:

    http://extensions.roachfiend.com/update.rdf

    You can take a look at it if you want. You’ll see that it’s got syntax highlighting and colors on it. This is good. That means that my server is correctly identifying it as an rdf file, and not just some random text file. This is the number one reason why things go awry when you try and set up an update file. There are two ways of remedying this if you run into problems: the first and easiest method is if you have cpanel running on your server. If so, just go to MIME types, and then add a new type as the following:

    MIME type: text/xml
    Extension: rdf
    

    If you don’t have cpanel installed, but you have an Apache server, you can add this to your root directory’s .htaccess file:

    AddType text/xml rdf
    

    Ok, now your server should recognize the file we’re going to create. Here’s a sample update.rdf file you can copy and paste, and edit as necessary. In this example we’ll track just one extension, but in my file posted above, you can see that you can keep tabs on a boatload of extensions.

    Note: There is no space between Description about=”urn:mozilla:extension: and {b4fb60db…} on lines 5 and 6 below. I had to split them up because it was too long on the web page. Sorry if this is what caused your insanity. Thanks, Karl!

    
    <?xml version="1.0"?>
    <r:RDF xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
           xmlns="http://www.mozilla.org/2004/em-rdf#">
    <!-- Foo Widget Extension -->
    <r:Description about="urn:mozilla:extension:
    {b4fb60db-ac1c-4c10-b0f6-39b0b0f56ea5}">
      <updates>
        <r:Seq>
          <r:li>
            <r:Description>
              <version>0.1</version>
              <targetApplication>
                <r:Description>
                  <id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id>
                  <minVersion>0.8</minVersion>
                  <maxVersion>1.9</maxVersion>
                  <updateLink>http://www.webserver.com/foowidget.xpi</updateLink>
                </r:Description>
              </targetApplication>
            </r:Description>
          </r:li>
        </r:Seq>
      </updates>
      <version>0.1</version>
      <updateLink>http://www.webserver.com/foowidget.xpi</updateLink>
    </r:Description>
    </r:RDF>
    

    So you would need to replace the web address and extension path as your own, as well as the first GUID that starts with b4fb… with your extension’s GUID. The second one that begins with ec80… is unique to Firefox, so leave that alone.

    You’ll notice two <version> tags- in the past sometimes the mechanism ignored any attributes outside of the <updates> tags, so having two ensured compatibility. To be honest, I don’t know if both are necessary, but it works, so hey, whatever. Put the current version number of your extension in there, so Firefox will have a new version to check against. If the number in here is greater than the user’s current release, then it will prompt them to install the new version.

    So, we’ve got the modified update.rdf file on the server. Now we need to tell the extension to call home to see if there’s a newer version. In your install.rdf file, you need this line:

    
    <em:updateURL>http://www.webserver.com/update.rdf</em:updateURL>
    

    That’s it! You can test it out by keeping an old version of an extension installed on your browser (that has the updateURL above in place) and uploading the new version on your server.



    -->

    38 Responses to “Enabling Extension Updates”

    1. Phil Ringnalda Says:

      One thing to keep in mind, for the advanced version of the tutorial, is managing raising maxVersion for old extension versions. If you package version 0.1 of your extension with maxVersion 1.0 of the application, then raise it in update.rdf to 1.1, and then you move on to version 0.2 of your extension, but some well-known and frozen-in-time site is still distributing version 0.1, you have to maintain updates elements for both versions of the extension, since someone trying to install 0.1 has to get the message that the maxVersion has been raised, so they can install 0.1, so that they can then be told to update to 0.2 the very first time they check for updates.

    2. Eric Says:


      That’s one of the reasons that I keep my extensions’ maxVersion at 1.2. Although technically incorrect, it has saved me from updating 9 extensions every few weeks. If the time comes where Firefox 1.2 is out and my extensions aren’t compatibile, I’ll simply change them so they are or delete them.


    3. Federico Says:

      I’ve done an extension at work and been trying to get update working for some time until I found this page. Before, I was copying the same update as for googlebar and some other extensions, but somehow it didn’t work. I just tried using your rdf file as template and worked! I really don’t understand how works for other extensions and I had to add updates, targetApplication, etc. tags to update.rdf to make it work for my extension. Any ideas? It’s a personal thing now ;-)

    4. Ihoss Says:

      In the htaccess file you should in fact have a . before the rdf:

      AddType text/xml .rdf

    5. Eric Says:


      Ihoss, the period makes no difference. When done through cpanel, the htaccess file that is generated doesn’t have one, so if anything, it’s preferred to leave it out.


    6. Jimmy Jazz Says:

      The period makes no difference. The webserver will just check if what you entered exists at the very “end” of the file.
      Example: poop.rdf
      rdf
      ||| =-=-=-Match Found
      poop.rdf
      .rdf
      |||| =-=-=-Match Found

      I like things optimized though, so stick without the period, itll speed things up .00001 percent :D

    7. KDS Says:

      And also remember to have the mime type for xpi files on your sever as:

      AddType application/x-xpinstall .xpi

    8. Eric Says:


      I installed it before I replied. That’s why I wrote that it didn’t make any sense. I don’t know why you’re getting a download error, but it works for me and it works on several different machines that I’ve tried.


    9. LAuX Says:

      Dear Eric, thanks for your two tutorials.
      I’m doing an extension for interactive use with webradio http://www.frequence3.fr/ and I just needed YOU to do it. Great job.

    10. bamm Says:

      How do I make an update.rdf file for themes? Does it work the same way as for extensions? Thanks.

    11. bamm Says:

      Tried it, yup it does work the same way for themes. Thanks!

    12. Two Ells » Auto-Updating Extensions Says:

      […] Firefox / Mozilla — daryl @ 8:57 am Eric Hamiter’s tutorial on how to enable extension updates is pretty handy. As he points out, in order to mak […]

    13. Sagar Says:

      I am developing a generic extension. I don’t want to hardcode the updateURL in the install.rdf. How can I do that?

    14. honkeytonk Says:

      AWESOME! Thanks so much for this and your tutorial on how to write them. It is exactly what I was looking for and helped me a lot. You are a very nice man, Eric ;)

    15. mscrab Says:

      Hi! These guys have a online form to generate update.rdf contents.

      http://www.gmacker.com/web/content/tutorial/firefox/updatefirefoxext.htm

    16. Devsyn Web Crafting Services Says:

      […]How to Create Firefox Extensions
      Eric of roachfiend.com has two helpful tutorials up on How to Create Firefox Extensions and Enabling Extension Updates. These’ll come in handy soon. Hint hint (via Gina).

    17. Eric Says:


      I updated the original post to increase the maxVersion number to 1.9 so it’ll work for current Firefox releases and hopefully future-proof your extensions for at least a few months.


    18. corn23 Says:

      Hallo there,

      Does anybody know where to find a reference which events are fired at what time?

    19. Karl Says:

      For the longest time the extension manager would tell me there were “no updates available”. It was because I combined the 5th and 6th lines above into one line, including a space where the newline was–

      became

      Bad idea. Do NOT put a space after that colon.
      Hope I save someone frustration.

    20. Karl Says:

      Hmm… the stuff inside my “code” blocks is gone. I think the point still comes across, though. I was talking about lines 5 and 6 of Eric’s update.rdf example.

    21. matt Says:

      I just had the space after urn:mozilla:extension: problem

      I should have read the comments 30 minutes ago!

    22. Nick Says:

      Hello All,

      If an extension’s GUID is changed - is it possible to update the versions with the older GUID?

      Are there any workarounds for this or is it not possible at all?

      Thanks,

    23. Soyapi Says:

      Nice tutorial!

      If there is room for suggestions, consider showing how to create an update.rdf file that has multiple target applications (e.g Firefox, Thunderbird, Flock)

      I had to search for an example and found http://divmod.org/trac/browser/trunk/ClickChronicle/extension/update.rdf?rev=3723

    24. Poker Guide Says:

      Well that just answered the question I just asked in the last article. Sorry, I should have checked here first.

    25. mojo Says:

      i just have found, that i can’t use id in format “extensionname@organization.tld” as is suggested in the article:
      http://developer.mozilla.org/en/docs/Install_Manifests#id

      so, urn:mozilla:extension:extensionname@organization.tld leads to inability to find updates.

      is there some workaround or rule of using such ids in update.rdf?

      thanks.

    26. Adnan Siddiqi Says:

      Dear Eric

      Currently i am reading your basic tutorial about FF extension and “I am loving It!!”.

      You are continously discussing about MIMEType and .htaccess.If i have IIS server,can a link html link of .xpi file won’t install my extension to browser?

      2nd question is about your current article.You discussed about updating toolbar and adding

      http://www.webserver.com/foowidget.xpi

      for auto updation.If you are using beta google toolbar,the xml file they have provide have Url to update the content of extension or say toolbar button itself.Does FF provide some built-in facility for such task?

      Thankyou

    27. Peter Says:

      Good, it works!

    28. Fred Says:

      Thanks to Eric for the tutorial and big thanks to Karl who save my mind with the space problem bettwen line 5 and 6(it take me 30 minutes to decide to read the comments).

    29. Nitallica Says:

      I’ve long been a fan of your extensions, and as I’ve lately begun the quest to build my own, I’ve become a fan of your tutorials. Today I am releasing my first “public” extension — thanks to your very helpful tuts. Thank you for putting the time and effort into sharing these with us. On my extensions page on my website, yours is the first developer’s resource I’ve listed, and is certainly most recommended. :)

      Thank you for your time and efforts!

    30. car insurance Says:

      Hello guys can you please help me?

    31. JohnnyLeitrim Says:

      My update.rdf file is hosted on a webserver that requires regular authentication. This means that the update check will fail unless the user happens to have logged in to the webserver lately. Is there anything in the RDF specification that allows you to ask (or get) webserver credentials so firefox can check the update file?

      Great tutorial BTW!!

    32. Bahram Says:

      Hi,
      i created my auto update rdf file, and added the MIME type, hoverer it does not works, any idea?

      here is the link to my update file:
      http://68.178.173.234/downloads/localization/update.rdf

      the current version in the xpi is 0.1 and in the rdf file 0.3, so the auto update should be triggered, what is wrong?

      Thanks.

    33. Eric Says:


      Try emptying your cache and re-visiting your update.rdf page in your browser.


    34. DanRoberts Says:

      Does anyone know of a fix for what mojo describes above (id=name@domain) — or know for sure whether this is a problem? When I try to find updates for my extension it says no updates were found though my update.rdf is a version higher and everything else appears to comply with the tutorial above. Thanks for any help.

    35. DanRoberts Says:

      Well I spoke too soon. I looked at the update.rdf for some of the extensions I use and noticed they don’t use the brackets {} if not using a GUID. Once I removed the brackets in the update.rdf file the updated version was detected and the update ran fine. Thanks for the tutorial!

    36. Myip Says:

      Thank you for your time and efforts!

    37. DAC324 Says:

      Does not work no matter what I tried.

      There are different approaches for in the install.rdf file, some just like this:

      http://home.arcor.de/dac324/firefox/germanlocale/update.rdf

      Is this really necessary?

      My update.rdf resides here:

      http://home.arcor.de/dac324/firefox/germanlocale/update.rdf

      I have version set to 0.0.1 in install.rdf and 0.2 in update.rdf. However, Firefox (3.0a7pre) tells me that it can not find any updates.

    38. DAC324 Says:

      I found the culprit: Add-On updates are only allowed for add-on types 2 (extension) and 4 (theme) but not for 8 (locale). So I had to change the add-on type to 2 in order to enable updates.

    Leave a Reply

    You must be logged in to post a comment.