Monthly Archives: February 2013

Create your own Cydia Repository on Ubuntu in a few minutes

I’ve created a simple Perl script which automatically builds your .deb files and compiles your Cydia Repository. Never bzip and gzip the ‘Packages’ file in the console again, never calculate and enter the md5 hashes by hand again. Here is a step-by-step tutorial:

(By the way, check out my own repository: http://patrickmuff.ch/repo/. It has some cool lockscreen themes on it, like this, this and this.)

Download and install Ubuntu

Download a 32-bit version of Ubuntu on this site. Install it in a virtual machine. I used VMWare Fusion on OS X and VMWare Player on Windows to do this.

Set up your Ubuntu

Simply install it like you would install an operating system. Now download this zip archive. Unzip it and drag it onto your Ubuntu desktop. You now need to install dpkg-scanpackages and dpkg-gettext.pl. To do that, start a terminal, authenticate yourself and navigate to the desktop:

sudo -s
cd Desktop/

Copy dpkg-scanpackages to /usr/bin

cp dpkg-scanpackages /usr/bin

Give it some rights with chmod

chmod 0777 /usr/bin/dpkg-scanpackages

Now do (nearly) the same with gettext.pl

cp dpkg-gettext.pl /etc/perl
chmod 0777 /etc/perl/dpkg-gettext.pl

You need to configure GnuPG. Execute this command, then enter the following.

 gpg --gen-key
1
1024
0
y
Your Name (e.g. Johnny Depp)
Your Email (e.g. johhny.depp@gmail.com)
Comment (e.g. Pirate)
o
Passphrase (You need to enter this every time you compile the repository)
Repeat your passphrase
Now type random letters on your keyboard until something happens.

Create a *.deb package

Create a new folder and name it after your package. The subfolder structure should look like this:

+- MyTheme
   +- DEBIAN
   |  +- control
   +- Library
      +- Themes
         +- yourTheme.theme

“Library/Themes” can be any directory on your device. Got it? Now for that control file; Create a file without any extension and paste this into it:

Package: com.dislick.blur
Name: Blur Lockscreen
Version: 0.1
Architecture: iphoneos-arm
Description: simple blurry lockscreen
Depiction: URL. This webpage replaces the description in Cydia. If you don't want this, remove the entire line.
Homepage: http://patrickmuff.ch
Maintainer: Patrick Muff
Author: Patrick Muff
Section: Themes

Important! If you don’t add a new line at the bottom of the file, you will not be able to build it! So just press enter after the section line.

Great, your package is ready. You don’t need to build it by hand, my perl script will take care of this. The only thing you have to do now is copying this folder into your Ubuntu desktop and place it in repo/uncompiled-packages.

Customize your repository

Go the the repo/ folder and open up “Release-Template” with gedit or any other text editor. This file will be used to name your repository and pass a few metadata to Cydia. It also contains MD5 hashes of the three Packages files. Those are generated by my script, you don’t need to do it by hand.

Run the script

Go back to your Ubuntu terminal and make sure you’re in the repo folder. Do this by entering this command which will list every file and directory in your current folder:

ls

If you see a file called “compile-repo”, you’re good to go. If not, navigate back and forth with the “cd”-command.

perl compile-repo

This will compile your repository. To GnuPG encrypt the ‘Release’ file you need to enter the passphrase you defined before. After that, you’re done. Now upload the entire repo folder on a webspace and enter the URL in Cydia!

In case you are an advanced user and are just interested in the perl script:

#!/usr/bin/env perl

# Author: Patrick Muff <muff.pa@gmail.com>
# Purpose: Compiles a Cydia repository

use Digest::MD5;

sub md5sum {   
    my $file = shift;
    my $digest = "";
    eval {
        open(FILE, $file) or die "Can't find file $file\n";
        my $ctx = Digest::MD5->new;
        $ctx->addfile(*FILE);
        $digest = $ctx->hexdigest;
        close(FILE);
    };
    if ($@) {
        print $@;
        return ""; 
    }  
    return $digest;
}

# build packages into deb/ 
system("chmod 0755 uncompiled-packages/ -R");

my $directory = 'uncompiled-packages/';
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR)) {
	system("dpkg -b uncompiled-packages/".$file." deb/".$file.".deb");
}
closedir(DIR);

# scan the packages and write output to file Packages 
system("dpkg-scanpackages deb / > Packages");

# bzip2 it to a new file 
system("bzip2 -fks Packages");

# gzip it  
system("gzip -f Packages");

# scan again because we zipped the original file  
system("dpkg-scanpackages deb / > Packages");

# calculate the hashes and write to Release  
system("cp Release-Template Release");
open(RLS, ">>Release");

@files = ("Packages", "Packages.gz", "Packages.bz2");
my $output = "";

foreach (@files) {
 	my $fname = $_;
	my $md5 =  md5sum($fname);
	my $size = -s $fname;
	$output = $output.$md5." ".$size." ".$fname."\n";
};

print RLS $output;
close(RLS);

# remove Release.gpg  
system("rm Release.gpg");

# generate Release.gpg  
system("gpg -abs -o Release.gpg Release");

exit 0;