HOW-To_Create a Repository for Add-Ons - XBMC

6
09.12.2013 HOW-TO:Create a repository for add-ons - XBMC wiki.xbmc.org/index.php?title=HOW-TO:Create_a_Repository_to_host_your_Add-on 1/6 HOW-TO:Create a repository for add-ons From XBMC (Redirected from HOW-TO:Create a Repository to host your Add-on) Development Add-on development Add-on repositories Create a repository for add-ons When you have created your repository, feel free to add it to the 3rd party add-on repositories list. Contents 1 Things you will require 2 Repository Files 3 Tips 3.1 Using your repo to host images 3.2 How to make an add-on self-updating without distributing a repository file 4 See also 1 Things you will require Any HTTP server. A popular method is to use the svn or git source code servers of googlecode, gitorious and github. - In your code project page, make sure you set up the correct version control system (source tab). - This will get you the right checkout address (link) and folder structure. A folder containing one or more add-on. - Start by installing an svn program (like Tortoisesvn). - Right click the empty folder, choose 'SVN Checkout' to let it build a folder structure inside. - Make sure you get asked for authentication (!), the folders look like your source code server. - If you don't get asked for authentication check your server settings and http vs https links. - Make a test.txt file in the trunk, right click to mark it as 'add' and use and use 'SVN Commit' Make the following two files using the python code below. These 2 files are made from the addon.xml files in the folders below (from the addons). Where you can have your addon unzipped (or zipped as long as there is an addon.xml file next to it, that is always up to date with the one in the zip). - A master addon s .xml file. This file contains metadata about all available add-ons. - A checksum of the above file (this file only contains a hash of addons.xml). A zipped repository add-on for distribution. This allows you to share your repository with others.

description

er

Transcript of HOW-To_Create a Repository for Add-Ons - XBMC

Page 1: HOW-To_Create a Repository for Add-Ons - XBMC

09.12.2013 HOW-TO:Create a repository for add-ons - XBMC

wiki.xbmc.org/index.php?title=HOW-TO:Create_a_Repository_to_host_your_Add-on 1/6

HOW-TO:Create a repository for add-onsFrom XBMC

(Redirected from HOW-TO:Create a Repository to host your Add-on)

Development Add-on development Add-on repositories Create a repository for add-ons

When you have created your repository, feel free to add it to the 3rd party add-on repositories list.

Contents

1 Things you will require

2 Repository Files3 Tips

3.1 Using your repo to host images3.2 How to make an add-on self-updating without distributing a repository file

4 See also

1 Things you will require

Any HTTP server. A popular method is to use the svn or git source code servers of googlecode, gitorious

and github.

- In your code project page, make sure you set up the correct version control system (source tab). Most skins use SVN.

- This will get you the right checkout address (link) and folder structure.

A folder containing one or more add-on.

- Start by installing an svn program (like Tortoisesvn).

- Right click the empty folder, choose 'SVN Checkout' to let it build a folder structure inside.

- Make sure you get asked for authentication (!), the folders look like your source code server.

- If you don't get asked for authentication check your server settings and http vs https links.

- Make a test.txt file in the trunk, right click to mark it as 'add' and use and use 'SVN Commit' on top folder.

Make the following two files using the python code below. These 2 files are made from the addon.xml files in

the folders below (from the addons). Where you can have your addon unzipped (or zipped as long as thereis an addon.xml file next to it, that is always up to date with the one in the zip).

- A master addons.xml file. This file contains metadata about all available add-ons.

- A checksum of the above file (this file only contains a hash of addons.xml).

A zipped repository add-on for distribution. This allows you to share your repository with others.

Page 2: HOW-To_Create a Repository for Add-Ons - XBMC

09.12.2013 HOW-TO:Create a repository for add-ons - XBMC

wiki.xbmc.org/index.php?title=HOW-TO:Create_a_Repository_to_host_your_Add-on 2/6

- Easiest way is to have a look at another repository file and change the name, info and links.

- You can also have a look at how other repos set up their folder structure.

You can use addons_xml_generator.py[1]

