This file is indexed.

/usr/share/screenlets-manager/screenlets-debianizer.py is in screenlets 0.1.6-0ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#!/usr/bin/env python
#

# 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, see <http://www.gnu.org/licenses/>.

# A small app to package a screenlet into an easily distributible archive
# Useful for screenlet-developers ..
#
# (c) Guido Tabbernuk 2010, 2012
# <boamaod@gmail.com>
#
# Used code from:
# (c) RYX (Rico Pfaus) 2007 and Whise Helder Fraga
#

import sys, os, subprocess
from datetime import datetime
import screenlets
import textwrap
import gettext

gettext.textdomain('screenlets-manager')
gettext.bindtextdomain('screenlets-manager', screenlets.INSTALL_PREFIX +  '/share/locale')

def _(s):
	return gettext.gettext(s)

def write_conf_file(path, contents):
	f = open(path, 'w')
	if f:
		f.write(contents)
		f.close()
	else:
		print "!!!", path
		raise Exception

# + constants
USAGE = _("""Screenlets debianizer - (c) Guido Tabbernuk 2010
Usage: screenlets-debianizer <path> [debuild keys or anything you like]
Caution!!!   You need lot of packages installed in your system as well as a bzr user set up to build a deb!
""")

# + globals (make commandline options from these)
# surpress any output if true
quiet		= False

# + functions
def msg (str):
	if not quiet:
		print str

def err (str):
	sys.stderr.write('Error: ' + str)

def die (str):
	err (str)
	sys.exit(1)


compatibility_mode = False

# + start app
# check path-argument
argc = len(sys.argv)
arg_start = 1
if argc < 2:
	die(USAGE)
else:
	path = sys.argv[arg_start]
	if path[-1] == '/':
		path = path[:-1]
	arg_start += 1

arguments = []

# check options and set vars (TODO)
if argc > arg_start:
	for var in sys.argv[arg_start:]:
		arguments.append(var)

# check for existence of directory to be packaged
if not os.path.isdir(path):
	die(_('The specified path "%s" does not exist.') % path)
msg(_('Found path "%s".') % path)

# get name of screenlet from the pathname
try:
	sl_name = path[path.rfind('/')+1:]
except:
	die(_('Failed to extract screenlet name from path.'))
msg(_('Screenlet name is %s.') % sl_name)

sl_path = path + '/' + sl_name

# check for correct file inside path
if not os.path.isfile(sl_path + 'Screenlet.py'):
	die(_('No screenlet-file "%sScreenlet.py" found in the given path.') % sl_name)
msg(_('Found %sScreenlet.py in path.') % sl_name)

# import the screenlets module from inside the dir and lookup the class
if sys.path.count(path) == 0:
	sys.path.insert(0, path)
try:
	sl_module = __import__(sl_name + 'Screenlet')
	sys.path.remove(path)
except Exception, ex:
	die("Unable to import module '%s' from %s. (%s)" % (sl_name, path, ex))
msg(_('Successfully imported module: %s') % str(sl_module))

# lookup screenlet class
try:
	sl_class = getattr(sl_module, sl_name + 'Screenlet')
except Exception, ex:
	die(_("Unable to import class from module."))
if not issubclass(sl_class, screenlets.Screenlet):
	die(_('The class inside the module is no subclass of screenlets.Screenlet.'))
msg(_('Successfully got class from module: %s') % str(sl_class))

# create a debian control file
deb_name = screenlets.utils.get_screenlet_linux_name_by_class_name(sl_class.__name__)
deb_requires = ", ".join(map(str, sl_class.__requires__))
deb_packager = os.popen("bzr whoami").readline().replace('\n', '')

paragraphed_desc = sl_class.__desc__.replace("\t", " ").strip().split('\n\n')

desktop_desc = " ".join(paragraphed_desc[0].split())

deb_synopsis = None
deb_desc = ""
for line in paragraphed_desc:
	print line
	if deb_synopsis is None:
		lead = line.split("\n")
		wrapped = textwrap.wrap(lead[0].strip(), 63)
		deb_synopsis = wrapped[0]
		if len(wrapped) > 1:
			del(lead[0])
			del(wrapped[0])
			line = "\n".join(wrapped) + "\n".join(lead) # will continue the sentence truncated in synopsis
			print "SYN(CUT_WRAP)", deb_synopsis
		else:
			if len(lead) > 1:
				del(lead[0])
				line = "\n".join(lead) # will continue the sentence truncated in synopsis
				print "SYN(CUT_LEAD)", deb_synopsis
			else:
				print "SYN", deb_synopsis
				continue # description starts as a new paragraph
	current_addition = " " + "\n ".join(textwrap.wrap(" ".join(line.split()), 76)) + "\n .\n"
	print current_addition
	deb_desc += current_addition
if deb_desc.endswith(" .\n"):
	deb_desc = deb_desc[:len(deb_desc)-3]

if deb_synopsis is None:
	deb_synopsis = "a screenlet called" + sl_class.__name__
screenlet_author = sl_class.__author__

print "Going for: %s" % deb_name

