From 80c7309c3ef0f9c466a5f5929824d6359d726866 Mon Sep 17 00:00:00 2001 From: ruuti Date: Sun, 20 Nov 2016 12:45:55 +0100 Subject: [PATCH 1/2] Correct pip install url added. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d298168..48f7513 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ In addition to publishing updates via the appcast feed, Django-sparkle-project c ## Setup -1. `pip install https://github.com/ruuti/django-sparkle-project` +1. `pip install https://github.com/ruuti/django-sparkle-project/archive/master.zip` 2. Add `sparkle` to your installed apps 4. In `settings.py` add `SPARKLE_PRIVATE_KEY_PATH` which is the path to your private DSA key for signing your releases. 5. In `urls.py` include the sparkle URLs by adding something like `(r'^sparkle/', include('sparkle.urls'))`. From 18fce52e3f059bb120cc6d5025bd49e1dfc20bc4 Mon Sep 17 00:00:00 2001 From: ruuti Date: Sun, 20 Nov 2016 12:48:31 +0100 Subject: [PATCH 2/2] Save method overrided in Version model. LSMinimumSystemVersion, CFBundleShortVersionString, CFBundleVersion are not anymore populated using Info.plist. Version update file is stored to root by default. --- sparkle/models.py | 62 ++++----------------------- sparkle/templates/sparkle/appcast.xml | 2 +- 2 files changed, 9 insertions(+), 55 deletions(-) diff --git a/sparkle/models.py b/sparkle/models.py index 0b12124..80e53ae 100644 --- a/sparkle/models.py +++ b/sparkle/models.py @@ -28,73 +28,27 @@ class Version(models.Model): release_notes = models.TextField(blank=True, null=True) minimum_system_version = models.CharField(blank=True, null=True, max_length=10) published = models.DateTimeField(auto_now_add=True) - update = models.FileField(upload_to='sparkle/') + update = models.FileField() active = models.BooleanField(default=False) def __unicode__(self): return self.title def save(self, *args, **kwargs): - super(Version, self).save(*args, **kwargs) - - update = False - path = os.path.join(settings.MEDIA_ROOT, self.update.path) - + # if there is no dsa signature and a private key is provided in the settings if not self.dsa_signature and SPARKLE_PRIVATE_KEY_PATH and os.path.exists(SPARKLE_PRIVATE_KEY_PATH): command = 'openssl dgst -sha1 -binary < "%s" | openssl dgst -dss1 -sign "%s" | openssl enc -base64' % (path, SPARKLE_PRIVATE_KEY_PATH) process = os.popen(command) self.dsa_signature = process.readline().strip() process.close() - update = True - - # if there is no length and it is a zip file - # extract it to a tempdir and calculate the length - # also parse the plist file for versions - if not self.length and path.endswith('.zip'): - zip_file = zipfile.ZipFile(path) - tempdir = tempfile.mkdtemp() - files = zip_file.namelist() - start_path = None - - for f in files: - if f.endswith('/'): - d = os.path.join(tempdir, f) - if not start_path: - start_path = d - os.makedirs(d) - else: - zip_file.extract(f, tempdir) - - total_size = 0 - for dirpath, dirnames, filenames in os.walk(start_path): - for f in filenames: - fp = os.path.join(dirpath, f) - total_size += os.path.getsize(fp) - - info_plist = os.path.join(start_path, 'Contents/Info.plist') - if os.path.exists(info_plist): - plist = plistlib.readPlist(info_plist) - - if not self.version and 'CFBundleVersion' in plist: - self.version = plist.get('CFBundleVersion') - - if not self.short_version and 'CFBundleShortVersionString' in plist: - self.short_version = plist.get('CFBundleShortVersionString') - - if not self.minimum_system_version and 'LSMinimumSystemVersion' in plist: - self.minimum_system_version = plist.get('LSMinimumSystemVersion') - - shutil.rmtree(tempdir) - - self.length = total_size - update = True - - if update: - self.save() - - + # Calculate file size + if not self.length : + # TODO: set correct size + self.length = 0 + + super(Version, self).save(*args, **kwargs) class SystemProfileReport(models.Model): """A system profile report""" diff --git a/sparkle/templates/sparkle/appcast.xml b/sparkle/templates/sparkle/appcast.xml index 7ab2c5e..3a06cda 100644 --- a/sparkle/templates/sparkle/appcast.xml +++ b/sparkle/templates/sparkle/appcast.xml @@ -14,7 +14,7 @@ {{ version.published|date:"r" }} {% if version.minimum_system_version %}{{ version.minimum_system_version }}{% endif %} - + {% endfor %}