Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2012-10-23 13:57:31 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-10-23 13:57:31 (GMT)
commit19018ad0352c1e46dd04df0d241372c76fdd0042 (patch)
tree1b82471325e524cad1597774b5b63b1f3b4b99f2
Initial commit
Signed-off-by: Daniel Francis <francis@sugarlabs.org>
-rw-r--r--.gitignore3
-rw-r--r--activity_luncher.py45
-rw-r--r--command.py30
-rw-r--r--desktop_luncher.py48
-rw-r--r--desktopbuild.py82
-rw-r--r--mime_type.py38
-rw-r--r--svg2png.py30
-rw-r--r--systeminstall.py52
-rw-r--r--xobuild.py81
9 files changed, 409 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..eef29c1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*~
+*.pyc
+
diff --git a/activity_luncher.py b/activity_luncher.py
new file mode 100644
index 0000000..ccf8815
--- /dev/null
+++ b/activity_luncher.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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 3 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import ConfigParser
+import sys
+import os
+os.environ['INFO_L10N'] = '0'
+appdir = os.path.abspath('./')
+sys.path.append(appdir)
+
+import info
+
+activity_file_stream = open('activity.info', 'w')
+activity_file = ConfigParser.RawConfigParser()
+activity_file.add_section('Activity')
+activity_file.set('Activity', 'name', info.name)
+activity_file.set('Activity', 'activity_version',
+ info.version)
+activity_file.set('Activity', 'show_launcher', '1')
+activity_file.set('Activity', 'bundle_id', info.service_name)
+activity_file.set('Activity', 'exec',
+ 'sugar-activity activity.Activity -s')
+activity_file.set('Activity', 'icon', 'activity-' + info.lower_name)
+activity_file.set('Activity', 'license', info.license)
+if info.file_filter_mime:
+ activity_file.set('Activity', 'mime_types', info.file_filter_mime)
+activity_file.write(activity_file_stream)
+activity_file_stream.close()
diff --git a/command.py b/command.py
new file mode 100644
index 0000000..c132993
--- /dev/null
+++ b/command.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 Daniel Francis <francis@sugarlabs.org>
+#
+# 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 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+import sys
+import os
+name = os.path.split(sys.argv[0])[-1]
+os.environ['DATADIR'] = '/usr/share/%s' % name
+os.environ['PROGRAMRUNNING'] = 'DESKTOP'
+os.environ['ICONDIR'] = '/usr/share/%s/icons' % name
+os.environ['TRANSLATIONDIR'] = '/usr/share/locale'
+os.environ['INFO_L10N'] = '1'
+os.system('python /usr/share/%s/application.py %s' % (name,
+ ('"%s"' % sys.argv[1]) if len(sys.argv) > 1 else ''))
diff --git a/desktop_luncher.py b/desktop_luncher.py
new file mode 100644
index 0000000..6f050cd
--- /dev/null
+++ b/desktop_luncher.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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 3 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import sys
+import os
+os.environ['INFO_L10N'] = '0'
+import pwd
+sys.path.append(os.path.abspath('./'))
+import info
+user = pwd.getpwuid(os.getuid()).pw_name
+execdir = '/usr/bin' if user == 'root' else os.path.abspath('./')
+appdir = '/usr/share/%s' % info.lower_name if user ==\
+ 'root' else os.path.abspath('./')
+
+desktop_file = open('app-entry.desktop', 'w')
+string = '[Desktop Entry]\nEncoding=UTF-8\n'
+string += 'Name=' + info.name
+string += '\nGenericName=' + info.generic_name
+string += '\nComment=' + info.description
+if user == 'root':
+ string += '\nExec=/usr/bin/command %U'.replace('command', info.lower_name)
+else:
+ string += '\nExec=' + os.path.join(appdir, info.lower_name) + ' %U'
+string += '\nIcon=' + os.path.join(appdir, info.lower_name + '.png')
+string += '\nTerminal=false'
+string += '\nCategories=' + ';'.join(info.categories)
+if info.file_filter_mime:
+ string += '\nMimeType=' + info.file_filter_mime + ';'
+string += '\nType=Application'
+desktop_file.write(string)
+desktop_file.close()
diff --git a/desktopbuild.py b/desktopbuild.py
new file mode 100644
index 0000000..84fcb15
--- /dev/null
+++ b/desktopbuild.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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 3 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import sys
+import os
+sys.path.append(os.path.abspath('.'))
+os.environ['INFO_L10N'] = '0'
+import tarfile
+import info
+
+ignore_ends = ['.pyc', '~']
+ignores = ['makescripts/activity_luncher.py', 'makescripts/xobuild.py', 'sugar',
+ 'activity', '.git', '.gitignore', 'mimetypes.xml', 'mimetype.png',
+ info.file_filter_mime.replace('/', '-') + '.xml',
+ info.lower_name + '.desktop',
+ info.lower_name + '.png',
+# 'data/appicon.svg', # Comment this line if you feel it's necessary.
+ 'activity.py']
+manifest = []
+
+
+def validate(path):
+ """Validate - Checks in the ignored files and ends"""
+ if path in ignores:
+ return False
+ for i in ignore_ends:
+ if path[-len(i):] == i:
+ return False
+ return True
+
+
+def packdir(path, newpath=None):
+ for i in os.listdir(path):
+ filepath = os.path.join(path, i)
+ filename = filepath[2:]
+ if validate(filename):
+ if os.path.isdir(filepath):
+ if filename == 'desktop':
+ for name in os.listdir(filepath):
+ new_filepath = os.path.join(filepath, name)
+ new_filename = new_filepath[2:]
+ if validate(new_filename):
+ packdir(new_filepath, os.path.join(newpath, name))
+ else:
+ if newpath:
+ packdir(filepath, os.path.join(newpath, filename))
+ else:
+ packdir(filepath)
+ else:
+ new_path = list(os.path.split(filename))
+ if newpath:
+ global new_path
+ if newpath != '.':
+ new_path[0] = newpath
+ manifest.append((filename, '/'.join(new_path)))
+ print '%s listed to pack' % filename
+
+packdir('./', '%s-%s' % (info.lower_name, info.version))
+
+tar = tarfile.open('./%s-%s.tgz' % (info.lower_name,
+ info.version), 'w:gz')
+for name, path in manifest:
+ tar.add(name, path)
+ print 'Packed %s as %s' % (name, path)
+tar.close()
diff --git a/mime_type.py b/mime_type.py
new file mode 100644
index 0000000..080b7a2
--- /dev/null
+++ b/mime_type.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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 3 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import sys
+import os
+appdir = os.path.abspath('./')
+sys.path.append(appdir)
+import info
+
+file_content = '<?xml version="1.0"?>\n'
+file_content +=\
+ " <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n"
+file_content += ' <mime-type type="%s">\n' % info.file_filter_mime
+file_content += ' <comment>%s</comment>\n' % info.file_filter_name
+for i in info.file_filter_patterns:
+ file_content += ' <glob pattern="%s" />\n' % i
+file_content += ' </mime-type>\n</mime-info>\n'
+
+file = open('mimetypes.xml', 'w')
+file.write(file_content)
+file.close()
diff --git a/svg2png.py b/svg2png.py
new file mode 100644
index 0000000..06eab59
--- /dev/null
+++ b/svg2png.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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 3 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import sys
+import os
+appdir = os.path.abspath('./')
+sys.path.append(appdir)
+import gtk
+
+import info
+
+pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(sys.argv[1], 48, 48)
+pixbuf.save(sys.argv[2], 'png')
diff --git a/systeminstall.py b/systeminstall.py
new file mode 100644
index 0000000..faad71e
--- /dev/null
+++ b/systeminstall.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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 3 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import sys
+import os
+import pwd
+sys.path.append(os.path.abspath('./'))
+import info
+user = pwd.getpwuid(os.getuid()).pw_name
+
+if user == 'root':
+ os.system('cp makescripts/command.py /usr/bin/%s' % info.lower_name)
+ try:
+ os.mkdir('/usr/share/%s' % info.lower_name)
+ os.mkdir('/usr/share/%s/icons' % info.lower_name)
+ except:
+ pass
+ os.system('cp -R desktop/sweetener /usr/share/%s/sweetener' %\
+ info.lower_name)
+ os.system('cp data/* /usr/share/%s/' % info.lower_name)
+ os.system('cp *.py /usr/share/%s/' % info.lower_name)
+ os.system('cp desktop/icons/*.svg /usr/share/%s/icons' %\
+ info.lower_name)
+ os.system('cp %s.png /usr/share/%s/' % (info.lower_name,
+ info.lower_name))
+ for i in os.listdir('locale'):
+ if not os.path.exists(os.path.join('/usr/share/locale', i)):
+ os.mkdir(os.path.join('/usr/share/locale', i))
+ if not os.path.exists(os.path.join('/usr/share/locale', i,
+ 'LC_MESSAGES')):
+ os.mkdir(os.path.join('/usr/share/locale', i,
+ 'LC_MESSAGES'))
+ os.system(
+ 'cp locale/%n%/LC_MESSAGES/*.mo /usr/share/locale/%n%/LC_MESSAGES/'.replace(
+ '%n%', i))
diff --git a/xobuild.py b/xobuild.py
new file mode 100644
index 0000000..300c2e9
--- /dev/null
+++ b/xobuild.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+#
+# 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 3 of the License, 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import sys
+import os
+sys.path.append(os.path.abspath('.'))
+os.environ['INFO_L10N'] = '0'
+import zipfile
+import info
+
+ignore_ends = ['.pyc', '~']
+ignores = ['makescripts', 'Makefile', 'install',
+ 'desktop', 'install', '.git', '.gitignore',
+ 'mimetypes.xml', 'mimetype.png',
+ info.file_filter_mime.replace('/', '-') + '.xml',
+ info.lower_name, info.lower_name + '.desktop',
+ info.lower_name + '.png',
+ 'data/appicon.svg', # Comment this line if you feel it's necessary.
+ 'application.py']
+manifest = []
+
+def validate(path):
+ """Validate - Checks in the ignored files and ends"""
+ if path in ignores:
+ return False
+ for i in ignore_ends:
+ if path[-len(i):] == i:
+ return False
+ return True
+
+def packdir(path, newpath=None):
+ for i in os.listdir(path):
+ filepath = os.path.join(path, i)
+ filename = filepath[2:]
+ if validate(filename):
+ if os.path.isdir(filepath):
+ if filename == 'sugar':
+ for name in os.listdir(filepath):
+ new_filepath = os.path.join(filepath, name)
+ new_filename = new_filepath[2:]
+ if validate(new_filename):
+ packdir(new_filepath, os.path.join(newpath, name))
+ else:
+ if newpath:
+ packdir(filepath, os.path.join(newpath, filename))
+ else:
+ packdir(filepath)
+ else:
+ new_path = list(os.path.split(filename))
+ if newpath:
+ global new_path
+ if newpath != '.':
+ new_path[0] = newpath
+ manifest.append((filename, '/'.join(new_path)))
+ print '%s listed to pack' % filename
+
+packdir('./', '%s.activity' % info.name.replace(' ', ''))
+
+xofile = zipfile.ZipFile('./%s-%s.xo' % (info.name.replace(' ', ''),
+ info.version), 'w')
+for name, path in manifest:
+ xofile.write(name, path)
+ print 'Packed %s as %s' % (name, path)
+xofile.close()