control = """Source: %s
Section: gnome
Priority: optional
Maintainer: %s
Uploaders: %s
Build-Depends: debhelper (>= 5)
Standards-Version: 3.7.2

Package: %s
Depends: screenlets (>= 0.1.2-9), %s
Architecture: all
Description: %s
%s""" % (deb_name, deb_packager, screenlet_author, deb_name, deb_requires, deb_synopsis, deb_desc)

release = os.popen("lsb_release -cs").readline().replace('\n', '')
deb_date = os.popen("date -R").readline().replace('\n', '')
deb_version = sl_class.__version__

changelog = """%s (%s) %s; urgency=low

  * Created automatically by The Screenlets Debianizer.

 -- %s  %s""" % ( deb_name, deb_version, release, deb_packager, deb_date)

rules = """#!/usr/bin/make -f
# -*- makefile -*-
build:
clean:
	dh_testdir
	dh_testroot
	dh_clean 
install:
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs
	$(MAKE) DESTDIR=$(CURDIR)/debian/%s install
binary-indep: build install
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_installexamples
#	dh_install
#	dh_installmenu
#	dh_installdebconf
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_python
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure""" % deb_name

compat = """5"""

Makefile = """SYSTEM_SCREENLETS_DIR = $(DESTDIR)/usr/share/screenlets
XDG_DESKTOP_FILES_DIR = $(DESTDIR)/usr/share/applications/screenlets

install:
	mkdir -p $(SYSTEM_SCREENLETS_DIR)
	cp -r screenlet/* $(SYSTEM_SCREENLETS_DIR)
	mkdir -p $(XDG_DESKTOP_FILES_DIR)
	cp -r xdg-desktop/* $(XDG_DESKTOP_FILES_DIR)
	for file in $$(ls -1 po/); do mkdir -p $(DESTDIR)/usr/share/locale/$${file%.po}/LC_MESSAGES; msgfmt -v -o $(DESTDIR)/usr/share/locale/$${file%.po}/LC_MESSAGES/""" + deb_name + ".mo po/$$file; done"

#print "=========================================================="
#print control
#print "=========================================================="

desktop_file = """[Desktop Entry]
Name=%s
Encoding=UTF-8
Version=1.0
Type=Application
GenericName=Desktop widget
Comment=%s
Exec= python -u /usr/share/screenlets/%s/%sScreenlet.py
""" % (sl_name, desktop_desc, sl_name, sl_name)

try:

	icon = None
	if os.path.exists("%s/icon.svg" % path):
		icon = "icon.svg"
	elif os.path.exists("%s/icon.png" % path):
		icon = "icon.png"
	if icon is not None:
		desktop_file += "Icon=/usr/share/screenlets/%s/%s" % (sl_name, icon)

	os.system('rm -rf /tmp/%s' % deb_name)
	os.system('mkdir -p /tmp/%s/debian' % deb_name)
	os.system('mkdir -p /tmp/%s/screenlet' % deb_name)

	write_conf_file('/tmp/%s/Makefile' % deb_name, Makefile)
	write_conf_file('/tmp/%s/debian/control' % deb_name, control)
	write_conf_file('/tmp/%s/debian/changelog' % deb_name, changelog)
	write_conf_file('/tmp/%s/debian/compat' % deb_name, compat)
	write_conf_file('/tmp/%s/debian/rules' % deb_name, rules)

	os.system('mkdir -p /tmp/%s/xdg-desktop' % deb_name)
	write_conf_file('/tmp/%s/xdg-desktop/%s.desktop' % (deb_name, deb_name), desktop_file)
	os.system('chmod a+x /tmp/%s/xdg-desktop/*' % deb_name)

	os.system('cp -r %s /tmp/%s/screenlet' % (path, deb_name))

	if os.path.exists("/tmp/%s/screenlet/%s/po" % (deb_name, sl_name)):
		os.system('mv /tmp/%s/screenlet/%s/po /tmp/%s' % (deb_name, sl_name, deb_name))
		os.system('rm /tmp/%s/po/*.pot' % (deb_name))

except:
	die(_('Failed to create file (no permissions?).'))

msg(_('Created all the files needed.'))

msg(_('Debianizing: %s (%s)') % (deb_name, deb_version) )

deb_arguments = " ".join(map(str, arguments))

if len(deb_arguments) > 0:
	print "Passing additional arguments: '%s'" % deb_arguments

# modify this if you want to build differently or do something more interesting
details = os.popen("cd /tmp/%s/debian && debuild %s " % (deb_name, deb_arguments)).read()

if subprocess.call("ls /tmp/%s_%s*.changes 1>/dev/null" % (deb_name, deb_version), shell=True) != 0:
	msg(details)
	die(_('Failed to debianize "%s".') % deb_name)

# UNCOMMENT ANY ONE OF FOLLOWING, IF NEEDED!
##########################################

# if you do not want it, just deb file is enough
if subprocess.call("cp /tmp/%s*deb ." % deb_name, shell=True) != 0:
	die(_('Failed to copy results "/tmp/%s*deb".') % deb_name)

# if you want all the debian files created by debuild
#os.system('cp /tmp/%s* .' % deb_name)

# if you want a whole deb structure to modify it yourself
#os.system('cp -r /tmp/%s* .' % deb_name)

############################################

# remove the files under tmp
os.system('rm -rf /tmp/%s*' % deb_name)
msg(_('Cleaned up and finished.'))

# OK
print 'OK.'