Add a script to install external activities

This commit is contained in:
Marco Pesenti Gritti 2006-08-04 15:54:28 +02:00
parent 3117d454b9
commit 167dbec0f5
6 changed files with 22 additions and 7 deletions

2
.gitignore vendored
View File

@ -32,5 +32,5 @@ po/POTFILES
po/stamp-it
po/sugar.pot
po/*.gmo
sugar/__installed__.py
tools/sugar-setup-activity

View File

@ -1,4 +1,4 @@
SUBDIRS = activities shell sugar
SUBDIRS = activities shell sugar tools
dbusconfdir = $(pkgdatadir)
dbusconf_DATA = dbus-installed.conf

View File

@ -40,4 +40,6 @@ sugar/p2p/Makefile
sugar/p2p/model/Makefile
sugar/presence/Makefile
po/Makefile.in
tools/Makefile
tools/sugar-setup-activity
])

View File

@ -11,8 +11,9 @@ class ServiceParser(ConfigParser):
def optionxform(self, option):
return option
def _install_activity(activity_dir, filename, dest_path, bin):
source = os.path.join(activity_dir, filename)
def setup_activity(source, dest_path, bin):
"""Copy an activity to the destination path and setup it"""
filename = os.path.basename(source)
dest = os.path.join(dest_path, filename)
print 'Install ' + filename + ' ...'
shutil.copyfile(source, dest)
@ -53,7 +54,7 @@ def _install_activity(activity_dir, filename, dest_path, bin):
service_cp.write(fileobject)
fileobject.close()
def install_activities(source_path, dest_path, bin):
def setup_activities(source_path, dest_path, bin):
"""Scan a directory for activities and install them."""
if os.path.isdir(source_path):
for filename in os.listdir(source_path):
@ -61,7 +62,8 @@ def install_activities(source_path, dest_path, bin):
if os.path.isdir(activity_dir):
for filename in os.listdir(activity_dir):
if filename.endswith(".activity"):
_install_activity(activity_dir, filename, dest_path, bin)
source = os.path.join(activity_dir, filename)
setup_activity(source, dest_path, bin)
if __name__=='__main__':
install_activities(sys.argv[1], sys.argv[2], sys.argv[3])
setup_activities(sys.argv[1], sys.argv[2], sys.argv[3])

1
tools/Makefile.am Normal file
View File

@ -0,0 +1 @@
bin_SCRIPTS = sugar-setup-activity

View File

@ -0,0 +1,10 @@
#!/usr/bin/python
import sys
from sugar import setup
setup.setup_activity(sys.argv[1],
'@prefix@/share/sugar/activities',
'@prefix@/bin/sugar-activity-factory')
print '%s installed.' % sys.argv[1]