Merge lp:~popey/ubuntu-filemanager-app/add-click-deps into lp:ubuntu-filemanager-app
- add-click-deps
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alan Pope πΊπ§π± π¦ |
Approved revision: | 469 |
Merged at revision: | 481 |
Proposed branch: | lp:~popey/ubuntu-filemanager-app/add-click-deps |
Merge into: | lp:ubuntu-filemanager-app |
Diff against target: |
538 lines (+518/-0) 3 files modified
CMakeLists.txt (+17/-0) filemanager-libs.json (+50/-0) get-click-deps (+451/-0) |
To merge this branch: | bzr merge lp:~popey/ubuntu-filemanager-app/add-click-deps |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Carlos Jose Mazieri | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+270287@code.launchpad.net |
Commit message
Add basics to cmake file and necessary parts to pull in samba libs.
Description of the change
First pass at adding get-click-deps from Stefano Verzegnassi to pull samba libs in during build process. Not final.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
- 467. By Alan Pope πΊπ§π± π¦
-
New get-click-deps from Stefano and updated deployment process
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:467
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
Ok, built a click based on this merge, which builds successfully, and bundles in all the samba libs.
http://
Tried goto -> smb://nas.local or some other local IP which serves up over SMB and it failed. Here's a log extract:- http://
Pretty sure this worked when I manually put all the samba libs in an already installed file manager build from the past. Am I doing something wrong? (probably)
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
Feel like I'm having the same issue with loviewer dependencies (libraries not found by the application).
May the links to the shared libraries, provided in the click package, be somehow broken? (probably when cp'ing files from temp folder to their destination)
Carlos Jose Mazieri (carlos-mazieri) wrote : | # |
> Ok, built a click based on this merge, which builds successfully, and bundles
> in all the samba libs.
> http://
> rmhf.click
>
> Tried goto -> smb://nas.local or some other local IP which serves up over SMB
> and it failed. Here's a log extract:- http://
>
> Pretty sure this worked when I manually put all the samba libs in an already
> installed file manager build from the past. Am I doing something wrong?
> (probably)
Try "unlock full access" first, it blocks remote browsing.
Next MPs will correct this as we discussed on File Manager meeting.
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
@stefano, I think it must be finding the libs, because the app crashes (won't even start) if the libs aren't there, or are in the wrong directory usually.
@carlos, yes, I tried that, but it still wouldn't connect. Will try on a different device as this one has lots of other things installed which may compromise it.
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
Just tried this click on my "retail" bq e4.5 (so it's still read only - not had any debian packages installed - is as a customer would find it). Not able to browse to my NAS.
Is there a "known good" config that this should connect to?
Carlos Jose Mazieri (carlos-mazieri) wrote : | # |
Looking at the log you posted, it looks like there is an extra space
after "smb":
void DirModel:
bool) DirModel_
be read: "smb ://192.168.1.3/"
The correct url must be "smb://
BTW, I have had some hard time trying to type "smb" urls on the device.
On 9/8/15, Alan Pope ξΏ <email address hidden> wrote:
> Just tried this click on my "retail" bq e4.5 (so it's still read only - not
> had any debian packages installed - is as a customer would find it). Not
> able to browse to my NAS.
>
> http://
>
> Is there a "known good" config that this should connect to?
> --
> https:/
> Your team Ubuntu File Manager Developers is requested to review the proposed
> merge of lp:~popey/ubuntu-filemanager-app/add-click-deps into
> lp:ubuntu-filemanager-app.
>
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
Well spotted. We should disable the keyboard helpers (which try to autocorrect when you type in a location) and that will stop the space getting added, and also stop smb being 'corrected' to sob.
I tried again and this time the file manager crashes.
The crash dump was uploaded, and processed. It's a secured page so I printed it as a PDF, I hope that's readable.
Carlos Jose Mazieri (carlos-mazieri) wrote : | # |
It is hard to say something about the crash, if you have the
'libsmbclient' installed in your phone you can try this click package
which contains 'Network' in Places to start navigating in Samba.
https:/
Have you tested on Desktop?
On 9/8/15, Alan Pope ξΏ <email address hidden> wrote:
> Well spotted. We should disable the keyboard helpers (which try to
> autocorrect when you type in a location) and that will stop the space
> getting added, and also stop smb being 'corrected' to sob.
>
> I tried again and this time the file manager crashes.
>
> http://
>
> The crash dump was uploaded, and processed. It's a secured page so I printed
> it as a PDF, I hope that's readable.
>
> http://
> --
> https:/
> Your team Ubuntu File Manager Developers is requested to review the proposed
> merge of lp:~popey/ubuntu-filemanager-app/add-click-deps into
> lp:ubuntu-filemanager-app.
>
Carlos Jose Mazieri (carlos-mazieri) wrote : | # |
> It is hard to say something about the crash, if you have the
> 'libsmbclient' installed in your phone you can try this click package
> which contains 'Network' in Places to start navigating in Samba.
> https:/
> mhf.click?dl=0
>
> Have you tested on Desktop?
>
> On 9/8/15, Alan Pope ξΏ <email address hidden> wrote:
> > Well spotted. We should disable the keyboard helpers (which try to
> > autocorrect when you type in a location) and that will stop the space
> > getting added, and also stop smb being 'corrected' to sob.
> >
> > I tried again and this time the file manager crashes.
> >
> > http://
> >
> > The crash dump was uploaded, and processed. It's a secured page so I printed
> > it as a PDF, I hope that's readable.
> >
> > http://
> > --
> > https:/
> deps/+merge/270287
> > Your team Ubuntu File Manager Developers is requested to review the proposed
> > merge of lp:~popey/ubuntu-filemanager-app/add-click-deps into
> > lp:ubuntu-filemanager-app.
> >
@popey, I do confirm the crash on Samba browsing, it happens on the phone, works on Desktop and works on the phone using the plugin/model as console application.
I am sorry for that, I did not test it properly, I worked on this on weekend and cannot solve it, I need the debug to work in order to find out the problem, I am able to use the debug from qtCreator on device, but it does not work properly, it behaves as a non debug invocation, when the crash happens there is not information about it.
Also tried using "gdb" directly on the device without success, in this case I could generate a core file with no enough information either.
Also added some qDebug() lines but it did not give me the reason for the crash.
If you have any idea about the crash or about other way of debugging please share with me.
Carlos Jose Mazieri (carlos-mazieri) wrote : | # |
Hello,
I did a first test without removing my Samba libraries.
On desktop it downloaded the libraries but on armhf it did not.
See some output:
-- Setting BZR_SOURCE to lp:ubuntu-filemanager-app
Grabbing upstream libs to /home/carlos/
Installing upstream libs from /home/carlos/
Following files to install:-
-- Found PkgConfig: arm-linux-
-- samba include=
-- samba lib=/usr/
-- Found samba: include=
Questions:
1. Did I do something wrong?
2. Cmake still found my installed samba libraries, should not it be changed to find downloaded stuff including libsmbclient.h which I think is missed from download script?
3. I am wondering how is the mechanism used to load local libraries in the click package, can anyone tell how it works?
Alan Pope πΊπ§π± π¦ (popey) wrote : | # |
Ok, I just checked building this branch on a nexus 7. Here's what I did to prove it builds:-
# grab this branch
bzr branch lp:~popey/ubuntu-filemanager-app/add-click-deps
# install build dependencies and cmake and phablet tools (to get click-buddy)
sudo apt-get install cmake debhelper intltool qtbase5-dev qtdeclarative5-dev qt5-default pkg-kde-tools python3-all libtag1-dev libpam0g-dev libsmbclient-dev cmake phablet-tools
# Build it:-
click-buddy --dir add-click-deps/
This grabbed the binary-built stuff which gets used at runtime, it then compiles and built filemanager.
I guess maybe when you un-installed samba libs you removed the headers needed for building?
Carlos Jose Mazieri (carlos-mazieri) wrote : | # |
Hello Alan,
My attempt was done using the SDK armhf 15-04.
I see that you did install 'libsmbclient-dev' (it installs all the samba libraries) which I thought it was going to be downloaded by the proposed solution.
I thought that solution would bring all the necessary resources to compile and deploy on device. Any new developer will try to create the click package using SDK.
Am I wrong?
Can you try it again after removing all the samba libraries?
If so, I would suggest a sequence of commands:
sudo apt-get remove libsmbclient-dev
sudo apt-get autoremove # I hope this will uninstall all other samba libraries
click-buddy --dir add-click-deps/
If you want, can you also try it using armhf SDK?
Thanks,
Carlos
- 468. By Alan Pope πΊπ§π± π¦
-
Merge trunk
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:468
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 469. By Alan Pope πΊπ§π± π¦
-
update get-click-deps to python3
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:469
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Carlos Jose Mazieri (carlos-mazieri) wrote : | # |
Thanks,
I am looking forward to getting the entire Samba stuff in the next release.
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-09-30 23:39:47 +0000 | |||
3 | +++ CMakeLists.txt 2015-10-14 11:21:34 +0000 | |||
4 | @@ -65,6 +65,23 @@ | |||
5 | 65 | add_custom_target(com_ubuntu_calendar_CLICKFiles ALL SOURCES ${CLICK_FILES}) | 65 | add_custom_target(com_ubuntu_calendar_CLICKFiles ALL SOURCES ${CLICK_FILES}) |
6 | 66 | 66 | ||
7 | 67 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json filemanager.apparmor ${CONTENT_HUB_EXPORTER} DESTINATION ${CMAKE_INSTALL_PREFIX}) | 67 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json filemanager.apparmor ${CONTENT_HUB_EXPORTER} DESTINATION ${CMAKE_INSTALL_PREFIX}) |
8 | 68 | |||
9 | 69 | MESSAGE("Grabbing upstream libs to ${CMAKE_CURRENT_BINARY_DIR}/upstream-libs") | ||
10 | 70 | execute_process( | ||
11 | 71 | COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/upstream-libs | ||
12 | 72 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get-click-deps -d ${CMAKE_CURRENT_SOURCE_DIR}/filemanager-libs.json ${CLICK_ARCH} ${CMAKE_CURRENT_BINARY_DIR}/upstream-libs | ||
13 | 73 | ) | ||
14 | 74 | MESSAGE("Installing upstream libs from ${CMAKE_CURRENT_BINARY_DIR}/upstream-libs/usr/lib/${ARCH_TRIPLET}/ to ${DATA_DIR}lib/${ARCH_TRIPLET}") | ||
15 | 75 | file(GLOB_RECURSE UPSTREAM_LIBS "${CMAKE_CURRENT_BINARY_DIR}/upstream-libs/usr/lib/${ARCH_TRIPLET}/*") | ||
16 | 76 | foreach(ITEM ${UPSTREAM_LIBS}) | ||
17 | 77 | IF( IS_DIRECTORY "${ITEM}" ) | ||
18 | 78 | LIST( APPEND DIRS_TO_DEPLOY "${ITEM}" ) | ||
19 | 79 | ELSE() | ||
20 | 80 | LIST( APPEND FILES_TO_DEPLOY "${ITEM}" ) | ||
21 | 81 | ENDIF() | ||
22 | 82 | endforeach() | ||
23 | 83 | MESSAGE("Following files to install:- ${FILES_TO_DEPLOY}") | ||
24 | 84 | INSTALL( FILES ${FILES_TO_DEPLOY} DESTINATION ${DATA_DIR}lib/${ARCH_TRIPLET} ) | ||
25 | 68 | else(CLICK_MODE) | 85 | else(CLICK_MODE) |
26 | 69 | execute_process( | 86 | execute_process( |
27 | 70 | COMMAND qmake -query QT_INSTALL_QML | 87 | COMMAND qmake -query QT_INSTALL_QML |
28 | 71 | 88 | ||
29 | === added file 'filemanager-libs.json' | |||
30 | --- filemanager-libs.json 1970-01-01 00:00:00 +0000 | |||
31 | +++ filemanager-libs.json 2015-10-14 11:21:34 +0000 | |||
32 | @@ -0,0 +1,50 @@ | |||
33 | 1 | { | ||
34 | 2 | "armhf": [ | ||
35 | 3 | { | ||
36 | 4 | "url": "http://ports.ubuntu.com/ubuntu-ports", | ||
37 | 5 | "dist": "vivid", | ||
38 | 6 | "component": "main", | ||
39 | 7 | "packages": [ | ||
40 | 8 | "libsmbclient", | ||
41 | 9 | "samba-libs", | ||
42 | 10 | "libtalloc2", | ||
43 | 11 | "libtevent0", | ||
44 | 12 | "libwbclient0", | ||
45 | 13 | "libldb1", | ||
46 | 14 | "libntdb1" | ||
47 | 15 | ] | ||
48 | 16 | } | ||
49 | 17 | ], | ||
50 | 18 | "amd64": [ | ||
51 | 19 | { | ||
52 | 20 | "url": "http://archive.ubuntu.com/ubuntu", | ||
53 | 21 | "dist": "vivid", | ||
54 | 22 | "component": "main", | ||
55 | 23 | "packages": [ | ||
56 | 24 | "libsmbclient", | ||
57 | 25 | "samba-libs", | ||
58 | 26 | "libtalloc2", | ||
59 | 27 | "libtevent0", | ||
60 | 28 | "libwbclient0", | ||
61 | 29 | "libldb1", | ||
62 | 30 | "libntdb1" | ||
63 | 31 | ] | ||
64 | 32 | } | ||
65 | 33 | ], | ||
66 | 34 | "i386": [ | ||
67 | 35 | { | ||
68 | 36 | "url": "http://archive.ubuntu.com/ubuntu", | ||
69 | 37 | "dist": "vivid", | ||
70 | 38 | "component": "main", | ||
71 | 39 | "packages": [ | ||
72 | 40 | "libsmbclient", | ||
73 | 41 | "samba-libs", | ||
74 | 42 | "libtalloc2", | ||
75 | 43 | "libtevent0", | ||
76 | 44 | "libwbclient0", | ||
77 | 45 | "libldb1", | ||
78 | 46 | "libntdb1" | ||
79 | 47 | ] | ||
80 | 48 | } | ||
81 | 49 | ] | ||
82 | 50 | } | ||
83 | 0 | 51 | ||
84 | === added file 'get-click-deps' | |||
85 | --- get-click-deps 1970-01-01 00:00:00 +0000 | |||
86 | +++ get-click-deps 2015-10-14 11:21:34 +0000 | |||
87 | @@ -0,0 +1,451 @@ | |||
88 | 1 | #!/usr/bin/python3 | ||
89 | 2 | |||
90 | 3 | # Copyright (C) 2015 Stefano Verzegnassi <verzegnassi.stefano@gmail.com> | ||
91 | 4 | # Copyright (C) 2015 Didier Roche <didrocks@ubuntu.com> | ||
92 | 5 | # | ||
93 | 6 | # This program is free software: you can redistribute it and/or modify it | ||
94 | 7 | # under the terms of the GNU General Public License version 3, as published | ||
95 | 8 | # by the Free Software Foundation. | ||
96 | 9 | # | ||
97 | 10 | # This program is distributed in the hope that it will be useful, but | ||
98 | 11 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
99 | 12 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
100 | 13 | # PURPOSE. See the GNU General Public License for more details. | ||
101 | 14 | # | ||
102 | 15 | # You should have received a copy of the GNU General Public License along | ||
103 | 16 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
104 | 17 | |||
105 | 18 | # | ||
106 | 19 | # Source code at: | ||
107 | 20 | # https://code.launchpad.net/~verzegnassi-stefano/+junk/get-click-deps | ||
108 | 21 | # | ||
109 | 22 | # A script to automate the fetching all the external dependencies of a | ||
110 | 23 | # Click packaged application from internet, and copying them in a given | ||
111 | 24 | # folder, so that the click packaging tool can easily build them in the | ||
112 | 25 | # package. | ||
113 | 26 | # | ||
114 | 27 | # usage: get-click-deps [-h] [-f] [-d] [-e] [-c SCRIPT_PATH] | ||
115 | 28 | # manifest_path {amd64,i386,armhf} target_path | ||
116 | 29 | # | ||
117 | 30 | # A tool for adding external libraries to a Ubuntu SDK application or scope. | ||
118 | 31 | # | ||
119 | 32 | # positional arguments: | ||
120 | 33 | # manifest_path path of json file containing the list of packages to | ||
121 | 34 | # be downloaded. | ||
122 | 35 | # {amd64,i386,armhf} CPU architecture ("amd64", "i386" or "armhf") | ||
123 | 36 | # target_path path to the target (a click package or a folder) | ||
124 | 37 | # where this tool will include the downloaded binaries. | ||
125 | 38 | # If the folder does not exist, it will be created. | ||
126 | 39 | # | ||
127 | 40 | # optional arguments: | ||
128 | 41 | # -h, --help show this help message and exit | ||
129 | 42 | # -f, --force-download force a new download of the packages | ||
130 | 43 | # -d, --delete-temp delete temp files at the end of the process | ||
131 | 44 | # -e, --extract-only only create temp directory and extract the content of | ||
132 | 45 | # downloaded packages | ||
133 | 46 | # -c SCRIPT_PATH, --custom-script SCRIPT_PATH | ||
134 | 47 | # run a custom script after the extraction of Debian | ||
135 | 48 | # packages and before copying their content to the | ||
136 | 49 | # target destination. The tool will execute the script | ||
137 | 50 | # with the path to the packages dump as argument. If | ||
138 | 51 | # the '-e' flag has been specified, the script will be | ||
139 | 52 | # anyway executed. This option is useful when you need | ||
140 | 53 | # to automatically modify the content of temp folder | ||
141 | 54 | # (e.g. when you need to fix some path before including | ||
142 | 55 | # the files in a click package). | ||
143 | 56 | # | ||
144 | 57 | # | ||
145 | 58 | # USAGE EXAMPLE: | ||
146 | 59 | # get-click-deps packages.json armhf <path/to/package.click> | ||
147 | 60 | # | ||
148 | 61 | # package.json is the package manifest, and contains all the references to the | ||
149 | 62 | # .deb packages to be included into the Ubuntu SDK project. | ||
150 | 63 | # If you're familiar to the Debian/Ubuntu world, you'll see that it's pretty | ||
151 | 64 | # similar to therepository management of these distros: | ||
152 | 65 | # see https://wiki.debian.org/SourcesList for further informations. | ||
153 | 66 | # | ||
154 | 67 | # An example of packages.json file is: | ||
155 | 68 | # { | ||
156 | 69 | # "armhf": [ | ||
157 | 70 | # { | ||
158 | 71 | # "url": "http://ports.ubuntu.com/ubuntu-ports/", | ||
159 | 72 | # "dist": "vivid", | ||
160 | 73 | # "component": "main", | ||
161 | 74 | # "packages": [ | ||
162 | 75 | # "libgl1-mesa-glx", | ||
163 | 76 | # "libxslt1.1", | ||
164 | 77 | # "libxcb-glx0", | ||
165 | 78 | # "libxcb-dri3-0", | ||
166 | 79 | # "libxcb-present0", | ||
167 | 80 | # "libxshmfence1", | ||
168 | 81 | # "libxxf86vm1" | ||
169 | 82 | # ] | ||
170 | 83 | # }, | ||
171 | 84 | # | ||
172 | 85 | # { | ||
173 | 86 | # "url": "http://ppa.launchpad.net/canonical-community/ppa/ubuntu", | ||
174 | 87 | # "dist": "vivid", | ||
175 | 88 | # "component": "main", | ||
176 | 89 | # "packages": [ | ||
177 | 90 | # "libreoffice-vanilla" | ||
178 | 91 | # ] | ||
179 | 92 | # } | ||
180 | 93 | # ], | ||
181 | 94 | # | ||
182 | 95 | # "amd64": [ | ||
183 | 96 | # "url": "http://ppa.launchpad.net/canonical-community/ppa/ubuntu", | ||
184 | 97 | # "dist": "vivid", | ||
185 | 98 | # "component": "main", | ||
186 | 99 | # "packages": [ | ||
187 | 100 | # "libreoffice-vanilla" | ||
188 | 101 | # ] | ||
189 | 102 | # } | ||
190 | 103 | # ] | ||
191 | 104 | # } | ||
192 | 105 | # | ||
193 | 106 | # Instead of a click package, you can specify the build folder used by Ubuntu | ||
194 | 107 | # SDK for compiling the sources of your project. This way the binaries | ||
195 | 108 | # downloaded by this tool will be automatically included in the .click package | ||
196 | 109 | # the next time you ask Ubuntu SDK to create a new package. | ||
197 | 110 | # | ||
198 | 111 | |||
199 | 112 | # TODO: Complete error handling | ||
200 | 113 | # TODO: Make target_path optional if the '-e' flag has been specified. | ||
201 | 114 | |||
202 | 115 | import sys | ||
203 | 116 | import os | ||
204 | 117 | import stat | ||
205 | 118 | import time | ||
206 | 119 | import argparse | ||
207 | 120 | import json | ||
208 | 121 | import gzip | ||
209 | 122 | import subprocess | ||
210 | 123 | import urllib.request, urllib.error, urllib.parse | ||
211 | 124 | |||
212 | 125 | def get_timestamp(): | ||
213 | 126 | return time.time() | ||
214 | 127 | |||
215 | 128 | |||
216 | 129 | def check_internet_connection(): | ||
217 | 130 | try: | ||
218 | 131 | urllib.request.urlopen('http://www.google.com', timeout=20) | ||
219 | 132 | return True | ||
220 | 133 | except urllib2.error.URLError as err: | ||
221 | 134 | pass | ||
222 | 135 | return False | ||
223 | 136 | |||
224 | 137 | |||
225 | 138 | def get_arch_triplet(arch): | ||
226 | 139 | return subprocess.check_output([ | ||
227 | 140 | 'dpkg-architecture', | ||
228 | 141 | '-A', | ||
229 | 142 | arch, | ||
230 | 143 | '-qDEB_TARGET_MULTIARCH']) | ||
231 | 144 | |||
232 | 145 | |||
233 | 146 | def download_file(url, dest, verbose=True): | ||
234 | 147 | if verbose: | ||
235 | 148 | print ("\nDownloading:\n{}".format(url)) | ||
236 | 149 | # TODO: Switch to subprocess | ||
237 | 150 | os.system('cd %s && { curl -# -O %s ; cd - ; }' % (dest, url)) | ||
238 | 151 | |||
239 | 152 | |||
240 | 153 | def download_file_and_rename(url, dest, new_filename, verbose=True): | ||
241 | 154 | if verbose: | ||
242 | 155 | print ("\nDownloading:\n{}".format(url)) | ||
243 | 156 | new_path = os.path.join(dest, new_filename) | ||
244 | 157 | subprocess.call(['curl', url, '-#', '-o', new_path]) | ||
245 | 158 | |||
246 | 159 | return new_path | ||
247 | 160 | |||
248 | 161 | |||
249 | 162 | def get_package_download_url(package_name, packages_list, base_url): | ||
250 | 163 | pkgs_list = packages_list.decode('utf-8').split('\n') | ||
251 | 164 | index = pkgs_list.index('Package: %s' % package_name) | ||
252 | 165 | |||
253 | 166 | for i in range(index, len(pkgs_list)): | ||
254 | 167 | if pkgs_list[i].find('Filename:') > -1: | ||
255 | 168 | return "%s/%s" % (base_url, pkgs_list[i].replace('Filename: ', '')) | ||
256 | 169 | |||
257 | 170 | |||
258 | 171 | def get_URLs_for_arch(manifest_path, arch, destpath): | ||
259 | 172 | urls = [] | ||
260 | 173 | |||
261 | 174 | f = open(manifest_path) | ||
262 | 175 | content = json.load(f) | ||
263 | 176 | f.close() | ||
264 | 177 | |||
265 | 178 | # Download repository index for each repository in the JSON package | ||
266 | 179 | # manifest. | ||
267 | 180 | try: | ||
268 | 181 | repo_index = 0 | ||
269 | 182 | for repo in content[arch]: | ||
270 | 183 | repo_index_url = '%s/dists/%s/%s/binary-%s/Packages.gz' % ( | ||
271 | 184 | repo['url'], | ||
272 | 185 | repo['dist'], | ||
273 | 186 | repo['component'], | ||
274 | 187 | arch) | ||
275 | 188 | |||
276 | 189 | print ("\nDownloading repository index at:\n".format(repo_index_url)) | ||
277 | 190 | |||
278 | 191 | repo_index_zip = download_file_and_rename( | ||
279 | 192 | repo_index_url, | ||
280 | 193 | destpath, | ||
281 | 194 | 'repo-index-%s-%s.gz' % (arch, repo_index), | ||
282 | 195 | False) | ||
283 | 196 | |||
284 | 197 | with gzip.open(repo_index_zip, 'r') as f: | ||
285 | 198 | repo_index_content = f.read() | ||
286 | 199 | f.close() | ||
287 | 200 | |||
288 | 201 | # Get the download URL of each package of the repository. | ||
289 | 202 | packages = repo['packages'] | ||
290 | 203 | for package in packages: | ||
291 | 204 | urls.append(get_package_download_url( | ||
292 | 205 | package, | ||
293 | 206 | repo_index_content, | ||
294 | 207 | repo['url'])) | ||
295 | 208 | |||
296 | 209 | repo_index += 1 | ||
297 | 210 | except KeyError: | ||
298 | 211 | # Arch not found in the manifest. Exit with no error, since there's no | ||
299 | 212 | # need to run the script for this arch. | ||
300 | 213 | print ("\n\nRequested arch has been not specified in the manifest. \ | ||
301 | 214 | Exiting...") | ||
302 | 215 | sys.exit(0) | ||
303 | 216 | print ("\nObtained packages informations") | ||
304 | 217 | return urls | ||
305 | 218 | |||
306 | 219 | |||
307 | 220 | def check_if_temp_folder_already_exists(path): | ||
308 | 221 | return os.path.isdir(path) | ||
309 | 222 | |||
310 | 223 | |||
311 | 224 | def copy_directory_content(sourcepath, destpath): | ||
312 | 225 | subprocess.call(['cp', '-r', '%s/.' % sourcepath, destpath]) | ||
313 | 226 | |||
314 | 227 | |||
315 | 228 | def delete_folder(path, recursive=False): | ||
316 | 229 | if recursive: | ||
317 | 230 | flag = '-rf' | ||
318 | 231 | else: | ||
319 | 232 | flag = '-f' | ||
320 | 233 | subprocess.call(['rm', flag, path]) | ||
321 | 234 | |||
322 | 235 | |||
323 | 236 | def extract_deb_package(deb_path, destpath): | ||
324 | 237 | subprocess.call(['dpkg-deb', '-x', deb_path, destpath]) | ||
325 | 238 | |||
326 | 239 | |||
327 | 240 | def extract_click_package(click_path, destpath): | ||
328 | 241 | extract_deb_package(click_path, destpath) | ||
329 | 242 | |||
330 | 243 | manifest = subprocess.check_output(['click', 'info', click_path]) | ||
331 | 244 | |||
332 | 245 | # The manifest we get has an 'installed-size' key with the value of the | ||
333 | 246 | # previous package. Anyway this value will be replaced when we'll run | ||
334 | 247 | # 'click build <pkg>', so there's no reason for removing it here. | ||
335 | 248 | f = open(os.path.join(destpath, 'manifest.json'), 'w') | ||
336 | 249 | f.write(manifest) | ||
337 | 250 | f.close() | ||
338 | 251 | |||
339 | 252 | return destpath | ||
340 | 253 | |||
341 | 254 | |||
342 | 255 | def build_click_package(source_dirpath): | ||
343 | 256 | output = subprocess.check_output(['click', 'build', source_dirpath]) | ||
344 | 257 | |||
345 | 258 | for line in output.split(os.linesep): | ||
346 | 259 | if line.find('Successfully built package in ') > -1: | ||
347 | 260 | # FIXME: Very ugly. | ||
348 | 261 | path = line.replace('Successfully built package in \'', '') | ||
349 | 262 | path = path.replace('\'.', '') | ||
350 | 263 | return path | ||
351 | 264 | |||
352 | 265 | |||
353 | 266 | def copy_file(sourcepath, destpath, overwrite=False): | ||
354 | 267 | flag = '' | ||
355 | 268 | |||
356 | 269 | if not overwrite: | ||
357 | 270 | flag = '-n' | ||
358 | 271 | |||
359 | 272 | subprocess.call(['cp', flag, sourcepath, destpath]) | ||
360 | 273 | |||
361 | 274 | |||
362 | 275 | # Argument parser | ||
363 | 276 | parser = argparse.ArgumentParser( | ||
364 | 277 | description="A tool for adding external libraries to a Ubuntu SDK \ | ||
365 | 278 | application or scope.") | ||
366 | 279 | |||
367 | 280 | parser.add_argument( | ||
368 | 281 | '-f', | ||
369 | 282 | '--force-download', | ||
370 | 283 | dest='force_download', | ||
371 | 284 | action='store_true', | ||
372 | 285 | help='force a new download of the packages') | ||
373 | 286 | |||
374 | 287 | parser.add_argument( | ||
375 | 288 | '-d', | ||
376 | 289 | '--delete-temp', | ||
377 | 290 | dest='delete_temp', | ||
378 | 291 | action='store_true', | ||
379 | 292 | help='delete temp files at the end of the process') | ||
380 | 293 | |||
381 | 294 | parser.add_argument( | ||
382 | 295 | '-e', | ||
383 | 296 | '--extract-only', | ||
384 | 297 | dest='extract_only', | ||
385 | 298 | action='store_true', | ||
386 | 299 | help='only create temp directory and extract the content of downloaded \ | ||
387 | 300 | packages') | ||
388 | 301 | |||
389 | 302 | parser.add_argument( | ||
390 | 303 | '-c', | ||
391 | 304 | '--custom-script', | ||
392 | 305 | dest='script_path', | ||
393 | 306 | type=str, | ||
394 | 307 | help='run a custom script after the extraction of Debian packages and \ | ||
395 | 308 | before copying their content to the target destination. The tool will \ | ||
396 | 309 | execute the script with the path to the packages dump as argument. If \ | ||
397 | 310 | the \'-e\' flag has been specified, the script will be anyway \ | ||
398 | 311 | executed. This option is useful when you need to automatically modify \ | ||
399 | 312 | the content of temp folder (e.g. when you need to fix some path \ | ||
400 | 313 | before including the files in a click package).') | ||
401 | 314 | |||
402 | 315 | parser.add_argument( | ||
403 | 316 | 'manifest_path', | ||
404 | 317 | type=str, | ||
405 | 318 | help='path of json file containing the list of packages to be downloaded.') | ||
406 | 319 | |||
407 | 320 | parser.add_argument( | ||
408 | 321 | 'arch', | ||
409 | 322 | type=str, | ||
410 | 323 | choices=['amd64', 'i386', 'armhf'], | ||
411 | 324 | help='CPU architecture ("amd64", "i386" or "armhf")') | ||
412 | 325 | |||
413 | 326 | parser.add_argument( | ||
414 | 327 | 'target_path', | ||
415 | 328 | type=str, | ||
416 | 329 | help='path to the target (a click package or a folder) where this \ | ||
417 | 330 | tool will include the downloaded binaries. If the folder does not \ | ||
418 | 331 | exist, it will be created.') | ||
419 | 332 | |||
420 | 333 | args = parser.parse_args() | ||
421 | 334 | |||
422 | 335 | # Variables | ||
423 | 336 | manifest_path = args.manifest_path | ||
424 | 337 | target_path = args.target_path | ||
425 | 338 | manifest_stat = os.stat(manifest_path) | ||
426 | 339 | temp_folder = os.path.join( | ||
427 | 340 | '/tmp/', | ||
428 | 341 | 'tmp-click-deps-%s-%s-%s-%s' % ( | ||
429 | 342 | manifest_stat.st_dev, | ||
430 | 343 | manifest_stat.st_ino, | ||
431 | 344 | manifest_stat.st_size, | ||
432 | 345 | manifest_stat.st_mtime)) | ||
433 | 346 | temp_arch_folder = os.path.join(temp_folder, args.arch) | ||
434 | 347 | is_click_target = os.path.isfile(args.target_path) | ||
435 | 348 | |||
436 | 349 | # Check command line arguments | ||
437 | 350 | if not os.path.isfile(manifest_path): | ||
438 | 351 | sys.exit("\n\nERROR: Package manifest is not a valid file. Exit...") | ||
439 | 352 | |||
440 | 353 | if not os.path.isfile(target_path) and target_path.endswith('.click'): | ||
441 | 354 | sys.exit("\n\nERROR: The specified target .click does not exists.") | ||
442 | 355 | elif not os.path.isdir(target_path): | ||
443 | 356 | print ("\n\nCreating dest folder\n{}".format(target_path)) | ||
444 | 357 | os.mkdir(target_path) | ||
445 | 358 | |||
446 | 359 | # Check if the script exist, if specified any. | ||
447 | 360 | if args.script_path and not os.path.exists(args.script_path): | ||
448 | 361 | sys.exit("\n\nERROR: The specified script does not exists.") | ||
449 | 362 | |||
450 | 363 | # If -f argument has been specified, remove all the existing data before | ||
451 | 364 | # running this script. | ||
452 | 365 | if args.force_download: | ||
453 | 366 | if os.path.isdir(temp_folder): | ||
454 | 367 | print ("\nRemoving temp data of the previous run, as requested") | ||
455 | 368 | delete_folder(temp_folder, True) | ||
456 | 369 | |||
457 | 370 | # Check if we already have run this script for the same target. | ||
458 | 371 | if not check_if_temp_folder_already_exists(temp_arch_folder): | ||
459 | 372 | # Check internet connection | ||
460 | 373 | if not check_internet_connection(): | ||
461 | 374 | sys.exit("\n\nERROR: An internet connection is required in order to \ | ||
462 | 375 | download packages from repositories.") | ||
463 | 376 | |||
464 | 377 | # Create temp folder in /tmp | ||
465 | 378 | print ("\nCreating temp folder in {}".format(temp_folder)) | ||
466 | 379 | os.mkdir(temp_folder) | ||
467 | 380 | os.mkdir(temp_arch_folder) | ||
468 | 381 | |||
469 | 382 | # Parse the JSON package list and get the download URL of the packages. | ||
470 | 383 | debs_url_list = get_URLs_for_arch( | ||
471 | 384 | manifest_path, | ||
472 | 385 | args.arch, | ||
473 | 386 | temp_folder) | ||
474 | 387 | |||
475 | 388 | # Download packages from web | ||
476 | 389 | for url in debs_url_list: | ||
477 | 390 | download_file(url, temp_folder) | ||
478 | 391 | |||
479 | 392 | # Extract DEBs packages | ||
480 | 393 | print ("\nExtracting .deb packages to {}".format(temp_arch_folder)) | ||
481 | 394 | deb_pkgs_list = [] | ||
482 | 395 | for file in os.listdir(temp_folder): | ||
483 | 396 | if file.endswith('.deb'): | ||
484 | 397 | deb_pkgs_list.append(file) | ||
485 | 398 | |||
486 | 399 | for deb_pkg in deb_pkgs_list: | ||
487 | 400 | extract_deb_package( | ||
488 | 401 | os.path.join(temp_folder, deb_pkg), | ||
489 | 402 | temp_arch_folder) | ||
490 | 403 | |||
491 | 404 | # If a script has been specified, run it. | ||
492 | 405 | if args.script_path: | ||
493 | 406 | print ("\nRunning the script at: {}\n".format(args.script_path)) | ||
494 | 407 | |||
495 | 408 | # Ensure that we can run the script, otherwise we don't have the | ||
496 | 409 | # permission | ||
497 | 410 | subprocess.call(['chmod', '+x', args.script_path]) | ||
498 | 411 | subprocess.call([ | ||
499 | 412 | args.script_path, | ||
500 | 413 | temp_arch_folder, | ||
501 | 414 | get_arch_triplet(args.arch)]) | ||
502 | 415 | else: | ||
503 | 416 | print ("\nPackages are already downloaded. Use them...") | ||
504 | 417 | |||
505 | 418 | # If -e or --extract-only flags have been specified, we have completed our work | ||
506 | 419 | if args.extract_only: | ||
507 | 420 | print ("\n\nCompleted successfully.") | ||
508 | 421 | sys.exit(0) | ||
509 | 422 | |||
510 | 423 | # Copy temp_arch folder content to its destination | ||
511 | 424 | if is_click_target: | ||
512 | 425 | print ("\nExtracting target .click package") | ||
513 | 426 | temp_click_folder = extract_click_package( | ||
514 | 427 | args.target_path, | ||
515 | 428 | os.path.join('/tmp/', str(get_timestamp()))) | ||
516 | 429 | |||
517 | 430 | print ("\nAdding extracted binaries to the package") | ||
518 | 431 | copy_directory_content(temp_arch_folder, temp_click_folder) | ||
519 | 432 | |||
520 | 433 | new_click_package_path = build_click_package(temp_click_folder) | ||
521 | 434 | print ("\nCreated new .click package at:\n{}".format(new_click_package_path)) | ||
522 | 435 | |||
523 | 436 | print ("\nReplacing older .click package") | ||
524 | 437 | copy_file(new_click_package_path, args.target_path, True) | ||
525 | 438 | |||
526 | 439 | delete_folder(temp_click_folder, True) | ||
527 | 440 | |||
528 | 441 | else: | ||
529 | 442 | print ("\nCopying extracted binaries to their destination") | ||
530 | 443 | copy_directory_content(temp_arch_folder, args.target_path) | ||
531 | 444 | |||
532 | 445 | # Delete temp files | ||
533 | 446 | if args.delete_temp: | ||
534 | 447 | print ("\)nRemoving temp files and directory, as requested") | ||
535 | 448 | delete_folder(temp_folder, True) | ||
536 | 449 | |||
537 | 450 | # Exit | ||
538 | 451 | print ("\n\nCompleted successfully.") |
PASSED: Continuous integration, rev:466 91.189. 93.70:8080/ job/ubuntu- filemanager- app-ci/ 539/ 91.189. 93.70:8080/ job/ubuntu- filemanager- app-vivid- amd64-ci/ 161
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- filemanager- app-ci/ 539/rebuild
http://