(https://raw.github.com/garbear/unqlocked/master/addons_xml_generator.py) to generate the master xml and theMD5. Put it in the folder with all your add-ons (it needs to see addon.xml files in a folder below) and run it fromyour Python interpreter. If using a source code server, you can now upload your add-on folder via svn or git toyour repository. Every time you update an add-on run the addons_xml_generator.py before uploading the add-onsfolder.

For Windows users. Install the latest version of Python.msi (from their website) in it's default directory.

Python (.py) files should now be associated with python.exe and can be run like a program.

Make a new text file and name it addons_xml_generator.py. Open it with Notepad++ (or equivalent)

and paste the following code inside.

addons_xml_generator.py

# *# * Copyright (C) 2012-2013 Garrett Brown# * Copyright (C) 2010 j48antialias# *# * This Program is free software; you can redistribute it and/or modify# * it under the terms of the GNU General Public License as published by# * the Free Software Foundation; either version 2, or (at your option)# * any later version.# *# * This Program is distributed in the hope that it will be useful,# * but WITHOUT ANY WARRANTY; without even the implied warranty of# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# * GNU General Public License for more details.# *# * You should have received a copy of the GNU General Public License# * along with XBMC; see the file COPYING. If not, write to# * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.# * http://www.gnu.org/copyleft/gpl.html# *# * Based on code by j48antialias:# * https://anarchintosh-projects.googlecode.com/files/addons_xml_generator.py """ addons.xml generator """ import osimport sys # Compatibility with 3.0, 3.1 and 3.2 not supporting u"" literalsif sys.version < '3':

Page 3: HOW-To_Create a Repository for Add-Ons - XBMC

09.12.2013 HOW-TO:Create a repository for add-ons - XBMC

wiki.xbmc.org/index.php?title=HOW-TO:Create_a_Repository_to_host_your_Add-on 3/6

import codecs

def u(x): return codecs.unicode_escape_decode(x)[0]

else: def u(x): return x

class Generator:

""" Generates a new addons.xml file from each addons addon.xml file and a new addons.xml.md5 hash file. Must be run from the root of the checked-out repo. Only handles single depth folder structure. """ def __init__( self ):

# generate files self._generate_addons_file() self._generate_md5_file() # notify user print("Finished updating addons xml and md5 files")

def _generate_addons_file( self ): # addon list addons = os.listdir( "." ) # final addons text addons_xml = u("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=

# loop thru and add each addons addon.xml file for addon in addons:

try: # skip any file or .svn folder or .git folder if ( not os.path.isdir( addon ) or addon == ".svn" or # create path _path = os.path.join( addon, "addon.xml" ) # split lines for stripping xml_lines = open( _path, "r" ).read().splitlines() # new addon addon_xml = "" # loop thru cleaning each line for line in xml_lines:

# skip encoding format line if ( line.find( "<?xml" ) >= 0 ): continue

# add line if sys.version < '3':

addon_xml += unicode( line.rstrip() + "\n",

else: addon_xml += line.rstrip() + "\n"

# we succeeded so add to our final addons.xml text addons_xml += addon_xml.rstrip() + "\n\n"

Page 4: HOW-To_Create a Repository for Add-Ons - XBMC

09.12.2013 HOW-TO:Create a repository for add-ons - XBMC

wiki.xbmc.org/index.php?title=HOW-TO:Create_a_Repository_to_host_your_Add-on 4/6

except Exception as e: # missing or poorly formatted addon.xml print("Excluding %s for %s" % ( _path, e )) # clean and add closing tag addons_xml = addons_xml.strip() + u("\n</addons>\n")

# save file self._save_file( addons_xml.encode( "UTF-8" ), file="addons.xml" def _generate_md5_file( self ):

# create a new md5 hash try:

import md5

m = md5.new( open( "addons.xml", "r" ).read() ).hexdigest except ImportError: import hashlib

m = hashlib.md5( open( "addons.xml", "r", encoding="UTF-8" # save file try:

self._save_file( m.encode( "UTF-8" ), file="addons.xml.md5" except Exception as e: # oops print("An error occurred creating addons.xml.md5 file!\n

def _save_file( self, data, file ): try:

# write data to the file (use b for Python 3) open( file, "wb" ).write( data ) except Exception as e: # oops print("An error occurred saving %s file!\n%s" % ( file, e

if ( __name__ == "__main__" ): # start Generator()

2 Repository Files

Repositories are distributed just like any other add-on. In order for you to browse one in XBMC, you'll need tocreate an add-on and install it. The repository addon extends the xbmc.addon.repository extension point, so inaddition to the general XML structure and icons required for an icon, you'll need an <extension> block specficallypointing to your repository. Use the addon.xml of any of the 3rd party add-on repositories as a template. Onlinerepositories should always have zip set to true, both for efficiency of download and for the protection that .zipoffers by way of verifying the download (i.e. can we unzip it).

Page 5: HOW-To_Create a Repository for Add-Ons - XBMC

09.12.2013 HOW-TO:Create a repository for add-ons - XBMC

wiki.xbmc.org/index.php?title=HOW-TO:Create_a_Repository_to_host_your_Add-on 5/6

3 Tips

3.1 Using your repo to host images

You may as a developer need to host images from time to time. Something like photobucket or flickr may work,but you can also use your repo. Commit an image to it, and then form the url to it as you would if you wereaccessing the image via git or svn (like below):

http://xbmc-adult.googlecode.com/svn/trunk/repository.xbmc-adult/icon.png

This can then be accessed easily from python code, or even embedded on the XBMC forums.

3.2 How to make an add-on self-updating without distributing a repository file

This is optional. You still need a repository for this, you just distribute the actual zipped plugin or script, as opposedto the repository file. First you need to have a working repository file. Copy the equivalent of this code from theaddon.xml of your repository file:

<extension point="xbmc.addon.repository" name="Official XBMC.org Add-on Repository">

<info compressed="true">http://mirrors.xbmc.org/addons/dharma-pre/addons.xml

<checksum>http://mirrors.xbmc.org/addons/dharma-pre/addons.xml.md5

<datadir zip="true">http://mirrors.xbmc.org/addons/dharma-pre</datadir </extension>

Then simply add it under the other <extension point> entries of your add-on's addon.xml The name= part of thisrepository extension must never be the same as your add-on.

4 See also

3rd party add-on repositories

Development:

Add-on development

Add-on repositories

Retrieved from "http://wiki.xbmc.org/index.php?title=HOW-TO:Create_a_repository_for_add-ons&oldid=63841"Categories: Addon Development Skin Development Development Repositories

This page was last modified on 31 August 2013, at 16:23.This page has been accessed 1,378 times.

Page 6: HOW-To_Create a Repository for Add-Ons - XBMC

09.12.2013 HOW-TO:Create a repository for add-ons - XBMC

wiki.xbmc.org/index.php?title=HOW-TO:Create_a_Repository_to_host_your_Add-on 6/6

Content is available under Attribution-ShareAlike 3.0 Unported.