Codebase list sugar-toolkit-gtk3 / a7b531c
add patch cherry-picked upstream to implement option --destdir; thanks to Vagrant Cascadian and James Cameron (see bug#975373, #975374) Jonas Smedegaard 3 years ago
2 changed file(s) with 122 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Description: bundlebuilder: install: add destdir support
1 Add support for DESTDIR using a --destdir option,
2 https://www.gnu.org/prep/standards/html_node/DESTDIR.html
3 Author: James Cameron <quozl@laptop.org>
4 Origin: Upstream, https://github.com/sugarlabs/sugar-toolkit-gtk3/commit/db642e1
5 Bug: https://github.com/sugarlabs/sugar-toolkit-gtk3/issues/453
6 Last-Update: 2021-01-28
7 ---
8 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
9 --- a/src/sugar3/activity/bundlebuilder.py
10 +++ b/src/sugar3/activity/bundlebuilder.py
11 @@ -280,7 +280,8 @@
12 Packager.__init__(self, builder.config)
13 self.builder = builder
14
15 - def install(self, prefix, install_mime=True, install_desktop_file=True):
16 + def install(self, destdir, prefix,
17 + install_mime=True, install_desktop_file=True):
18 self.builder.build()
19
20 activity_path = os.path.join(prefix, 'share', 'sugar', 'activities',
21 @@ -290,16 +291,21 @@
22
23 for f in self.get_files_in_git():
24 source_path = os.path.join(self.config.source_dir, f)
25 - dest_path = os.path.join(activity_path, f)
26 + dest_path = os.path.join(destdir,
27 + os.path.relpath(activity_path, '/'), f)
28 source_to_dest[source_path] = dest_path
29
30 for f in self.builder.get_locale_files():
31 source_path = os.path.join(self.builder.locale_dir, f)
32
33 if source_path.endswith(".mo"):
34 - dest_path = os.path.join(prefix, 'share', 'locale', f)
35 + dest_path = os.path.join(destdir,
36 + os.path.relpath(prefix, '/'),
37 + 'share', 'locale', f)
38 else:
39 - dest_path = os.path.join(activity_path, 'locale', f)
40 + dest_path = os.path.join(destdir,
41 + os.path.relpath(activity_path, '/'),
42 + 'locale', f)
43
44 source_to_dest[source_path] = dest_path
45
46 @@ -316,10 +322,10 @@
47 self.config.bundle.install_mime_type(self.config.source_dir)
48
49 if install_desktop_file:
50 - self._install_desktop_file(prefix, activity_path)
51 - self._generate_appdata(prefix, activity_path)
52 + self._install_desktop_file(destdir, prefix, activity_path)
53 + self._generate_appdata(destdir, prefix, activity_path)
54
55 - def _install_desktop_file(self, prefix, activity_path):
56 + def _install_desktop_file(self, destdir, prefix, activity_path):
57 cp = ConfigParser()
58 section = 'Desktop Entry'
59 cp.add_section(section)
60 @@ -327,7 +333,9 @@
61
62 # Get it from the activity.info for the non-translated version
63 info = ConfigParser()
64 - info.read(os.path.join(activity_path, 'activity', 'activity.info'))
65 + info_path = os.path.join(destdir, os.path.relpath(activity_path, '/'),
66 + 'activity', 'activity.info')
67 + info.read(info_path)
68 cp.set(section, 'Name', info.get('Activity', 'name'))
69 if info.has_option('Activity', 'summary'):
70 cp.set(section, 'Comment', info.get('Activity', 'summary'))
71 @@ -353,15 +361,18 @@
72 cp.set(section, 'Path', activity_path) # Path == CWD for running
73
74 name = '{}.activity.desktop'.format(self.config.bundle_id)
75 - path = os.path.join(prefix, 'share', 'applications', name)
76 + path = os.path.join(destdir, os.path.relpath(prefix, '/'),
77 + 'share', 'applications', name)
78 if not os.path.isdir(os.path.dirname(path)):
79 os.makedirs(os.path.dirname(path))
80 with open(path, 'w') as f:
81 cp.write(f)
82
83 - def _generate_appdata(self, prefix, activity_path):
84 + def _generate_appdata(self, destdir, prefix, activity_path):
85 info = ConfigParser()
86 - info.read(os.path.join(activity_path, 'activity', 'activity.info'))
87 + info_path = os.path.join(destdir, os.path.relpath(activity_path, '/'),
88 + 'activity', 'activity.info')
89 + info.read(info_path)
90
91 required_fields = ['metadata_license', 'license', 'name', 'icon',
92 'description']
93 @@ -408,7 +419,8 @@
94 ET.SubElement(root, 'url', type='bugtracker').text = \
95 info.get('Activity', 'repository')
96
97 - path = os.path.join(prefix, 'share', 'metainfo',
98 + path = os.path.join(destdir, os.path.relpath(prefix, '/'),
99 + 'share', 'metainfo',
100 self.config.bundle_id + '.appdata.xml')
101 if not os.path.isdir(os.path.dirname(path)):
102 os.makedirs(os.path.dirname(path))
103 @@ -505,6 +517,7 @@
104
105 installer = Installer(Builder(config))
106 installer.install(
107 + options.destdir,
108 options.prefix,
109 options.install_mime,
110 options.install_desktop_file)
111 @@ -593,6 +606,9 @@
112 "--prefix", dest="prefix", default=sys.prefix,
113 help="Path for installing")
114 install_parser.add_argument(
115 + "--destdir", dest="destdir", default="/",
116 + help="Path for staged install")
117 + install_parser.add_argument(
118 "--skip-install-mime", dest="install_mime",
119 action="store_false", default=True,
120 help="Skip the installation of custom mime types in the system")
0 020201202~db642e1.patch
01 1001_espeak-ng.patch
12 2002_ignore_debian_and_quilt-patches.patch
23 #2003_bundlebuilder_exit_nonzero_on_error.patch