File LICENSE added (mode: 100644) (index 0000000..dba13ed) |
|
1 |
|
GNU AFFERO GENERAL PUBLIC LICENSE |
|
2 |
|
Version 3, 19 November 2007 |
|
3 |
|
|
|
4 |
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
|
5 |
|
Everyone is permitted to copy and distribute verbatim copies |
|
6 |
|
of this license document, but changing it is not allowed. |
|
7 |
|
|
|
8 |
|
Preamble |
|
9 |
|
|
|
10 |
|
The GNU Affero General Public License is a free, copyleft license for |
|
11 |
|
software and other kinds of works, specifically designed to ensure |
|
12 |
|
cooperation with the community in the case of network server software. |
|
13 |
|
|
|
14 |
|
The licenses for most software and other practical works are designed |
|
15 |
|
to take away your freedom to share and change the works. By contrast, |
|
16 |
|
our General Public Licenses are intended to guarantee your freedom to |
|
17 |
|
share and change all versions of a program--to make sure it remains free |
|
18 |
|
software for all its users. |
|
19 |
|
|
|
20 |
|
When we speak of free software, we are referring to freedom, not |
|
21 |
|
price. Our General Public Licenses are designed to make sure that you |
|
22 |
|
have the freedom to distribute copies of free software (and charge for |
|
23 |
|
them if you wish), that you receive source code or can get it if you |
|
24 |
|
want it, that you can change the software or use pieces of it in new |
|
25 |
|
free programs, and that you know you can do these things. |
|
26 |
|
|
|
27 |
|
Developers that use our General Public Licenses protect your rights |
|
28 |
|
with two steps: (1) assert copyright on the software, and (2) offer |
|
29 |
|
you this License which gives you legal permission to copy, distribute |
|
30 |
|
and/or modify the software. |
|
31 |
|
|
|
32 |
|
A secondary benefit of defending all users' freedom is that |
|
33 |
|
improvements made in alternate versions of the program, if they |
|
34 |
|
receive widespread use, become available for other developers to |
|
35 |
|
incorporate. Many developers of free software are heartened and |
|
36 |
|
encouraged by the resulting cooperation. However, in the case of |
|
37 |
|
software used on network servers, this result may fail to come about. |
|
38 |
|
The GNU General Public License permits making a modified version and |
|
39 |
|
letting the public access it on a server without ever releasing its |
|
40 |
|
source code to the public. |
|
41 |
|
|
|
42 |
|
The GNU Affero General Public License is designed specifically to |
|
43 |
|
ensure that, in such cases, the modified source code becomes available |
|
44 |
|
to the community. It requires the operator of a network server to |
|
45 |
|
provide the source code of the modified version running there to the |
|
46 |
|
users of that server. Therefore, public use of a modified version, on |
|
47 |
|
a publicly accessible server, gives the public access to the source |
|
48 |
|
code of the modified version. |
|
49 |
|
|
|
50 |
|
An older license, called the Affero General Public License and |
|
51 |
|
published by Affero, was designed to accomplish similar goals. This is |
|
52 |
|
a different license, not a version of the Affero GPL, but Affero has |
|
53 |
|
released a new version of the Affero GPL which permits relicensing under |
|
54 |
|
this license. |
|
55 |
|
|
|
56 |
|
The precise terms and conditions for copying, distribution and |
|
57 |
|
modification follow. |
|
58 |
|
|
|
59 |
|
TERMS AND CONDITIONS |
|
60 |
|
|
|
61 |
|
0. Definitions. |
|
62 |
|
|
|
63 |
|
"This License" refers to version 3 of the GNU Affero General Public License. |
|
64 |
|
|
|
65 |
|
"Copyright" also means copyright-like laws that apply to other kinds of |
|
66 |
|
works, such as semiconductor masks. |
|
67 |
|
|
|
68 |
|
"The Program" refers to any copyrightable work licensed under this |
|
69 |
|
License. Each licensee is addressed as "you". "Licensees" and |
|
70 |
|
"recipients" may be individuals or organizations. |
|
71 |
|
|
|
72 |
|
To "modify" a work means to copy from or adapt all or part of the work |
|
73 |
|
in a fashion requiring copyright permission, other than the making of an |
|
74 |
|
exact copy. The resulting work is called a "modified version" of the |
|
75 |
|
earlier work or a work "based on" the earlier work. |
|
76 |
|
|
|
77 |
|
A "covered work" means either the unmodified Program or a work based |
|
78 |
|
on the Program. |
|
79 |
|
|
|
80 |
|
To "propagate" a work means to do anything with it that, without |
|
81 |
|
permission, would make you directly or secondarily liable for |
|
82 |
|
infringement under applicable copyright law, except executing it on a |
|
83 |
|
computer or modifying a private copy. Propagation includes copying, |
|
84 |
|
distribution (with or without modification), making available to the |
|
85 |
|
public, and in some countries other activities as well. |
|
86 |
|
|
|
87 |
|
To "convey" a work means any kind of propagation that enables other |
|
88 |
|
parties to make or receive copies. Mere interaction with a user through |
|
89 |
|
a computer network, with no transfer of a copy, is not conveying. |
|
90 |
|
|
|
91 |
|
An interactive user interface displays "Appropriate Legal Notices" |
|
92 |
|
to the extent that it includes a convenient and prominently visible |
|
93 |
|
feature that (1) displays an appropriate copyright notice, and (2) |
|
94 |
|
tells the user that there is no warranty for the work (except to the |
|
95 |
|
extent that warranties are provided), that licensees may convey the |
|
96 |
|
work under this License, and how to view a copy of this License. If |
|
97 |
|
the interface presents a list of user commands or options, such as a |
|
98 |
|
menu, a prominent item in the list meets this criterion. |
|
99 |
|
|
|
100 |
|
1. Source Code. |
|
101 |
|
|
|
102 |
|
The "source code" for a work means the preferred form of the work |
|
103 |
|
for making modifications to it. "Object code" means any non-source |
|
104 |
|
form of a work. |
|
105 |
|
|
|
106 |
|
A "Standard Interface" means an interface that either is an official |
|
107 |
|
standard defined by a recognized standards body, or, in the case of |
|
108 |
|
interfaces specified for a particular programming language, one that |
|
109 |
|
is widely used among developers working in that language. |
|
110 |
|
|
|
111 |
|
The "System Libraries" of an executable work include anything, other |
|
112 |
|
than the work as a whole, that (a) is included in the normal form of |
|
113 |
|
packaging a Major Component, but which is not part of that Major |
|
114 |
|
Component, and (b) serves only to enable use of the work with that |
|
115 |
|
Major Component, or to implement a Standard Interface for which an |
|
116 |
|
implementation is available to the public in source code form. A |
|
117 |
|
"Major Component", in this context, means a major essential component |
|
118 |
|
(kernel, window system, and so on) of the specific operating system |
|
119 |
|
(if any) on which the executable work runs, or a compiler used to |
|
120 |
|
produce the work, or an object code interpreter used to run it. |
|
121 |
|
|
|
122 |
|
The "Corresponding Source" for a work in object code form means all |
|
123 |
|
the source code needed to generate, install, and (for an executable |
|
124 |
|
work) run the object code and to modify the work, including scripts to |
|
125 |
|
control those activities. However, it does not include the work's |
|
126 |
|
System Libraries, or general-purpose tools or generally available free |
|
127 |
|
programs which are used unmodified in performing those activities but |
|
128 |
|
which are not part of the work. For example, Corresponding Source |
|
129 |
|
includes interface definition files associated with source files for |
|
130 |
|
the work, and the source code for shared libraries and dynamically |
|
131 |
|
linked subprograms that the work is specifically designed to require, |
|
132 |
|
such as by intimate data communication or control flow between those |
|
133 |
|
subprograms and other parts of the work. |
|
134 |
|
|
|
135 |
|
The Corresponding Source need not include anything that users |
|
136 |
|
can regenerate automatically from other parts of the Corresponding |
|
137 |
|
Source. |
|
138 |
|
|
|
139 |
|
The Corresponding Source for a work in source code form is that |
|
140 |
|
same work. |
|
141 |
|
|
|
142 |
|
2. Basic Permissions. |
|
143 |
|
|
|
144 |
|
All rights granted under this License are granted for the term of |
|
145 |
|
copyright on the Program, and are irrevocable provided the stated |
|
146 |
|
conditions are met. This License explicitly affirms your unlimited |
|
147 |
|
permission to run the unmodified Program. The output from running a |
|
148 |
|
covered work is covered by this License only if the output, given its |
|
149 |
|
content, constitutes a covered work. This License acknowledges your |
|
150 |
|
rights of fair use or other equivalent, as provided by copyright law. |
|
151 |
|
|
|
152 |
|
You may make, run and propagate covered works that you do not |
|
153 |
|
convey, without conditions so long as your license otherwise remains |
|
154 |
|
in force. You may convey covered works to others for the sole purpose |
|
155 |
|
of having them make modifications exclusively for you, or provide you |
|
156 |
|
with facilities for running those works, provided that you comply with |
|
157 |
|
the terms of this License in conveying all material for which you do |
|
158 |
|
not control copyright. Those thus making or running the covered works |
|
159 |
|
for you must do so exclusively on your behalf, under your direction |
|
160 |
|
and control, on terms that prohibit them from making any copies of |
|
161 |
|
your copyrighted material outside their relationship with you. |
|
162 |
|
|
|
163 |
|
Conveying under any other circumstances is permitted solely under |
|
164 |
|
the conditions stated below. Sublicensing is not allowed; section 10 |
|
165 |
|
makes it unnecessary. |
|
166 |
|
|
|
167 |
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
|
168 |
|
|
|
169 |
|
No covered work shall be deemed part of an effective technological |
|
170 |
|
measure under any applicable law fulfilling obligations under article |
|
171 |
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or |
|
172 |
|
similar laws prohibiting or restricting circumvention of such |
|
173 |
|
measures. |
|
174 |
|
|
|
175 |
|
When you convey a covered work, you waive any legal power to forbid |
|
176 |
|
circumvention of technological measures to the extent such circumvention |
|
177 |
|
is effected by exercising rights under this License with respect to |
|
178 |
|
the covered work, and you disclaim any intention to limit operation or |
|
179 |
|
modification of the work as a means of enforcing, against the work's |
|
180 |
|
users, your or third parties' legal rights to forbid circumvention of |
|
181 |
|
technological measures. |
|
182 |
|
|
|
183 |
|
4. Conveying Verbatim Copies. |
|
184 |
|
|
|
185 |
|
You may convey verbatim copies of the Program's source code as you |
|
186 |
|
receive it, in any medium, provided that you conspicuously and |
|
187 |
|
appropriately publish on each copy an appropriate copyright notice; |
|
188 |
|
keep intact all notices stating that this License and any |
|
189 |
|
non-permissive terms added in accord with section 7 apply to the code; |
|
190 |
|
keep intact all notices of the absence of any warranty; and give all |
|
191 |
|
recipients a copy of this License along with the Program. |
|
192 |
|
|
|
193 |
|
You may charge any price or no price for each copy that you convey, |
|
194 |
|
and you may offer support or warranty protection for a fee. |
|
195 |
|
|
|
196 |
|
5. Conveying Modified Source Versions. |
|
197 |
|
|
|
198 |
|
You may convey a work based on the Program, or the modifications to |
|
199 |
|
produce it from the Program, in the form of source code under the |
|
200 |
|
terms of section 4, provided that you also meet all of these conditions: |
|
201 |
|
|
|
202 |
|
a) The work must carry prominent notices stating that you modified |
|
203 |
|
it, and giving a relevant date. |
|
204 |
|
|
|
205 |
|
b) The work must carry prominent notices stating that it is |
|
206 |
|
released under this License and any conditions added under section |
|
207 |
|
7. This requirement modifies the requirement in section 4 to |
|
208 |
|
"keep intact all notices". |
|
209 |
|
|
|
210 |
|
c) You must license the entire work, as a whole, under this |
|
211 |
|
License to anyone who comes into possession of a copy. This |
|
212 |
|
License will therefore apply, along with any applicable section 7 |
|
213 |
|
additional terms, to the whole of the work, and all its parts, |
|
214 |
|
regardless of how they are packaged. This License gives no |
|
215 |
|
permission to license the work in any other way, but it does not |
|
216 |
|
invalidate such permission if you have separately received it. |
|
217 |
|
|
|
218 |
|
d) If the work has interactive user interfaces, each must display |
|
219 |
|
Appropriate Legal Notices; however, if the Program has interactive |
|
220 |
|
interfaces that do not display Appropriate Legal Notices, your |
|
221 |
|
work need not make them do so. |
|
222 |
|
|
|
223 |
|
A compilation of a covered work with other separate and independent |
|
224 |
|
works, which are not by their nature extensions of the covered work, |
|
225 |
|
and which are not combined with it such as to form a larger program, |
|
226 |
|
in or on a volume of a storage or distribution medium, is called an |
|
227 |
|
"aggregate" if the compilation and its resulting copyright are not |
|
228 |
|
used to limit the access or legal rights of the compilation's users |
|
229 |
|
beyond what the individual works permit. Inclusion of a covered work |
|
230 |
|
in an aggregate does not cause this License to apply to the other |
|
231 |
|
parts of the aggregate. |
|
232 |
|
|
|
233 |
|
6. Conveying Non-Source Forms. |
|
234 |
|
|
|
235 |
|
You may convey a covered work in object code form under the terms |
|
236 |
|
of sections 4 and 5, provided that you also convey the |
|
237 |
|
machine-readable Corresponding Source under the terms of this License, |
|
238 |
|
in one of these ways: |
|
239 |
|
|
|
240 |
|
a) Convey the object code in, or embodied in, a physical product |
|
241 |
|
(including a physical distribution medium), accompanied by the |
|
242 |
|
Corresponding Source fixed on a durable physical medium |
|
243 |
|
customarily used for software interchange. |
|
244 |
|
|
|
245 |
|
b) Convey the object code in, or embodied in, a physical product |
|
246 |
|
(including a physical distribution medium), accompanied by a |
|
247 |
|
written offer, valid for at least three years and valid for as |
|
248 |
|
long as you offer spare parts or customer support for that product |
|
249 |
|
model, to give anyone who possesses the object code either (1) a |
|
250 |
|
copy of the Corresponding Source for all the software in the |
|
251 |
|
product that is covered by this License, on a durable physical |
|
252 |
|
medium customarily used for software interchange, for a price no |
|
253 |
|
more than your reasonable cost of physically performing this |
|
254 |
|
conveying of source, or (2) access to copy the |
|
255 |
|
Corresponding Source from a network server at no charge. |
|
256 |
|
|
|
257 |
|
c) Convey individual copies of the object code with a copy of the |
|
258 |
|
written offer to provide the Corresponding Source. This |
|
259 |
|
alternative is allowed only occasionally and noncommercially, and |
|
260 |
|
only if you received the object code with such an offer, in accord |
|
261 |
|
with subsection 6b. |
|
262 |
|
|
|
263 |
|
d) Convey the object code by offering access from a designated |
|
264 |
|
place (gratis or for a charge), and offer equivalent access to the |
|
265 |
|
Corresponding Source in the same way through the same place at no |
|
266 |
|
further charge. You need not require recipients to copy the |
|
267 |
|
Corresponding Source along with the object code. If the place to |
|
268 |
|
copy the object code is a network server, the Corresponding Source |
|
269 |
|
may be on a different server (operated by you or a third party) |
|
270 |
|
that supports equivalent copying facilities, provided you maintain |
|
271 |
|
clear directions next to the object code saying where to find the |
|
272 |
|
Corresponding Source. Regardless of what server hosts the |
|
273 |
|
Corresponding Source, you remain obligated to ensure that it is |
|
274 |
|
available for as long as needed to satisfy these requirements. |
|
275 |
|
|
|
276 |
|
e) Convey the object code using peer-to-peer transmission, provided |
|
277 |
|
you inform other peers where the object code and Corresponding |
|
278 |
|
Source of the work are being offered to the general public at no |
|
279 |
|
charge under subsection 6d. |
|
280 |
|
|
|
281 |
|
A separable portion of the object code, whose source code is excluded |
|
282 |
|
from the Corresponding Source as a System Library, need not be |
|
283 |
|
included in conveying the object code work. |
|
284 |
|
|
|
285 |
|
A "User Product" is either (1) a "consumer product", which means any |
|
286 |
|
tangible personal property which is normally used for personal, family, |
|
287 |
|
or household purposes, or (2) anything designed or sold for incorporation |
|
288 |
|
into a dwelling. In determining whether a product is a consumer product, |
|
289 |
|
doubtful cases shall be resolved in favor of coverage. For a particular |
|
290 |
|
product received by a particular user, "normally used" refers to a |
|
291 |
|
typical or common use of that class of product, regardless of the status |
|
292 |
|
of the particular user or of the way in which the particular user |
|
293 |
|
actually uses, or expects or is expected to use, the product. A product |
|
294 |
|
is a consumer product regardless of whether the product has substantial |
|
295 |
|
commercial, industrial or non-consumer uses, unless such uses represent |
|
296 |
|
the only significant mode of use of the product. |
|
297 |
|
|
|
298 |
|
"Installation Information" for a User Product means any methods, |
|
299 |
|
procedures, authorization keys, or other information required to install |
|
300 |
|
and execute modified versions of a covered work in that User Product from |
|
301 |
|
a modified version of its Corresponding Source. The information must |
|
302 |
|
suffice to ensure that the continued functioning of the modified object |
|
303 |
|
code is in no case prevented or interfered with solely because |
|
304 |
|
modification has been made. |
|
305 |
|
|
|
306 |
|
If you convey an object code work under this section in, or with, or |
|
307 |
|
specifically for use in, a User Product, and the conveying occurs as |
|
308 |
|
part of a transaction in which the right of possession and use of the |
|
309 |
|
User Product is transferred to the recipient in perpetuity or for a |
|
310 |
|
fixed term (regardless of how the transaction is characterized), the |
|
311 |
|
Corresponding Source conveyed under this section must be accompanied |
|
312 |
|
by the Installation Information. But this requirement does not apply |
|
313 |
|
if neither you nor any third party retains the ability to install |
|
314 |
|
modified object code on the User Product (for example, the work has |
|
315 |
|
been installed in ROM). |
|
316 |
|
|
|
317 |
|
The requirement to provide Installation Information does not include a |
|
318 |
|
requirement to continue to provide support service, warranty, or updates |
|
319 |
|
for a work that has been modified or installed by the recipient, or for |
|
320 |
|
the User Product in which it has been modified or installed. Access to a |
|
321 |
|
network may be denied when the modification itself materially and |
|
322 |
|
adversely affects the operation of the network or violates the rules and |
|
323 |
|
protocols for communication across the network. |
|
324 |
|
|
|
325 |
|
Corresponding Source conveyed, and Installation Information provided, |
|
326 |
|
in accord with this section must be in a format that is publicly |
|
327 |
|
documented (and with an implementation available to the public in |
|
328 |
|
source code form), and must require no special password or key for |
|
329 |
|
unpacking, reading or copying. |
|
330 |
|
|
|
331 |
|
7. Additional Terms. |
|
332 |
|
|
|
333 |
|
"Additional permissions" are terms that supplement the terms of this |
|
334 |
|
License by making exceptions from one or more of its conditions. |
|
335 |
|
Additional permissions that are applicable to the entire Program shall |
|
336 |
|
be treated as though they were included in this License, to the extent |
|
337 |
|
that they are valid under applicable law. If additional permissions |
|
338 |
|
apply only to part of the Program, that part may be used separately |
|
339 |
|
under those permissions, but the entire Program remains governed by |
|
340 |
|
this License without regard to the additional permissions. |
|
341 |
|
|
|
342 |
|
When you convey a copy of a covered work, you may at your option |
|
343 |
|
remove any additional permissions from that copy, or from any part of |
|
344 |
|
it. (Additional permissions may be written to require their own |
|
345 |
|
removal in certain cases when you modify the work.) You may place |
|
346 |
|
additional permissions on material, added by you to a covered work, |
|
347 |
|
for which you have or can give appropriate copyright permission. |
|
348 |
|
|
|
349 |
|
Notwithstanding any other provision of this License, for material you |
|
350 |
|
add to a covered work, you may (if authorized by the copyright holders of |
|
351 |
|
that material) supplement the terms of this License with terms: |
|
352 |
|
|
|
353 |
|
a) Disclaiming warranty or limiting liability differently from the |
|
354 |
|
terms of sections 15 and 16 of this License; or |
|
355 |
|
|
|
356 |
|
b) Requiring preservation of specified reasonable legal notices or |
|
357 |
|
author attributions in that material or in the Appropriate Legal |
|
358 |
|
Notices displayed by works containing it; or |
|
359 |
|
|
|
360 |
|
c) Prohibiting misrepresentation of the origin of that material, or |
|
361 |
|
requiring that modified versions of such material be marked in |
|
362 |
|
reasonable ways as different from the original version; or |
|
363 |
|
|
|
364 |
|
d) Limiting the use for publicity purposes of names of licensors or |
|
365 |
|
authors of the material; or |
|
366 |
|
|
|
367 |
|
e) Declining to grant rights under trademark law for use of some |
|
368 |
|
trade names, trademarks, or service marks; or |
|
369 |
|
|
|
370 |
|
f) Requiring indemnification of licensors and authors of that |
|
371 |
|
material by anyone who conveys the material (or modified versions of |
|
372 |
|
it) with contractual assumptions of liability to the recipient, for |
|
373 |
|
any liability that these contractual assumptions directly impose on |
|
374 |
|
those licensors and authors. |
|
375 |
|
|
|
376 |
|
All other non-permissive additional terms are considered "further |
|
377 |
|
restrictions" within the meaning of section 10. If the Program as you |
|
378 |
|
received it, or any part of it, contains a notice stating that it is |
|
379 |
|
governed by this License along with a term that is a further |
|
380 |
|
restriction, you may remove that term. If a license document contains |
|
381 |
|
a further restriction but permits relicensing or conveying under this |
|
382 |
|
License, you may add to a covered work material governed by the terms |
|
383 |
|
of that license document, provided that the further restriction does |
|
384 |
|
not survive such relicensing or conveying. |
|
385 |
|
|
|
386 |
|
If you add terms to a covered work in accord with this section, you |
|
387 |
|
must place, in the relevant source files, a statement of the |
|
388 |
|
additional terms that apply to those files, or a notice indicating |
|
389 |
|
where to find the applicable terms. |
|
390 |
|
|
|
391 |
|
Additional terms, permissive or non-permissive, may be stated in the |
|
392 |
|
form of a separately written license, or stated as exceptions; |
|
393 |
|
the above requirements apply either way. |
|
394 |
|
|
|
395 |
|
8. Termination. |
|
396 |
|
|
|
397 |
|
You may not propagate or modify a covered work except as expressly |
|
398 |
|
provided under this License. Any attempt otherwise to propagate or |
|
399 |
|
modify it is void, and will automatically terminate your rights under |
|
400 |
|
this License (including any patent licenses granted under the third |
|
401 |
|
paragraph of section 11). |
|
402 |
|
|
|
403 |
|
However, if you cease all violation of this License, then your |
|
404 |
|
license from a particular copyright holder is reinstated (a) |
|
405 |
|
provisionally, unless and until the copyright holder explicitly and |
|
406 |
|
finally terminates your license, and (b) permanently, if the copyright |
|
407 |
|
holder fails to notify you of the violation by some reasonable means |
|
408 |
|
prior to 60 days after the cessation. |
|
409 |
|
|
|
410 |
|
Moreover, your license from a particular copyright holder is |
|
411 |
|
reinstated permanently if the copyright holder notifies you of the |
|
412 |
|
violation by some reasonable means, this is the first time you have |
|
413 |
|
received notice of violation of this License (for any work) from that |
|
414 |
|
copyright holder, and you cure the violation prior to 30 days after |
|
415 |
|
your receipt of the notice. |
|
416 |
|
|
|
417 |
|
Termination of your rights under this section does not terminate the |
|
418 |
|
licenses of parties who have received copies or rights from you under |
|
419 |
|
this License. If your rights have been terminated and not permanently |
|
420 |
|
reinstated, you do not qualify to receive new licenses for the same |
|
421 |
|
material under section 10. |
|
422 |
|
|
|
423 |
|
9. Acceptance Not Required for Having Copies. |
|
424 |
|
|
|
425 |
|
You are not required to accept this License in order to receive or |
|
426 |
|
run a copy of the Program. Ancillary propagation of a covered work |
|
427 |
|
occurring solely as a consequence of using peer-to-peer transmission |
|
428 |
|
to receive a copy likewise does not require acceptance. However, |
|
429 |
|
nothing other than this License grants you permission to propagate or |
|
430 |
|
modify any covered work. These actions infringe copyright if you do |
|
431 |
|
not accept this License. Therefore, by modifying or propagating a |
|
432 |
|
covered work, you indicate your acceptance of this License to do so. |
|
433 |
|
|
|
434 |
|
10. Automatic Licensing of Downstream Recipients. |
|
435 |
|
|
|
436 |
|
Each time you convey a covered work, the recipient automatically |
|
437 |
|
receives a license from the original licensors, to run, modify and |
|
438 |
|
propagate that work, subject to this License. You are not responsible |
|
439 |
|
for enforcing compliance by third parties with this License. |
|
440 |
|
|
|
441 |
|
An "entity transaction" is a transaction transferring control of an |
|
442 |
|
organization, or substantially all assets of one, or subdividing an |
|
443 |
|
organization, or merging organizations. If propagation of a covered |
|
444 |
|
work results from an entity transaction, each party to that |
|
445 |
|
transaction who receives a copy of the work also receives whatever |
|
446 |
|
licenses to the work the party's predecessor in interest had or could |
|
447 |
|
give under the previous paragraph, plus a right to possession of the |
|
448 |
|
Corresponding Source of the work from the predecessor in interest, if |
|
449 |
|
the predecessor has it or can get it with reasonable efforts. |
|
450 |
|
|
|
451 |
|
You may not impose any further restrictions on the exercise of the |
|
452 |
|
rights granted or affirmed under this License. For example, you may |
|
453 |
|
not impose a license fee, royalty, or other charge for exercise of |
|
454 |
|
rights granted under this License, and you may not initiate litigation |
|
455 |
|
(including a cross-claim or counterclaim in a lawsuit) alleging that |
|
456 |
|
any patent claim is infringed by making, using, selling, offering for |
|
457 |
|
sale, or importing the Program or any portion of it. |
|
458 |
|
|
|
459 |
|
11. Patents. |
|
460 |
|
|
|
461 |
|
A "contributor" is a copyright holder who authorizes use under this |
|
462 |
|
License of the Program or a work on which the Program is based. The |
|
463 |
|
work thus licensed is called the contributor's "contributor version". |
|
464 |
|
|
|
465 |
|
A contributor's "essential patent claims" are all patent claims |
|
466 |
|
owned or controlled by the contributor, whether already acquired or |
|
467 |
|
hereafter acquired, that would be infringed by some manner, permitted |
|
468 |
|
by this License, of making, using, or selling its contributor version, |
|
469 |
|
but do not include claims that would be infringed only as a |
|
470 |
|
consequence of further modification of the contributor version. For |
|
471 |
|
purposes of this definition, "control" includes the right to grant |
|
472 |
|
patent sublicenses in a manner consistent with the requirements of |
|
473 |
|
this License. |
|
474 |
|
|
|
475 |
|
Each contributor grants you a non-exclusive, worldwide, royalty-free |
|
476 |
|
patent license under the contributor's essential patent claims, to |
|
477 |
|
make, use, sell, offer for sale, import and otherwise run, modify and |
|
478 |
|
propagate the contents of its contributor version. |
|
479 |
|
|
|
480 |
|
In the following three paragraphs, a "patent license" is any express |
|
481 |
|
agreement or commitment, however denominated, not to enforce a patent |
|
482 |
|
(such as an express permission to practice a patent or covenant not to |
|
483 |
|
sue for patent infringement). To "grant" such a patent license to a |
|
484 |
|
party means to make such an agreement or commitment not to enforce a |
|
485 |
|
patent against the party. |
|
486 |
|
|
|
487 |
|
If you convey a covered work, knowingly relying on a patent license, |
|
488 |
|
and the Corresponding Source of the work is not available for anyone |
|
489 |
|
to copy, free of charge and under the terms of this License, through a |
|
490 |
|
publicly available network server or other readily accessible means, |
|
491 |
|
then you must either (1) cause the Corresponding Source to be so |
|
492 |
|
available, or (2) arrange to deprive yourself of the benefit of the |
|
493 |
|
patent license for this particular work, or (3) arrange, in a manner |
|
494 |
|
consistent with the requirements of this License, to extend the patent |
|
495 |
|
license to downstream recipients. "Knowingly relying" means you have |
|
496 |
|
actual knowledge that, but for the patent license, your conveying the |
|
497 |
|
covered work in a country, or your recipient's use of the covered work |
|
498 |
|
in a country, would infringe one or more identifiable patents in that |
|
499 |
|
country that you have reason to believe are valid. |
|
500 |
|
|
|
501 |
|
If, pursuant to or in connection with a single transaction or |
|
502 |
|
arrangement, you convey, or propagate by procuring conveyance of, a |
|
503 |
|
covered work, and grant a patent license to some of the parties |
|
504 |
|
receiving the covered work authorizing them to use, propagate, modify |
|
505 |
|
or convey a specific copy of the covered work, then the patent license |
|
506 |
|
you grant is automatically extended to all recipients of the covered |
|
507 |
|
work and works based on it. |
|
508 |
|
|
|
509 |
|
A patent license is "discriminatory" if it does not include within |
|
510 |
|
the scope of its coverage, prohibits the exercise of, or is |
|
511 |
|
conditioned on the non-exercise of one or more of the rights that are |
|
512 |
|
specifically granted under this License. You may not convey a covered |
|
513 |
|
work if you are a party to an arrangement with a third party that is |
|
514 |
|
in the business of distributing software, under which you make payment |
|
515 |
|
to the third party based on the extent of your activity of conveying |
|
516 |
|
the work, and under which the third party grants, to any of the |
|
517 |
|
parties who would receive the covered work from you, a discriminatory |
|
518 |
|
patent license (a) in connection with copies of the covered work |
|
519 |
|
conveyed by you (or copies made from those copies), or (b) primarily |
|
520 |
|
for and in connection with specific products or compilations that |
|
521 |
|
contain the covered work, unless you entered into that arrangement, |
|
522 |
|
or that patent license was granted, prior to 28 March 2007. |
|
523 |
|
|
|
524 |
|
Nothing in this License shall be construed as excluding or limiting |
|
525 |
|
any implied license or other defenses to infringement that may |
|
526 |
|
otherwise be available to you under applicable patent law. |
|
527 |
|
|
|
528 |
|
12. No Surrender of Others' Freedom. |
|
529 |
|
|
|
530 |
|
If conditions are imposed on you (whether by court order, agreement or |
|
531 |
|
otherwise) that contradict the conditions of this License, they do not |
|
532 |
|
excuse you from the conditions of this License. If you cannot convey a |
|
533 |
|
covered work so as to satisfy simultaneously your obligations under this |
|
534 |
|
License and any other pertinent obligations, then as a consequence you may |
|
535 |
|
not convey it at all. For example, if you agree to terms that obligate you |
|
536 |
|
to collect a royalty for further conveying from those to whom you convey |
|
537 |
|
the Program, the only way you could satisfy both those terms and this |
|
538 |
|
License would be to refrain entirely from conveying the Program. |
|
539 |
|
|
|
540 |
|
13. Remote Network Interaction; Use with the GNU General Public License. |
|
541 |
|
|
|
542 |
|
Notwithstanding any other provision of this License, if you modify the |
|
543 |
|
Program, your modified version must prominently offer all users |
|
544 |
|
interacting with it remotely through a computer network (if your version |
|
545 |
|
supports such interaction) an opportunity to receive the Corresponding |
|
546 |
|
Source of your version by providing access to the Corresponding Source |
|
547 |
|
from a network server at no charge, through some standard or customary |
|
548 |
|
means of facilitating copying of software. This Corresponding Source |
|
549 |
|
shall include the Corresponding Source for any work covered by version 3 |
|
550 |
|
of the GNU General Public License that is incorporated pursuant to the |
|
551 |
|
following paragraph. |
|
552 |
|
|
|
553 |
|
Notwithstanding any other provision of this License, you have |
|
554 |
|
permission to link or combine any covered work with a work licensed |
|
555 |
|
under version 3 of the GNU General Public License into a single |
|
556 |
|
combined work, and to convey the resulting work. The terms of this |
|
557 |
|
License will continue to apply to the part which is the covered work, |
|
558 |
|
but the work with which it is combined will remain governed by version |
|
559 |
|
3 of the GNU General Public License. |
|
560 |
|
|
|
561 |
|
14. Revised Versions of this License. |
|
562 |
|
|
|
563 |
|
The Free Software Foundation may publish revised and/or new versions of |
|
564 |
|
the GNU Affero General Public License from time to time. Such new versions |
|
565 |
|
will be similar in spirit to the present version, but may differ in detail to |
|
566 |
|
address new problems or concerns. |
|
567 |
|
|
|
568 |
|
Each version is given a distinguishing version number. If the |
|
569 |
|
Program specifies that a certain numbered version of the GNU Affero General |
|
570 |
|
Public License "or any later version" applies to it, you have the |
|
571 |
|
option of following the terms and conditions either of that numbered |
|
572 |
|
version or of any later version published by the Free Software |
|
573 |
|
Foundation. If the Program does not specify a version number of the |
|
574 |
|
GNU Affero General Public License, you may choose any version ever published |
|
575 |
|
by the Free Software Foundation. |
|
576 |
|
|
|
577 |
|
If the Program specifies that a proxy can decide which future |
|
578 |
|
versions of the GNU Affero General Public License can be used, that proxy's |
|
579 |
|
public statement of acceptance of a version permanently authorizes you |
|
580 |
|
to choose that version for the Program. |
|
581 |
|
|
|
582 |
|
Later license versions may give you additional or different |
|
583 |
|
permissions. However, no additional obligations are imposed on any |
|
584 |
|
author or copyright holder as a result of your choosing to follow a |
|
585 |
|
later version. |
|
586 |
|
|
|
587 |
|
15. Disclaimer of Warranty. |
|
588 |
|
|
|
589 |
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
|
590 |
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
|
591 |
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
|
592 |
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
|
593 |
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
594 |
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
|
595 |
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
|
596 |
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
|
597 |
|
|
|
598 |
|
16. Limitation of Liability. |
|
599 |
|
|
|
600 |
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
601 |
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
|
602 |
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
|
603 |
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
|
604 |
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
|
605 |
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
|
606 |
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
|
607 |
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
608 |
|
SUCH DAMAGES. |
|
609 |
|
|
|
610 |
|
17. Interpretation of Sections 15 and 16. |
|
611 |
|
|
|
612 |
|
If the disclaimer of warranty and limitation of liability provided |
|
613 |
|
above cannot be given local legal effect according to their terms, |
|
614 |
|
reviewing courts shall apply local law that most closely approximates |
|
615 |
|
an absolute waiver of all civil liability in connection with the |
|
616 |
|
Program, unless a warranty or assumption of liability accompanies a |
|
617 |
|
copy of the Program in return for a fee. |
|
618 |
|
|
|
619 |
|
END OF TERMS AND CONDITIONS |
|
620 |
|
|
|
621 |
|
How to Apply These Terms to Your New Programs |
|
622 |
|
|
|
623 |
|
If you develop a new program, and you want it to be of the greatest |
|
624 |
|
possible use to the public, the best way to achieve this is to make it |
|
625 |
|
free software which everyone can redistribute and change under these terms. |
|
626 |
|
|
|
627 |
|
To do so, attach the following notices to the program. It is safest |
|
628 |
|
to attach them to the start of each source file to most effectively |
|
629 |
|
state the exclusion of warranty; and each file should have at least |
|
630 |
|
the "copyright" line and a pointer to where the full notice is found. |
|
631 |
|
|
|
632 |
|
<one line to give the program's name and a brief idea of what it does.> |
|
633 |
|
Copyright (C) <year> <name of author> |
|
634 |
|
|
|
635 |
|
This program is free software: you can redistribute it and/or modify |
|
636 |
|
it under the terms of the GNU Affero General Public License as published by |
|
637 |
|
the Free Software Foundation, either version 3 of the License, or |
|
638 |
|
(at your option) any later version. |
|
639 |
|
|
|
640 |
|
This program is distributed in the hope that it will be useful, |
|
641 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
642 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
643 |
|
GNU Affero General Public License for more details. |
|
644 |
|
|
|
645 |
|
You should have received a copy of the GNU Affero General Public License |
|
646 |
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
647 |
|
|
|
648 |
|
Also add information on how to contact you by electronic and paper mail. |
|
649 |
|
|
|
650 |
|
If your software can interact with users remotely through a computer |
|
651 |
|
network, you should also make sure that it provides a way for users to |
|
652 |
|
get its source. For example, if your program is a web application, its |
|
653 |
|
interface could display a "Source" link that leads users to an archive |
|
654 |
|
of the code. There are many ways you could offer source, and different |
|
655 |
|
solutions will be better for different programs; see section 13 for the |
|
656 |
|
specific requirements. |
|
657 |
|
|
|
658 |
|
You should also get your employer (if you work as a programmer) or school, |
|
659 |
|
if any, to sign a "copyright disclaimer" for the program, if necessary. |
|
660 |
|
For more information on this, and how to apply and follow the GNU AGPL, see |
|
661 |
|
<http://www.gnu.org/licenses/>. |
File duilder added (mode: 100755) (index 0000000..9320430) |
|
1 |
|
#!/bin/bash |
|
2 |
|
|
|
3 |
|
set -e |
|
4 |
|
|
|
5 |
|
function duilder_final() |
|
6 |
|
{ |
|
7 |
|
PRJ="${1}" |
|
8 |
|
VER="${2}" |
|
9 |
|
RELEASE_SCRIPT="${3}" |
|
10 |
|
|
|
11 |
|
# Run release script |
|
12 |
|
if [ ! -z "${RELEASE_SCRIPT}" -a -x "${RELEASE_SCRIPT}" ]; then |
|
13 |
|
echo "[*] Running ${RELEASE_SCRIPT}..." |
|
14 |
|
${RELEASE_SCRIPT} |
|
15 |
|
fi |
|
16 |
|
} |
|
17 |
|
|
|
18 |
|
function duilder_docs() |
|
19 |
|
{ |
|
20 |
|
PRJ="${1}" |
|
21 |
|
VER="${2}" |
|
22 |
|
EXPORT_PATH="${3}" |
|
23 |
|
|
|
24 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
25 |
|
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
26 |
|
mkdir -p "${EXPORT_PATH}" |
|
27 |
|
fi |
|
28 |
|
|
|
29 |
|
if [ "${BUILD_SDEB}" = "1" ]; then |
|
30 |
|
if [ -d "debian" ]; then |
|
31 |
|
>debian/docs |
|
32 |
|
fi |
|
33 |
|
fi |
|
34 |
|
|
|
35 |
|
echo "[*] Copying docs to [${EXPORT_PATH}]..." |
|
36 |
|
for f in README License LICENSE Changelog Changelog-last TODO FAQ INSTALL AUTHORS samples; do |
|
37 |
|
if [ -r "${f}" ]; then |
|
38 |
|
cp -avp "${f}" "${EXPORT_PATH}/" |
|
39 |
|
if [ "${BUILD_SDEB}" = "1" ]; then |
|
40 |
|
# No need to install the license file |
|
41 |
|
if [ "${f}" = "LICENSE" ]; then |
|
42 |
|
continue |
|
43 |
|
fi |
|
44 |
|
echo "${f}" >> debian/docs |
|
45 |
|
fi |
|
46 |
|
fi |
|
47 |
|
done |
|
48 |
|
echo |
|
49 |
|
|
|
50 |
|
if [ -d "screenshot" ]; then |
|
51 |
|
echo "[*] Copying screenshots..." |
|
52 |
|
mkdir -p "${EXPORT_PATH}" |
|
53 |
|
cp -vp screenshot/* "${EXPORT_PATH}/" |
|
54 |
|
echo |
|
55 |
|
fi |
|
56 |
|
} |
|
57 |
|
|
|
58 |
|
function duilder_git() |
|
59 |
|
{ |
|
60 |
|
PRJ="${1}" |
|
61 |
|
GIT_DEST="${2}" |
|
62 |
|
EXPORT_GIT="${3}" |
|
63 |
|
GIT_CHANGELOG="${4}" |
|
64 |
|
GIT_PUSH="${5}" |
|
65 |
|
|
|
66 |
|
if [ ! -x /usr/bin/git ]; then |
|
67 |
|
echo "[*] Warning: Git not found!" |
|
68 |
|
exit 0 |
|
69 |
|
fi |
|
70 |
|
|
|
71 |
|
if [ ! -d .git ]; then |
|
72 |
|
echo "[*] Warning: I cannot find .git directory!" |
|
73 |
|
exit 0 |
|
74 |
|
fi |
|
75 |
|
|
|
76 |
|
echo "[*] Testing if a tag is present for HEAD..." |
|
77 |
|
D=`git describe | sed -e 's/^.*-g[0-9a-fA-F]*$//'` |
|
78 |
|
if [ "${D}" = "" ]; then |
|
79 |
|
echo "No annotated tag preset for HEAD! Please add one!" |
|
80 |
|
exit 1 |
|
81 |
|
fi |
|
82 |
|
|
|
83 |
|
if [ "${EXPORT_GIT}" = "1" ]; then |
|
84 |
|
echo "[*] Generating GIT tree for HTTP transport..." |
|
85 |
|
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then |
|
86 |
|
git clone --bare . "${GIT_DEST}/${PRJ}.git" |
|
87 |
|
|
|
88 |
|
# Activate post-update hook |
|
89 |
|
cp "${GIT_DEST}/${PRJ}.git/hooks/post-update.sample" \ |
|
90 |
|
"${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
91 |
|
chmod a+x "${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
92 |
|
|
|
93 |
|
# add project name and description |
|
94 |
|
echo "${PRJ}" > "${GIT_DEST}/${PRJ}.git/description" |
|
95 |
|
|
|
96 |
|
# allow export by git daemon? |
|
97 |
|
#touch "${GIT_DEST}/${PRJ}.git/git-daemon-export-ok |
|
98 |
|
else |
|
99 |
|
# --force? |
|
100 |
|
echo "Running git push -v --all \"${GIT_DEST}/${PRJ}.git\"..." |
|
101 |
|
git push -v --all "${GIT_DEST}/${PRJ}.git" |
|
102 |
|
echo "Running git push -v --tags \"${GIT_DEST}/${PRJ}.git\"..." |
|
103 |
|
git push -v --tags "${GIT_DEST}/${PRJ}.git" |
|
104 |
|
fi |
|
105 |
|
(cd "${GIT_DEST}/${PRJ}.git" && git update-server-info) |
|
106 |
|
fi |
|
107 |
|
|
|
108 |
|
if [ "${GIT_PUSH}" = "1" ]; then |
|
109 |
|
echo "[*] Git push..." |
|
110 |
|
git push -v --all |
|
111 |
|
fi |
|
112 |
|
|
|
113 |
|
if [ "${GIT_CHANGELOG}" = "1" ]; then |
|
114 |
|
echo "[*] Generating Changelog from git..." |
|
115 |
|
echo -n > Changelog |
|
116 |
|
|
|
117 |
|
# get the list of tags |
|
118 |
|
number_of_tags=0 |
|
119 |
|
git show-ref --tags -d | grep refs/tags/v > duilder.tmp |
|
120 |
|
while read sha1 full_tag; do |
|
121 |
|
tag=`echo ${full_tag} | sed -e 's#refs/tags/##' | cut -d'^' -f1` |
|
122 |
|
tags[${number_of_tags}]=${tag} |
|
123 |
|
tags_commit[${number_of_tags}]=${sha1} |
|
124 |
|
number_of_tags=$[${number_of_tags}+1] |
|
125 |
|
done < duilder.tmp |
|
126 |
|
rm -f duilder.tmp |
|
127 |
|
|
|
128 |
|
# get the list of commits, test if is a tag and do the diff |
|
129 |
|
prev="" |
|
130 |
|
add="" |
|
131 |
|
first=1 |
|
132 |
|
git log --pretty=oneline | cut -f1 | \ |
|
133 |
|
while read commit junk; do |
|
134 |
|
# test if it is a tag |
|
135 |
|
tag="" |
|
136 |
|
i=0 |
|
137 |
|
while [ "${i}" -lt "${number_of_tags}" ]; do |
|
138 |
|
if [ "${commit}" = "${tags_commit[${i}]}" ]; then |
|
139 |
|
tag="${tags[${i}]}" |
|
140 |
|
break |
|
141 |
|
fi |
|
142 |
|
|
|
143 |
|
i=$[${i}+1] |
|
144 |
|
done |
|
145 |
|
|
|
146 |
|
if [ -z "${tag}" ]; then |
|
147 |
|
continue |
|
148 |
|
fi |
|
149 |
|
|
|
150 |
|
if [ ! -z "${prev}" ]; then |
|
151 |
|
echo "[*] Generating Changelog from ${tag} -> ${prev}..." |
|
152 |
|
echo -en "${add}" >> Changelog |
|
153 |
|
add="\n" |
|
154 |
|
echo "[${tag} -> ${prev}]" >> Changelog |
|
155 |
|
git shortlog ${tag}..${prev} | \ |
|
156 |
|
(IFS="" |
|
157 |
|
while read line; do |
|
158 |
|
echo " ${line}" |
|
159 |
|
done) \ |
|
160 |
|
>> Changelog |
|
161 |
|
|
|
162 |
|
if [ "${first}" = "1" ]; then |
|
163 |
|
echo "[*] Generating Changelog-last..." |
|
164 |
|
cp Changelog Changelog-last |
|
165 |
|
first=0 |
|
166 |
|
fi |
|
167 |
|
fi |
|
168 |
|
prev=${tag} |
|
169 |
|
done |
|
170 |
|
fi |
|
171 |
|
} |
|
172 |
|
|
|
173 |
|
function duilder_srpm() |
|
174 |
|
{ |
|
175 |
|
PRJ="${1}" |
|
176 |
|
VER="${2}" |
|
177 |
|
EXPORT_PATH="${3}" |
|
178 |
|
BUILD_SRPM="${4}" |
|
179 |
|
SRPM_DEST="${5}" |
|
180 |
|
SRPM_POST_RUN="${6}" |
|
181 |
|
|
|
182 |
|
P="${PRJ}-${VER}" |
|
183 |
|
|
|
184 |
|
if [ "${BUILD_SRPM}" != "1" ]; then |
|
185 |
|
exit 0 |
|
186 |
|
fi |
|
187 |
|
|
|
188 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
189 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
190 |
|
mkdir -p "${EXPORT_PATH}" |
|
191 |
|
fi |
|
192 |
|
|
|
193 |
|
echo "[*] Building SRPM..." |
|
194 |
|
rpmbuild -ts "${P}.tar.gz" |
|
195 |
|
echo |
|
196 |
|
|
|
197 |
|
PKG="${RPMBUILD}/SRPMS/${P}-${REV}.src.rpm" |
|
198 |
|
|
|
199 |
|
# Run a rpmlint on it |
|
200 |
|
if [ -x /usr/bin/rpmlint ]; then |
|
201 |
|
echo "[*] RPMlinting..." |
|
202 |
|
rpmlint -iv "${PKG}" > rpmlint.out |
|
203 |
|
else |
|
204 |
|
echo "[*] WARN: rpmlint is missing!" |
|
205 |
|
fi |
|
206 |
|
|
|
207 |
|
if [ ! -z "${SRPM_DEST}" ]; then |
|
208 |
|
if [ -r "${SRPM_DEST}/${PKG}" ]; then |
|
209 |
|
mv "${SRPM_DEST}/${PKG}" "${SRPM_DEST}/${PKG}.old" |
|
210 |
|
fi |
|
211 |
|
echo "[*] Copying [${PKG}] to [${SRPM_DEST}]..." |
|
212 |
|
cp -vp "${PKG}" "${SRPM_DEST}/" |
|
213 |
|
fi |
|
214 |
|
|
|
215 |
|
echo "[*] Copying to export dir [${EXPORT_PATH}]..." |
|
216 |
|
mkdir -p "${EXPORT_PATH}" |
|
217 |
|
cp -vp "${PKG}" "${EXPORT_PATH}/" |
|
218 |
|
echo |
|
219 |
|
|
|
220 |
|
if [ -x "${SRPM_POST_RUN}" ]; then |
|
221 |
|
echo "[*] Running post SRPM build script [${SRPM_POST_RUN}]..." |
|
222 |
|
${SRPM_POST_RUN} "${PKG}" |
|
223 |
|
fi |
|
224 |
|
} |
|
225 |
|
|
|
226 |
|
function duilder_sdeb() |
|
227 |
|
{ |
|
228 |
|
PRJ="${1}" |
|
229 |
|
VER="${2}" |
|
230 |
|
EXPORT_PATH="${3}" |
|
231 |
|
BUILD_SDEB="${4}" |
|
232 |
|
SDEB_DEST="${5}" |
|
233 |
|
SDEB_POST_RUN="${6}" |
|
234 |
|
|
|
235 |
|
P="${PRJ}-${VER}" |
|
236 |
|
|
|
237 |
|
if [ "${BUILD_SDEB}" != "1" ]; then |
|
238 |
|
exit 0 |
|
239 |
|
fi |
|
240 |
|
|
|
241 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
242 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
243 |
|
mkdir -p "${EXPORT_PATH}" |
|
244 |
|
fi |
|
245 |
|
|
|
246 |
|
echo "[*] Copying SDEB..." |
|
247 |
|
PKG="${PRJ}_${VER}.orig.tar.gz" |
|
248 |
|
|
|
249 |
|
if [ -n "${SDEB_DEST}" ]; then |
|
250 |
|
cp -vp "${P}.tar.gz" "${SDEB_DEST}/${PKG}" |
|
251 |
|
fi |
|
252 |
|
|
|
253 |
|
echo "[*] Copying to export dir [${DEB_EXPORT_PATH}]..." |
|
254 |
|
mkdir -p "${EXPORT_PATH}" |
|
255 |
|
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/${PKG}" |
|
256 |
|
echo |
|
257 |
|
|
|
258 |
|
if [ -x "${SDEB_POST_RUN}" ]; then |
|
259 |
|
echo "[*] Running post SDEB build script [${SDEB_POST_RUN}]..." |
|
260 |
|
${SDEB_POST_RUN} "${SDEB}/${PKG}" |
|
261 |
|
fi |
|
262 |
|
} |
|
263 |
|
|
|
264 |
|
function duilder_tar() |
|
265 |
|
{ |
|
266 |
|
PRJ="${1}" |
|
267 |
|
VER="${2}" |
|
268 |
|
EXPORT_PATH="${3}" |
|
269 |
|
EXCLUDE="${4}" |
|
270 |
|
|
|
271 |
|
P="${PRJ}-${VER}" |
|
272 |
|
|
|
273 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
274 |
|
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
275 |
|
mkdir -p "${EXPORT_PATH}" |
|
276 |
|
fi |
|
277 |
|
|
|
278 |
|
echo "[*] Generating tarball [${P}.tar.gz]..." |
|
279 |
|
ADD_EXCLUDE="" |
|
280 |
|
if [ -r "${EXCLUDE}" ]; then |
|
281 |
|
ADD_EXCLUDE="--exclude-from ${P}/${EXCLUDE}" |
|
282 |
|
echo "[*] ADD_EXCLUDE=${ADD_EXCLUDE}" |
|
283 |
|
fi |
|
284 |
|
|
|
285 |
|
(cd .. \ |
|
286 |
|
&& rm -rf "${P}" \ |
|
287 |
|
&& cp -a --link "${PRJ}" "${P}" \ |
|
288 |
|
&& tar czf "${PRJ}/${P}.tar.gz" \ |
|
289 |
|
--exclude-vcs \ |
|
290 |
|
--exclude ${P}/Makefile \ |
|
291 |
|
${ADD_EXCLUDE} \ |
|
292 |
|
"${P}" \ |
|
293 |
|
&& rm -rf "${P}" |
|
294 |
|
) |
|
295 |
|
|
|
296 |
|
echo "[*] Copying source to ${EXPORT_PATH}..." |
|
297 |
|
mkdir -p "${EXPORT_PATH}" |
|
298 |
|
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/" |
|
299 |
|
echo |
|
300 |
|
} |
|
301 |
|
|
|
302 |
|
#################################################################### |
|
303 |
|
|
|
304 |
|
# Variables |
|
305 |
|
if [ -d "${HOME}/rpmbuild" ]; then |
|
306 |
|
RPMBUILD="${HOME}/rpmbuild" |
|
307 |
|
else |
|
308 |
|
RPMBUILD="/usr/src/redhat" |
|
309 |
|
fi |
|
310 |
|
|
|
311 |
|
|
|
312 |
|
if [ ! -r duilder.conf ]; then |
|
313 |
|
echo "[*] You must build a duilder.conf file!" |
|
314 |
|
exit 1 |
|
315 |
|
fi |
|
316 |
|
|
|
317 |
|
source ${PWD}/duilder.conf |
|
318 |
|
|
|
319 |
|
# fixes |
|
320 |
|
if [ -z "${GIT_DEST}" ]; then |
|
321 |
|
GIT_DEST="${EXPORT_PATH}" |
|
322 |
|
fi |
|
323 |
|
|
|
324 |
|
if [ -z "${PRJ}" ]; then |
|
325 |
|
echo "ERROR: PRJ= parameter is missing." |
|
326 |
|
exit 1 |
|
327 |
|
fi |
|
328 |
|
|
|
329 |
|
if [ -z "${VER}" ]; then |
|
330 |
|
echo "ERROR: VER= parameter is missing." |
|
331 |
|
exit 1 |
|
332 |
|
fi |
|
333 |
|
|
|
334 |
|
if [ -z "${REV}" ]; then |
|
335 |
|
echo "ERROR: REV= parameter is missing." |
|
336 |
|
exit 1 |
|
337 |
|
fi |
|
338 |
|
|
|
339 |
|
# export variables - just in case a script cares |
|
340 |
|
export PRJ VER REV SHORT_DESCRIPTION EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST |
|
341 |
|
export SRPM_DEST SDEB_DEST LICENSE MAINTAINER_NAME MAINTAINER_EMAIL |
|
342 |
|
export HOME_PAGE BUILD_SRPM BUILD_SDEB |
|
343 |
|
|
|
344 |
|
|
|
345 |
|
# Multiplexer |
|
346 |
|
if [ "${1}" = "docs" ]; then |
|
347 |
|
shift |
|
348 |
|
duilder_docs "$@" |
|
349 |
|
exit $? |
|
350 |
|
fi |
|
351 |
|
|
|
352 |
|
if [ "${1}" = "tar" ]; then |
|
353 |
|
shift |
|
354 |
|
duilder_tar "$@" |
|
355 |
|
exit $? |
|
356 |
|
fi |
|
357 |
|
|
|
358 |
|
if [ "${1}" = "git" ]; then |
|
359 |
|
shift |
|
360 |
|
duilder_git "$@" |
|
361 |
|
exit $? |
|
362 |
|
fi |
|
363 |
|
|
|
364 |
|
if [ "${1}" = "srpm" ]; then |
|
365 |
|
shift |
|
366 |
|
duilder_srpm "$@" |
|
367 |
|
exit $? |
|
368 |
|
fi |
|
369 |
|
|
|
370 |
|
if [ "${1}" = "sdeb" ]; then |
|
371 |
|
shift |
|
372 |
|
duilder_sdeb "$@" |
|
373 |
|
exit $? |
|
374 |
|
fi |
|
375 |
|
|
|
376 |
|
if [ "${1}" = "final" ]; then |
|
377 |
|
shift |
|
378 |
|
duilder_final "$@" |
|
379 |
|
exit $? |
|
380 |
|
fi |
|
381 |
|
|
|
382 |
|
|
|
383 |
|
###### Main stuff |
|
384 |
|
echo "[*] Duilder builder script" |
|
385 |
|
echo "[*] Copyright Catalin(ux) M. BOIE - catab at embedromix dot ro" |
|
386 |
|
echo "[*] PRJ=${PRJ}, VER=${VER}, REV=${REV}" |
|
387 |
|
echo "[*] System: `uname -a`" |
|
388 |
|
echo "[*] Parameters: ${@}" |
|
389 |
|
|
|
390 |
|
ETC="/etc" |
|
391 |
|
BIN="/bin" |
|
392 |
|
USR="/usr" |
|
393 |
|
USR_BIN="/usr/bin" |
|
394 |
|
USR_SBIN="/usr/sbin" |
|
395 |
|
USR_INCLUDE="/usr/include" |
|
396 |
|
if [ "`uname -m`" = "i686" ]; then |
|
397 |
|
USR_LIB="/usr/lib" |
|
398 |
|
else |
|
399 |
|
USR_LIB="/usr/lib64" |
|
400 |
|
fi |
|
401 |
|
USR_SHARE="/usr/share" |
|
402 |
|
USR_SHARE_DOC="/usr/share/doc/${PRJ}" |
|
403 |
|
SBIN="/usr/sbin" |
|
404 |
|
VAR="/var" |
|
405 |
|
VAR_LIB="/var/lib" |
|
406 |
|
MAN="/usr/share/man" |
|
407 |
|
PREFIX="/usr" |
|
408 |
|
|
|
409 |
|
while [ "${1}" != "" ]; do |
|
410 |
|
xVAR="`echo ${1} | cut -d'=' -f1`" |
|
411 |
|
xVAL="`echo ${1} | cut -d'=' -f2 | sed -e "s|\\${prefix}|${PREFIX}|"`" |
|
412 |
|
shift |
|
413 |
|
case ${xVAR} in |
|
414 |
|
--sysconfdir) |
|
415 |
|
ETC="${xVAL}" |
|
416 |
|
;; |
|
417 |
|
--bindir) |
|
418 |
|
USR_BIN="${xVAL}" |
|
419 |
|
;; |
|
420 |
|
--sbindir) |
|
421 |
|
USR_SBIN="${xVAL}" |
|
422 |
|
;; |
|
423 |
|
--includedir) |
|
424 |
|
USR_INCLUDE="${xVAL}" |
|
425 |
|
;; |
|
426 |
|
--libdir) |
|
427 |
|
USR_LIB="${xVAL}" |
|
428 |
|
;; |
|
429 |
|
--localstatedir) |
|
430 |
|
VAR="${xVAL}" |
|
431 |
|
;; |
|
432 |
|
--sharedstatedir) |
|
433 |
|
VAR_LIB="${xVAL}" |
|
434 |
|
;; |
|
435 |
|
--datadir) |
|
436 |
|
USR_SHARE="${xVAL}" |
|
437 |
|
;; |
|
438 |
|
--mandir) |
|
439 |
|
MAN="${xVAL}" |
|
440 |
|
;; |
|
441 |
|
--prefix) |
|
442 |
|
PREFIX="${xVAL}" |
|
443 |
|
USR="${xVAL}" |
|
444 |
|
;; |
|
445 |
|
esac |
|
446 |
|
done |
|
447 |
|
|
|
448 |
|
# Last fixes |
|
449 |
|
VAR_LOG="${VAR}/log" |
|
450 |
|
VAR_RUN="${VAR}/run" |
|
451 |
|
DUILDER_SYSTEMD="${USR}/lib/systemd" |
|
452 |
|
|
|
453 |
|
for i in ETC BIN USR USR_BIN USR_SBIN USR_INCLUDE USR_LIB USR_SHARE USR_SHARE_DOC SBIN VAR VAR_LIB MAN VAR_LOG VAR_RUN DUILDER_SYSTEMD; do |
|
454 |
|
eval value=\$$i |
|
455 |
|
echo "[*] Var ${i}=${value}" |
|
456 |
|
done |
|
457 |
|
|
|
458 |
|
# Truncate future sed file |
|
459 |
|
> tmp.sed |
|
460 |
|
|
|
461 |
|
DB_SUPPORT=0 |
|
462 |
|
|
|
463 |
|
echo -n "[*] Searching for PostgreSQL..." |
|
464 |
|
set +e |
|
465 |
|
PG_VERSION="`pg_config --version 2>/dev/null`" |
|
466 |
|
set -e |
|
467 |
|
if [ -z "${PG_VERSION}" ]; then |
|
468 |
|
echo " not found." |
|
469 |
|
PG_FOUND=0 |
|
470 |
|
else |
|
471 |
|
echo " found version ${PG_VERSION}." |
|
472 |
|
PG_FOUND=1 |
|
473 |
|
PG_INC="-I`pg_config --includedir`" |
|
474 |
|
PG_LIB="-L`pg_config --libdir` -lpq" |
|
475 |
|
|
|
476 |
|
echo "s#@PG_VERSION@#${PG_VERSION}#g" >> tmp.sed |
|
477 |
|
echo "s#@PG_INC@#${PG_INC}#g" >> tmp.sed |
|
478 |
|
echo "s#@PG_LIB@#${PG_LIB}#g" >> tmp.sed |
|
479 |
|
|
|
480 |
|
DB_SUPPORT=1 |
|
481 |
|
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed |
|
482 |
|
fi |
|
483 |
|
echo "s#@PG_FOUND@#${PG_FOUND}#g" >> tmp.sed |
|
484 |
|
|
|
485 |
|
|
|
486 |
|
echo -n "[*] Searching for MySQL..." |
|
487 |
|
set +e |
|
488 |
|
MYSQL_VERSION="`mysql_config --version 2>/dev/null`" |
|
489 |
|
set -e |
|
490 |
|
if [ -z "${MYSQL_VERSION}" ]; then |
|
491 |
|
echo " not found." |
|
492 |
|
MYSQL_FOUND=0 |
|
493 |
|
else |
|
494 |
|
echo " found version ${MYSQL_VERSION}." |
|
495 |
|
MYSQL_FOUND=1 |
|
496 |
|
MYSQL_INC="`mysql_config --include`" |
|
497 |
|
MYSQL_LIB="`mysql_config --libs`" |
|
498 |
|
|
|
499 |
|
echo "s#@MYSQL_VERSION@#${MYSQL_VERSION}#g" >> tmp.sed |
|
500 |
|
echo "s#@MYSQL_INC@#${MYSQL_INC}#g" >> tmp.sed |
|
501 |
|
echo "s#@MYSQL_LIB@#${MYSQL_LIB}#g" >> tmp.sed |
|
502 |
|
|
|
503 |
|
DB_SUPPORT=1 |
|
504 |
|
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed |
|
505 |
|
fi |
|
506 |
|
echo "s#@MYSQL_FOUND@#${MYSQL_FOUND}#g" >> tmp.sed |
|
507 |
|
|
|
508 |
|
echo -n "[*] Searching for poll..." |
|
509 |
|
set +e |
|
510 |
|
echo -e "#include <poll.h> \n int main(void) { return poll(0, 0, 0); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
|
511 |
|
E="${?}" |
|
512 |
|
set -e |
|
513 |
|
if [ "${E}" != "0" ]; then |
|
514 |
|
echo " not found." |
|
515 |
|
echo "s#@POLL_FOUND@#0#g" >> tmp.sed |
|
516 |
|
else |
|
517 |
|
echo " found." |
|
518 |
|
echo "s#@POLL_FOUND@#1#g" >> tmp.sed |
|
519 |
|
fi |
|
520 |
|
|
|
521 |
|
echo -n "[*] Searching for epoll..." |
|
522 |
|
set +e |
|
523 |
|
echo -e "#include <sys/epoll.h> \n int main(void) { return epoll_create(64); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
|
524 |
|
E="${?}" |
|
525 |
|
set -e |
|
526 |
|
if [ "${E}" != "0" ]; then |
|
527 |
|
echo " not found." |
|
528 |
|
echo "s#@EPOLL_FOUND@#0#g" >> tmp.sed |
|
529 |
|
else |
|
530 |
|
echo " found." |
|
531 |
|
echo "s#@EPOLL_FOUND@#1#g" >> tmp.sed |
|
532 |
|
fi |
|
533 |
|
|
|
534 |
|
echo -n "[*] Searching for ncurses..." |
|
535 |
|
set +e |
|
536 |
|
echo -e "#include <ncurses.h> \n int main(void) { initscr(); return 0; }" | gcc -x c -pipe - -o /dev/null -lncurses 2>/dev/null |
|
537 |
|
E="${?}" |
|
538 |
|
set -e |
|
539 |
|
if [ "${E}" != "0" ]; then |
|
540 |
|
echo " not found." |
|
541 |
|
echo "s#@NCURSES_FOUND@#0#g" >> tmp.sed |
|
542 |
|
else |
|
543 |
|
echo " found." |
|
544 |
|
echo "s#@NCURSES_FOUND@#1#g" >> tmp.sed |
|
545 |
|
fi |
|
546 |
|
|
|
547 |
|
if [ -n "${CC_SWITCHES}" ]; then |
|
548 |
|
_CC_SWITCHES="" |
|
549 |
|
echo "[*] Search for valid compiler flags..." |
|
550 |
|
add="" |
|
551 |
|
for s in ${CC_SWITCHES}; do |
|
552 |
|
echo -n " [*] Testing switch [${s}]..." |
|
553 |
|
set +e |
|
554 |
|
echo "int main(void) { return 0; }" | gcc ${s} -x c -pipe - -o /dev/null 2>/dev/null |
|
555 |
|
E=${?} |
|
556 |
|
set -e |
|
557 |
|
if [ "${E}" != "0" ]; then |
|
558 |
|
echo "not supported" |
|
559 |
|
else |
|
560 |
|
echo "supported" |
|
561 |
|
_CC_SWITCHES="${_CC_SWITCHES}${add}${s}" |
|
562 |
|
add=" " |
|
563 |
|
fi |
|
564 |
|
done |
|
565 |
|
fi |
|
566 |
|
|
|
567 |
|
# generic stuff |
|
568 |
|
echo "s#@PRJ@#${PRJ}#g" >> tmp.sed |
|
569 |
|
echo "s#@VER@#${VER}#g" >> tmp.sed |
|
570 |
|
echo "s#@REV@#${REV}#g" >> tmp.sed |
|
571 |
|
echo "s#@ETC@#${ETC}#g" >> tmp.sed |
|
572 |
|
echo "s#@BIN@#${BIN}#g" >> tmp.sed |
|
573 |
|
echo "s#@USR@#${USR}#g" >> tmp.sed |
|
574 |
|
echo "s#@USR_BIN@#${USR_BIN}#g" >> tmp.sed |
|
575 |
|
echo "s#@SBIN@#${SBIN}#g" >> tmp.sed |
|
576 |
|
echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed |
|
577 |
|
echo "s#@VAR@#${VAR}#g" >> tmp.sed |
|
578 |
|
echo "s#@VAR_LIB@#${VAR_LIB}#g" >> tmp.sed |
|
579 |
|
echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed |
|
580 |
|
echo "s#@VAR_RUN@#${VAR_RUN}#g" >> tmp.sed |
|
581 |
|
echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed |
|
582 |
|
echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed |
|
583 |
|
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed |
|
584 |
|
echo "s#@USR_SHARE@#${USR_SHARE}#g" >> tmp.sed |
|
585 |
|
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed |
|
586 |
|
echo "s#@MAN@#${MAN}#g" >> tmp.sed |
|
587 |
|
echo "s#@DUILDER_SYSTEMD@#${DUILDER_SYSTEMD}#g" >> tmp.sed |
|
588 |
|
# Export stuff |
|
589 |
|
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed |
|
590 |
|
# cc_switches |
|
591 |
|
echo "s#@CC_SWITCHES@#${_CC_SWITCHES}#g" >> tmp.sed |
|
592 |
|
echo "s#@MAINTAINER_NAME@#${MAINTAINER_NAME}#g" >> tmp.sed |
|
593 |
|
echo "s#@MAINTAINER_EMAIL@#${MAINTAINER_EMAIL}#g" >> tmp.sed |
|
594 |
|
echo "s#@SHORT_DESCRIPTION@#${SHORT_DESCRIPTION}#g" >> tmp.sed |
|
595 |
|
echo "s#@HOME_PAGE@#${HOME_PAGE}#g" >> tmp.sed |
|
596 |
|
|
|
597 |
|
|
|
598 |
|
|
|
599 |
|
if [ -r Makefile.in ]; then |
|
600 |
|
echo "[*] Building Makefile..." |
|
601 |
|
echo -n > Makefile |
|
602 |
|
echo "# duilder header starts #" >> Makefile |
|
603 |
|
echo "export PRJ := ${PRJ}" >> Makefile |
|
604 |
|
echo "export VER := ${VER}" >> Makefile |
|
605 |
|
echo "export REV := ${REV}" >> Makefile |
|
606 |
|
echo "export DESTDIR" >> Makefile |
|
607 |
|
echo >> Makefile |
|
608 |
|
echo "export I_ETC := \$(DESTDIR)${ETC}" >> Makefile |
|
609 |
|
echo "export I_BIN := \$(DESTDIR)${BIN}" >> Makefile |
|
610 |
|
echo "export I_SBIN := \$(DESTDIR)${SBIN}" >> Makefile |
|
611 |
|
echo "export I_USR := \$(DESTDIR)${USR}" >> Makefile |
|
612 |
|
echo "export I_USR_BIN := \$(DESTDIR)${USR_BIN}" >> Makefile |
|
613 |
|
echo "export I_USR_SBIN := \$(DESTDIR)${USR_SBIN}" >> Makefile |
|
614 |
|
echo "export I_USR_INCLUDE := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
|
615 |
|
echo "export I_USR_INC := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
|
616 |
|
echo "export I_USR_SHARE := \$(DESTDIR)${USR_SHARE}" >> Makefile |
|
617 |
|
echo "export I_USR_SHARE_DOC := \$(DESTDIR)${USR_SHARE_DOC}" >> Makefile |
|
618 |
|
echo "export I_USR_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
|
619 |
|
echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
|
620 |
|
echo "export I_VAR := \$(DESTDIR)${VAR}" >> Makefile |
|
621 |
|
echo "export I_VAR_LIB := \$(DESTDIR)${VAR_LIB}" >> Makefile |
|
622 |
|
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile |
|
623 |
|
echo "export I_VAR_RUN := \$(DESTDIR)${VAR_RUN}" >> Makefile |
|
624 |
|
echo "export I_MAN := \$(DESTDIR)${MAN}" >> Makefile |
|
625 |
|
echo "export I_DUILDER_SYSTEMD := \$(DESTDIR)${DUILDER_SYSTEMD}" >> Makefile |
|
626 |
|
echo >> Makefile |
|
627 |
|
echo "# DB stuff" >> Makefile |
|
628 |
|
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile |
|
629 |
|
echo "# PG" >> Makefile |
|
630 |
|
echo "export PG_FOUND := ${PG_FOUND}" >> Makefile |
|
631 |
|
echo "export PG_INC := ${PG_INC}" >> Makefile |
|
632 |
|
echo "export PG_LIB := ${PG_LIB}" >> Makefile |
|
633 |
|
echo "# MySQL" >> Makefile |
|
634 |
|
echo "export MYSQL_FOUND := ${MYSQL_FOUND}" >> Makefile |
|
635 |
|
echo "export MYSQL_INC := ${MYSQL_INC}" >> Makefile |
|
636 |
|
echo "export MYSQL_LIB := ${MYSQL_LIB}" >> Makefile |
|
637 |
|
echo >> Makefile |
|
638 |
|
echo "# duilder header ends #" >> Makefile |
|
639 |
|
echo >> Makefile |
|
640 |
|
|
|
641 |
|
sed -f tmp.sed Makefile.in >> Makefile |
|
642 |
|
|
|
643 |
|
echo >> Makefile |
|
644 |
|
echo "# duilder tail starts #" >> Makefile |
|
645 |
|
echo >> Makefile |
|
646 |
|
echo "# This is to allow exporting only the git tree" >> Makefile |
|
647 |
|
echo "dist_git:" >> Makefile |
|
648 |
|
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${EXPORT_PATH}\" \"${GIT_CHANGELOG}\"" >> Makefile |
|
649 |
|
echo >> Makefile |
|
650 |
|
echo "# This is to allow making the tar" >> Makefile |
|
651 |
|
echo "dist_tar:" >> Makefile |
|
652 |
|
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile |
|
653 |
|
echo >> Makefile |
|
654 |
|
echo "# This is to allow making rpm" >> Makefile |
|
655 |
|
echo "dist_srpm: dist_tar" >> Makefile |
|
656 |
|
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile |
|
657 |
|
echo >> Makefile |
|
658 |
|
echo ".PHONY: dist" >> Makefile |
|
659 |
|
echo "dist: clean" >> Makefile |
|
660 |
|
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${GIT_CHANGELOG}\"" \"${GIT_PUSH}\" >> Makefile |
|
661 |
|
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile |
|
662 |
|
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile |
|
663 |
|
echo " @./duilder sdeb \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SDEB}\" \"${SDEB_DEST}\" \"${SDEB_POST_RUN}\"" >> Makefile |
|
664 |
|
echo " @./duilder docs \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\"" >> Makefile |
|
665 |
|
echo " @./duilder final \"\$(PRJ)\" \"\$(VER)\" \"${RELEASE_SCRIPT}\"" >> Makefile |
|
666 |
|
echo " @rm -f \"\$(PRJ)-\$(VER).tar.gz\"" >> Makefile |
|
667 |
|
echo >> Makefile |
|
668 |
|
fi |
|
669 |
|
|
|
670 |
|
if [ -r "${PRJ}.spec.in" ]; then |
|
671 |
|
echo "[*] Generating .spec file..." |
|
672 |
|
sed -f tmp.sed ${PRJ}.spec.in > ${PRJ}.spec |
|
673 |
|
fi |
|
674 |
|
|
|
675 |
|
if [ ! -z "${CONFIG_H}" ]; then |
|
676 |
|
echo "[*] Generating ${CONFIG_H} file..." |
|
677 |
|
sed -f tmp.sed ${CONFIG_H}.in > ${CONFIG_H} |
|
678 |
|
fi |
|
679 |
|
|
|
680 |
|
if [ "${BUILD_SDEB}" = "1" ]; then |
|
681 |
|
AUTOGENERATE="${AUTOGENERATE} debian/control.in debian/changelog.in" |
|
682 |
|
AUTOGENERATE="${AUTOGENERATE} debian/copyright.in debian/rules.in" |
|
683 |
|
fi |
|
684 |
|
|
|
685 |
|
echo "[*] Autogenerate files from .in..." |
|
686 |
|
for f in ${AUTOGENERATE}; do |
|
687 |
|
if [ -r "${f}" ]; then |
|
688 |
|
dst="${f%.in}" |
|
689 |
|
echo " [*] Autogenerate ${dst} from ${f}..." |
|
690 |
|
sed -f tmp.sed "${f}" > "${dst}" |
|
691 |
|
# We need to have the same rights (maybe is executable...) |
|
692 |
|
chmod --reference="${f}" "${dst}" |
|
693 |
|
fi |
|
694 |
|
done |
|
695 |
|
|
|
696 |
|
rm -f tmp.sed |
|
697 |
|
|
|
698 |
|
if [ "`basename ${0}`" = "duilderx" ]; then |
|
699 |
|
echo "[*] Cloning myself to destination as 'duilder'..." |
|
700 |
|
cp -vpf "${0}" ${PWD}/duilder |
|
701 |
|
fi |
|
702 |
|
|
|
703 |
|
echo "[*] Done. Run make." |
File rgfs.c added (mode: 100644) (index 0000000..67e54d0) |
|
1 |
|
/* |
|
2 |
|
* rgfs project |
|
3 |
|
* Main GNUTLS code was borrowed from their public domain example. Thank you! |
|
4 |
|
*/ |
|
5 |
|
|
|
6 |
|
#include "rgfs_config.h" |
|
7 |
|
|
|
8 |
|
#include <sys/types.h> |
|
9 |
|
#include <sys/socket.h> |
|
10 |
|
#include <sys/stat.h> |
|
11 |
|
#include <netdb.h> |
|
12 |
|
#include <unistd.h> |
|
13 |
|
#include <stdio.h> |
|
14 |
|
#include <stdlib.h> |
|
15 |
|
#include <string.h> |
|
16 |
|
#include <errno.h> |
|
17 |
|
#include <endian.h> |
|
18 |
|
|
|
19 |
|
#include <fuse.h> |
|
20 |
|
|
|
21 |
|
#include <gnutls/gnutls.h> |
|
22 |
|
#include <gnutls/x509.h> |
|
23 |
|
|
|
24 |
|
#if 0 |
|
25 |
|
static int rgfs_port = 443; |
|
26 |
|
static const char *rgfs_server = "rocketgit.com"; // TODO: switch to rgfs.rocketgit.com |
|
27 |
|
static char *rgfs_url = "/rgfs"; |
|
28 |
|
#else |
|
29 |
|
static int rgfs_port = 8443; |
|
30 |
|
static const char *rgfs_server = "cloud.embedromix.ro"; // TODO: switch to rgfs.rocketgit.com |
|
31 |
|
static char *rgfs_url = "/rgfs"; |
|
32 |
|
#endif |
|
33 |
|
|
|
34 |
|
static gnutls_session_t session; |
|
35 |
|
static unsigned char connected = 0; |
|
36 |
|
static int sd = -1; |
|
37 |
|
static gnutls_certificate_credentials_t xcred; |
|
38 |
|
|
|
39 |
|
|
|
40 |
|
/* |
|
41 |
|
* Receiving data |
|
42 |
|
*/ |
|
43 |
|
static ssize_t rgfs_recv(void *buf, const size_t buf_max) |
|
44 |
|
{ |
|
45 |
|
ssize_t r; |
|
46 |
|
|
|
47 |
|
do { |
|
48 |
|
r = gnutls_record_recv(session, buf, buf_max); |
|
49 |
|
} while ((r == GNUTLS_E_AGAIN) || (r == GNUTLS_E_INTERRUPTED)); |
|
50 |
|
|
|
51 |
|
if (r < 0) |
|
52 |
|
fprintf(stderr, "Cannot receive [%zd]!\n", r); |
|
53 |
|
|
|
54 |
|
return r; |
|
55 |
|
} |
|
56 |
|
|
|
57 |
|
/* |
|
58 |
|
* Sending data |
|
59 |
|
*/ |
|
60 |
|
static ssize_t rgfs_send(const void *buf, size_t buf_len) |
|
61 |
|
{ |
|
62 |
|
ssize_t r; |
|
63 |
|
|
|
64 |
|
do { |
|
65 |
|
r = gnutls_record_send(session, buf, buf_len); |
|
66 |
|
} while ((r == GNUTLS_E_AGAIN) || (r == GNUTLS_E_INTERRUPTED)); |
|
67 |
|
|
|
68 |
|
if (r < 0) { |
|
69 |
|
fprintf(stderr, "Cannot send [%zd]!\n", r); |
|
70 |
|
exit(EXIT_FAILURE); |
|
71 |
|
} else if ((size_t) r < buf_len) { |
|
72 |
|
fprintf(stderr, "Invalid send r=%ld < buf_len=%zu!\n", r, buf_len); |
|
73 |
|
exit(EXIT_FAILURE); |
|
74 |
|
} |
|
75 |
|
|
|
76 |
|
return r; |
|
77 |
|
} |
|
78 |
|
|
|
79 |
|
/* |
|
80 |
|
* Connect to server |
|
81 |
|
*/ |
|
82 |
|
static int rgfs_connect(void) |
|
83 |
|
{ |
|
84 |
|
int r, fd; |
|
85 |
|
struct addrinfo hints; |
|
86 |
|
struct addrinfo *result, *rp; |
|
87 |
|
char port[6]; |
|
88 |
|
|
|
89 |
|
snprintf(port, sizeof(port), "%d", rgfs_port); |
|
90 |
|
|
|
91 |
|
memset(&hints, 0, sizeof(hints)); |
|
92 |
|
hints.ai_family = AF_UNSPEC; |
|
93 |
|
hints.ai_socktype = SOCK_STREAM; |
|
94 |
|
r = getaddrinfo(rgfs_server, port, &hints, &result); |
|
95 |
|
if (r != 0) { |
|
96 |
|
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(r)); |
|
97 |
|
return -1; |
|
98 |
|
} |
|
99 |
|
|
|
100 |
|
for (rp = result; rp != NULL; rp = rp->ai_next) { |
|
101 |
|
fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); |
|
102 |
|
if (fd == -1) |
|
103 |
|
continue; |
|
104 |
|
|
|
105 |
|
r = connect(fd, rp->ai_addr, rp->ai_addrlen); |
|
106 |
|
if (r != -1) { |
|
107 |
|
char ip[49], service[NI_MAXSERV]; |
|
108 |
|
|
|
109 |
|
r = getnameinfo((struct sockaddr *) rp->ai_addr, rp->ai_addrlen, |
|
110 |
|
ip, sizeof(ip), service, sizeof(service), |
|
111 |
|
NI_NUMERICHOST | NI_NUMERICSERV); |
|
112 |
|
if (r == 0) |
|
113 |
|
fprintf(stderr, "Connected to %s/%s!\n", ip, service); |
|
114 |
|
break; |
|
115 |
|
} |
|
116 |
|
|
|
117 |
|
fprintf(stderr, "connect error: %m\n"); |
|
118 |
|
} |
|
119 |
|
freeaddrinfo(result); |
|
120 |
|
if (rp == NULL) { |
|
121 |
|
fprintf(stderr, "Could not connect!\n"); |
|
122 |
|
return -1; |
|
123 |
|
} |
|
124 |
|
|
|
125 |
|
return fd; |
|
126 |
|
} |
|
127 |
|
|
|
128 |
|
/* |
|
129 |
|
* Send first websocket negotiation |
|
130 |
|
*/ |
|
131 |
|
static ssize_t rgfs_ws1(void) |
|
132 |
|
{ |
|
133 |
|
char out[4096]; |
|
134 |
|
int len; |
|
135 |
|
|
|
136 |
|
len = snprintf(out, sizeof(out), |
|
137 |
|
"GET %s HTTP/1.1\r\n" |
|
138 |
|
"Host: %s:%d\r\n" |
|
139 |
|
"Connection: keep-alive, Upgrade\r\n" |
|
140 |
|
"Pragma: no-cache\r\n" |
|
141 |
|
"Cache-Control: no-cache\r\n" |
|
142 |
|
"Upgrade: websocket\r\n" |
|
143 |
|
"\r\n", |
|
144 |
|
rgfs_url, rgfs_server, rgfs_port); |
|
145 |
|
|
|
146 |
|
//fprintf(stderr, "Sending:\n%s", out); |
|
147 |
|
return rgfs_send(out, len); |
|
148 |
|
} |
|
149 |
|
|
|
150 |
|
static int rgfs_tls(void) |
|
151 |
|
{ |
|
152 |
|
int r, ret = -1, off; |
|
153 |
|
char buf[8192], *desc; |
|
154 |
|
int type; |
|
155 |
|
unsigned status; |
|
156 |
|
|
|
157 |
|
while (1) { |
|
158 |
|
/* Destroy session */ |
|
159 |
|
fprintf(stderr, "session=%p sd=%d\n", session, sd); |
|
160 |
|
if (session) { |
|
161 |
|
r = gnutls_bye(session, GNUTLS_SHUT_RDWR); |
|
162 |
|
if (r != GNUTLS_E_SUCCESS) |
|
163 |
|
fprintf(stderr, "gnutls error: cannot say goodbye!\n"); |
|
164 |
|
} |
|
165 |
|
|
|
166 |
|
if (sd != -1) |
|
167 |
|
close(sd); |
|
168 |
|
|
|
169 |
|
gnutls_deinit(session); |
|
170 |
|
|
|
171 |
|
/* Initialize TLS session */ |
|
172 |
|
r = gnutls_init(&session, GNUTLS_CLIENT); |
|
173 |
|
if (r != GNUTLS_E_SUCCESS) { |
|
174 |
|
fprintf(stderr, "gnutls error: cannot init session!\n"); |
|
175 |
|
break; |
|
176 |
|
} |
|
177 |
|
|
|
178 |
|
r = gnutls_server_name_set(session, GNUTLS_NAME_DNS, |
|
179 |
|
rgfs_server, strlen(rgfs_server)); |
|
180 |
|
if (r != GNUTLS_E_SUCCESS) { |
|
181 |
|
fprintf(stderr, "gnutls error: cannot set name [%s]!\n", rgfs_server); |
|
182 |
|
break; |
|
183 |
|
} |
|
184 |
|
|
|
185 |
|
/* It is recommended to use the default priorities */ |
|
186 |
|
r = gnutls_set_default_priority(session); |
|
187 |
|
if (r != GNUTLS_E_SUCCESS) { |
|
188 |
|
fprintf(stderr, "gnutls error: cannot set default priority!\n"); |
|
189 |
|
break; |
|
190 |
|
} |
|
191 |
|
|
|
192 |
|
/* put the x509 credentials to the current session */ |
|
193 |
|
r = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); |
|
194 |
|
if (r != GNUTLS_E_SUCCESS) { |
|
195 |
|
fprintf(stderr, "gnutls error: cannot set credentials!\n"); |
|
196 |
|
break; |
|
197 |
|
} |
|
198 |
|
gnutls_session_set_verify_cert(session, rgfs_server, 0); |
|
199 |
|
// TODO - no error code? |
|
200 |
|
|
|
201 |
|
sd = rgfs_connect(); |
|
202 |
|
if (sd == -1) |
|
203 |
|
break; |
|
204 |
|
|
|
205 |
|
gnutls_transport_set_int(session, sd); |
|
206 |
|
gnutls_handshake_set_timeout(session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT); |
|
207 |
|
|
|
208 |
|
/* Perform the TLS handshake */ |
|
209 |
|
do { |
|
210 |
|
r = gnutls_handshake(session); |
|
211 |
|
} while (r < 0 && gnutls_error_is_fatal(r) == 0); |
|
212 |
|
if (r < 0) { |
|
213 |
|
if (r == GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR) { |
|
214 |
|
gnutls_datum_t out; |
|
215 |
|
|
|
216 |
|
/* check certificate verification status */ |
|
217 |
|
type = gnutls_certificate_type_get(session); |
|
218 |
|
status = gnutls_session_get_verify_cert_status(session); |
|
219 |
|
r = gnutls_certificate_verification_status_print(status, type, &out, 0); |
|
220 |
|
if (r == GNUTLS_E_SUCCESS) { |
|
221 |
|
fprintf(stderr, "cert verify output: %s\n", out.data); |
|
222 |
|
gnutls_free(out.data); |
|
223 |
|
} |
|
224 |
|
} |
|
225 |
|
fprintf(stderr, "Handshake failed: %s\n", gnutls_strerror(r)); |
|
226 |
|
break; |
|
227 |
|
} |
|
228 |
|
|
|
229 |
|
desc = gnutls_session_get_desc(session); |
|
230 |
|
fprintf(stderr, "Session info: %s\n", desc); |
|
231 |
|
gnutls_free(desc); |
|
232 |
|
|
|
233 |
|
r = rgfs_ws1(); |
|
234 |
|
if (r == -1) |
|
235 |
|
break; |
|
236 |
|
//fprintf(stderr, "ws1 returned %d.\n", r); |
|
237 |
|
|
|
238 |
|
off = 0; |
|
239 |
|
while (1) { |
|
240 |
|
r = rgfs_recv(buf + off, sizeof(buf) - off - 1); |
|
241 |
|
if (r <= 0) |
|
242 |
|
break; |
|
243 |
|
|
|
244 |
|
buf[off + r] = '\0'; |
|
245 |
|
//fprintf(stderr, "Received[%d + %d]:\n%s\n", off, r, buf); |
|
246 |
|
if (strstr(buf, "\r\n\r\n")) |
|
247 |
|
break; |
|
248 |
|
} |
|
249 |
|
if (r == -1) |
|
250 |
|
break; |
|
251 |
|
if (strncmp(buf, "HTTP/1.1 101 Switching Protocols", 32) != 0) { |
|
252 |
|
fprintf(stderr, "Invalid HTTP answer:\n%s\n", buf); |
|
253 |
|
break; |
|
254 |
|
} |
|
255 |
|
|
|
256 |
|
fprintf(stderr, "Sending version...\n"); |
|
257 |
|
buf[0] = 0x01; // type=SEND_VERSION |
|
258 |
|
buf[1] = 0; // len |
|
259 |
|
buf[2] = 1; // len |
|
260 |
|
buf[3] = RGFS_PROTOCOL_VERSION; |
|
261 |
|
r = rgfs_send(buf, 4); |
|
262 |
|
if (r <= 0) |
|
263 |
|
break; |
|
264 |
|
|
|
265 |
|
fprintf(stderr, "Receiving version...\n"); |
|
266 |
|
r = rgfs_recv(buf, sizeof(buf)); |
|
267 |
|
if (r <= 0) |
|
268 |
|
break; |
|
269 |
|
fprintf(stderr, "Server version: %hhu.\n", buf[4]); |
|
270 |
|
|
|
271 |
|
ret = 0; |
|
272 |
|
break; |
|
273 |
|
} |
|
274 |
|
|
|
275 |
|
return ret; |
|
276 |
|
} |
|
277 |
|
|
|
278 |
|
static void rgfs_reconnect(void) |
|
279 |
|
{ |
|
280 |
|
int r; |
|
281 |
|
|
|
282 |
|
while (1) { |
|
283 |
|
fprintf(stderr, "Reconnecting...\n"); |
|
284 |
|
r = rgfs_tls(); |
|
285 |
|
if (r == 0) { |
|
286 |
|
fprintf(stderr, " Reconnecting OK!\n"); |
|
287 |
|
connected = 1; |
|
288 |
|
break; |
|
289 |
|
} |
|
290 |
|
|
|
291 |
|
fprintf(stderr, "Sleeping...\n"); |
|
292 |
|
sleep(1); |
|
293 |
|
} |
|
294 |
|
} |
|
295 |
|
|
|
296 |
|
static int rgfs_recv_hl(void *buf, size_t buf_size) |
|
297 |
|
{ |
|
298 |
|
int r; |
|
299 |
|
uint32_t off, to_read = 0; |
|
300 |
|
|
|
301 |
|
off = 0; |
|
302 |
|
while (1) { |
|
303 |
|
//fprintf(stderr, " Waiting for data (off=%d to_read=%u)\n", off, to_read); |
|
304 |
|
if (off == buf_size) { |
|
305 |
|
fprintf(stderr, "Buffer is too small!\n"); |
|
306 |
|
exit(EXIT_FAILURE); |
|
307 |
|
} |
|
308 |
|
r = rgfs_recv(buf + off, buf_size - off); |
|
309 |
|
if (r <= 0) |
|
310 |
|
return r; |
|
311 |
|
|
|
312 |
|
off += r; |
|
313 |
|
if (off >= 4) |
|
314 |
|
to_read = be32toh(*(uint32_t *) buf); |
|
315 |
|
|
|
316 |
|
#if 0 |
|
317 |
|
fprintf(stderr, " RECV: "); |
|
318 |
|
for (unsigned int i = 0; i < off; i++) |
|
319 |
|
fprintf(stderr, "%02hhx", * (unsigned char *) (buf + i)); |
|
320 |
|
fprintf(stderr, "\n"); |
|
321 |
|
#endif |
|
322 |
|
|
|
323 |
|
if (off == 4 + to_read) { |
|
324 |
|
//fprintf(stderr, " Readed 4 + %u\n", to_read); |
|
325 |
|
return off; |
|
326 |
|
} |
|
327 |
|
} |
|
328 |
|
} |
|
329 |
|
|
|
330 |
|
static ssize_t rgfs_send_recv(const void *out_buf, size_t out_buf_len, |
|
331 |
|
void *in_buf, size_t in_buf_size) |
|
332 |
|
{ |
|
333 |
|
int r; |
|
334 |
|
|
|
335 |
|
if (connected == 0) |
|
336 |
|
rgfs_reconnect(); |
|
337 |
|
|
|
338 |
|
while (1) { |
|
339 |
|
//fprintf(stderr, " Sending %zu bytes\n", out_buf_len); |
|
340 |
|
r = rgfs_send(out_buf, out_buf_len); |
|
341 |
|
if (r <= 0) { |
|
342 |
|
rgfs_reconnect(); |
|
343 |
|
continue; |
|
344 |
|
} |
|
345 |
|
|
|
346 |
|
r = rgfs_recv_hl(in_buf, in_buf_size); |
|
347 |
|
if (r <= 0) { |
|
348 |
|
rgfs_reconnect(); |
|
349 |
|
continue; |
|
350 |
|
} |
|
351 |
|
|
|
352 |
|
return r; |
|
353 |
|
} |
|
354 |
|
} |
|
355 |
|
|
|
356 |
|
///////////////////////////////////////////////////////////////////// fuse stuff |
|
357 |
|
|
|
358 |
|
|
|
359 |
|
static int rgfs_fuse_getattr(const char *path, struct stat *s) |
|
360 |
|
{ |
|
361 |
|
int r, i, err = 0; |
|
362 |
|
unsigned char buf[4 * 4096], cmd; |
|
363 |
|
uint16_t path_len, len; |
|
364 |
|
|
|
365 |
|
//fprintf(stderr, "getattr: path=%s\n", path); |
|
366 |
|
|
|
367 |
|
path_len = strlen(path); |
|
368 |
|
len = 1 + 2 + path_len; |
|
369 |
|
if (len > sizeof(buf)) { |
|
370 |
|
fprintf(stderr, " buffer too small\n"); |
|
371 |
|
return -EIO; |
|
372 |
|
} |
|
373 |
|
|
|
374 |
|
i = 0; |
|
375 |
|
buf[i++] = 0x02; |
|
376 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
377 |
|
buf[i++] = len - 1 - 2; |
|
378 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
379 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
380 |
|
|
|
381 |
|
memset(s, 0, sizeof(struct stat)); |
|
382 |
|
i = 4; |
|
383 |
|
while (i < r) { |
|
384 |
|
cmd = buf[i++]; |
|
385 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
386 |
|
switch (cmd) { |
|
387 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
388 |
|
case 0x01: s->st_mode = be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
389 |
|
case 0x02: s->st_nlink = be64toh(*(uint64_t *) (buf + i)); i += 8; break; |
|
390 |
|
case 0x03: s->st_size = be64toh(*(uint64_t *) (buf + i)); i += 8; break; |
|
391 |
|
case 0x04: s->st_atime = be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
392 |
|
case 0x05: s->st_mtime = be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
393 |
|
case 0x06: s->st_ctime = be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
394 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
395 |
|
} |
|
396 |
|
} |
|
397 |
|
|
|
398 |
|
if (err != 0) { |
|
399 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
400 |
|
return err; |
|
401 |
|
} |
|
402 |
|
|
|
403 |
|
//fprintf(stderr, " mode=%o nlink=%lu size=%lu\n", |
|
404 |
|
// s->st_mode, s->st_nlink, s->st_size); |
|
405 |
|
return 0; |
|
406 |
|
} |
|
407 |
|
|
|
408 |
|
static int rgfs_fuse_readdir(const char *dir, void *out, |
|
409 |
|
fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) |
|
410 |
|
{ |
|
411 |
|
int r, ret, i, err = 0; |
|
412 |
|
unsigned char buf[4 * 4096], cmd; |
|
413 |
|
uint16_t u16, path_len, len; |
|
414 |
|
char path[512]; |
|
415 |
|
uint64_t u64; |
|
416 |
|
|
|
417 |
|
(void) offset; |
|
418 |
|
(void) fi; |
|
419 |
|
//fprintf(stderr, "readdir: dir=%s offset=%zd\n", dir, offset); |
|
420 |
|
|
|
421 |
|
path_len = strlen(dir); |
|
422 |
|
len = 1 + 2 + 8 + path_len; |
|
423 |
|
if (len > sizeof(buf)) { |
|
424 |
|
fprintf(stderr, " buffer too small\n"); |
|
425 |
|
return -EIO; |
|
426 |
|
} |
|
427 |
|
|
|
428 |
|
i = 0; |
|
429 |
|
buf[i++] = 0x03; |
|
430 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
431 |
|
buf[i++] = len - 1 - 2; |
|
432 |
|
u64 = htobe64(offset); memcpy(buf + i, &u64, 8); i += 8; |
|
433 |
|
memcpy(buf + i, dir, path_len); i += path_len; |
|
434 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
435 |
|
|
|
436 |
|
// standard |
|
437 |
|
filler(out, ".", NULL, 0); |
|
438 |
|
filler(out, "..", NULL, 0); |
|
439 |
|
|
|
440 |
|
i = 4; |
|
441 |
|
while (i < r) { |
|
442 |
|
cmd = buf[i++]; |
|
443 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
444 |
|
switch (cmd) { |
|
445 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
446 |
|
case 0x01: /* entry */ |
|
447 |
|
u16 = be16toh(*(uint16_t *) (buf + i)); i += 2; |
|
448 |
|
if (u16 > sizeof(path) - 1) { |
|
449 |
|
fprintf(stderr, "path len bigger than buf!\n"); |
|
450 |
|
i += u16; |
|
451 |
|
break; |
|
452 |
|
} |
|
453 |
|
memcpy(path, buf + i, u16); i += u16; |
|
454 |
|
path[u16] = '\0'; |
|
455 |
|
//fprintf(stderr, " received path %s\n", path); |
|
456 |
|
ret = filler(out, path, NULL, 0); |
|
457 |
|
if (ret != 0) |
|
458 |
|
fprintf(stderr, " FILLTER RETURNS 1!\n"); |
|
459 |
|
break; |
|
460 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
461 |
|
} |
|
462 |
|
} |
|
463 |
|
|
|
464 |
|
if (err != 0) { |
|
465 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
466 |
|
return err; |
|
467 |
|
} |
|
468 |
|
|
|
469 |
|
return 0; |
|
470 |
|
} |
|
471 |
|
|
|
472 |
|
static int rgfs_fuse_open(const char *path, struct fuse_file_info *fi) |
|
473 |
|
{ |
|
474 |
|
(void) path; |
|
475 |
|
(void) fi; |
|
476 |
|
//fprintf(stderr, "open: path=%s\n", path); |
|
477 |
|
|
|
478 |
|
//if ((fi->flags & O_ACCMODE) != O_RDONLY) |
|
479 |
|
// return -EACCES; |
|
480 |
|
|
|
481 |
|
return 0; |
|
482 |
|
} |
|
483 |
|
|
|
484 |
|
static int rgfs_fuse_create(const char *path, mode_t mode, |
|
485 |
|
struct fuse_file_info *fi) |
|
486 |
|
{ |
|
487 |
|
int err = 0, r, i; |
|
488 |
|
uint16_t u16, path_len, len; |
|
489 |
|
unsigned char buf[4 * 4096], cmd; |
|
490 |
|
|
|
491 |
|
(void) mode; |
|
492 |
|
(void) fi; |
|
493 |
|
//fprintf(stderr, "create: path=%s\n", path); |
|
494 |
|
|
|
495 |
|
path_len = strlen(path); |
|
496 |
|
len = 1 + 2 + 2 + path_len; |
|
497 |
|
if (len > sizeof(buf)) { |
|
498 |
|
fprintf(stderr, " buffer too small\n"); |
|
499 |
|
return -EIO; |
|
500 |
|
} |
|
501 |
|
|
|
502 |
|
i = 0; |
|
503 |
|
buf[i++] = 0x06; |
|
504 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
505 |
|
buf[i++] = len - 1 - 2; |
|
506 |
|
u16 = htobe16(path_len); memcpy(buf + i, &u16, 2); i += 2; |
|
507 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
508 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
509 |
|
|
|
510 |
|
i = 4; |
|
511 |
|
while (i < r) { |
|
512 |
|
cmd = buf[i++]; |
|
513 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
514 |
|
switch (cmd) { |
|
515 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
516 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
517 |
|
} |
|
518 |
|
} |
|
519 |
|
|
|
520 |
|
if (err != 0) { |
|
521 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
522 |
|
return err; |
|
523 |
|
} |
|
524 |
|
|
|
525 |
|
return 0; |
|
526 |
|
} |
|
527 |
|
|
|
528 |
|
static int rgfs_fuse_mkdir(const char *path, mode_t mode) |
|
529 |
|
{ |
|
530 |
|
int err = 0, r, i; |
|
531 |
|
uint16_t u16, path_len, len; |
|
532 |
|
unsigned char buf[4 * 4096], cmd; |
|
533 |
|
|
|
534 |
|
(void) mode; |
|
535 |
|
//fprintf(stderr, "mkdir: path=%s\n", path); |
|
536 |
|
|
|
537 |
|
path_len = strlen(path); |
|
538 |
|
len = 1 + 2 + 2 + path_len; |
|
539 |
|
if (len > sizeof(buf)) { |
|
540 |
|
fprintf(stderr, " buffer too small\n"); |
|
541 |
|
return -EIO; |
|
542 |
|
} |
|
543 |
|
|
|
544 |
|
i = 0; |
|
545 |
|
buf[i++] = 0x07; |
|
546 |
|
buf[i++] = (2 + path_len) / 256; |
|
547 |
|
buf[i++] = 2 + path_len; |
|
548 |
|
u16 = htobe16(path_len); memcpy(buf + i, &u16, 2); i += 2; |
|
549 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
550 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
551 |
|
|
|
552 |
|
i = 4; |
|
553 |
|
while (i < r) { |
|
554 |
|
cmd = buf[i++]; |
|
555 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
556 |
|
switch (cmd) { |
|
557 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
558 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
559 |
|
} |
|
560 |
|
} |
|
561 |
|
|
|
562 |
|
if (err != 0) { |
|
563 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
564 |
|
return err; |
|
565 |
|
} |
|
566 |
|
|
|
567 |
|
return 0; |
|
568 |
|
} |
|
569 |
|
|
|
570 |
|
static int rgfs_fuse_unlink(const char *path) |
|
571 |
|
{ |
|
572 |
|
int err = 0, r, i; |
|
573 |
|
uint16_t u16, path_len, len; |
|
574 |
|
unsigned char buf[4 * 4096], cmd; |
|
575 |
|
|
|
576 |
|
//fprintf(stderr, "unlink: path=%s\n", path); |
|
577 |
|
|
|
578 |
|
path_len = strlen(path); |
|
579 |
|
len = 1 + 2 + 2 + path_len; |
|
580 |
|
if (len > sizeof(buf)) { |
|
581 |
|
fprintf(stderr, " buffer too small\n"); |
|
582 |
|
return -EIO; |
|
583 |
|
} |
|
584 |
|
|
|
585 |
|
i = 0; |
|
586 |
|
buf[i++] = 0x08; |
|
587 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
588 |
|
buf[i++] = len - 1 - 2; |
|
589 |
|
u16 = htobe16(path_len); memcpy(buf + i, &u16, 2); i += 2; |
|
590 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
591 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
592 |
|
|
|
593 |
|
i = 4; |
|
594 |
|
while (i < r) { |
|
595 |
|
cmd = buf[i++]; |
|
596 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
597 |
|
switch (cmd) { |
|
598 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
599 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
600 |
|
} |
|
601 |
|
} |
|
602 |
|
|
|
603 |
|
if (err != 0) { |
|
604 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
605 |
|
return err; |
|
606 |
|
} |
|
607 |
|
|
|
608 |
|
return 0; |
|
609 |
|
} |
|
610 |
|
|
|
611 |
|
static int rgfs_fuse_rmdir(const char *path) |
|
612 |
|
{ |
|
613 |
|
int err = 0, r, i; |
|
614 |
|
uint16_t u16, path_len, len; |
|
615 |
|
unsigned char buf[4096], cmd; |
|
616 |
|
|
|
617 |
|
//fprintf(stderr, "rmdir: path=%s\n", path); |
|
618 |
|
|
|
619 |
|
path_len = strlen(path); |
|
620 |
|
len = 1 + 2 + 2 + path_len; |
|
621 |
|
if (len > sizeof(buf)) { |
|
622 |
|
fprintf(stderr, " buffer too small\n"); |
|
623 |
|
return -EIO; |
|
624 |
|
} |
|
625 |
|
|
|
626 |
|
i = 0; |
|
627 |
|
buf[i++] = 0x09; |
|
628 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
629 |
|
buf[i++] = len - 1 - 2; |
|
630 |
|
u16 = htobe16(path_len); memcpy(buf + i, &u16, 2); i += 2; |
|
631 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
632 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
633 |
|
|
|
634 |
|
i = 4; |
|
635 |
|
while (i < r) { |
|
636 |
|
cmd = buf[i++]; |
|
637 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
638 |
|
switch (cmd) { |
|
639 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
640 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
641 |
|
} |
|
642 |
|
} |
|
643 |
|
|
|
644 |
|
if (err != 0) { |
|
645 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
646 |
|
return err; |
|
647 |
|
} |
|
648 |
|
|
|
649 |
|
return 0; |
|
650 |
|
} |
|
651 |
|
|
|
652 |
|
static int rgfs_fuse_truncate(const char *path, off_t off) |
|
653 |
|
{ |
|
654 |
|
int err = 0, r, i; |
|
655 |
|
uint16_t u16, path_len, len; |
|
656 |
|
uint64_t u64; |
|
657 |
|
unsigned char buf[4096], cmd; |
|
658 |
|
|
|
659 |
|
//fprintf(stderr, "truncate: path=%s off=%ld\n", path, off); |
|
660 |
|
|
|
661 |
|
path_len = strlen(path); |
|
662 |
|
len = 1 + 2 + 2 + 8 + path_len; |
|
663 |
|
if (len > sizeof(buf)) { |
|
664 |
|
fprintf(stderr, " buffer too small\n"); |
|
665 |
|
return -EIO; |
|
666 |
|
} |
|
667 |
|
|
|
668 |
|
i = 0; |
|
669 |
|
buf[i++] = 0x0b; |
|
670 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
671 |
|
buf[i++] = len - 1 - 2; |
|
672 |
|
u16 = htobe16(path_len); memcpy(buf + i, &u16, 2); i += 2; |
|
673 |
|
u64 = htobe64(off); memcpy(buf + i, &u64, 8); i += 8; |
|
674 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
675 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
676 |
|
|
|
677 |
|
i = 4; |
|
678 |
|
while (i < r) { |
|
679 |
|
cmd = buf[i++]; |
|
680 |
|
fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
681 |
|
switch (cmd) { |
|
682 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
683 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
684 |
|
} |
|
685 |
|
} |
|
686 |
|
|
|
687 |
|
if (err != 0) { |
|
688 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
689 |
|
return err; |
|
690 |
|
} |
|
691 |
|
|
|
692 |
|
return 0; |
|
693 |
|
} |
|
694 |
|
|
|
695 |
|
static int rgfs_fuse_read(const char *path, char *out, size_t size, |
|
696 |
|
off_t offset, struct fuse_file_info *fi) |
|
697 |
|
{ |
|
698 |
|
int r, err = 0, i; |
|
699 |
|
unsigned char buf[16 * 4096], cmd; |
|
700 |
|
uint16_t path_len, len; |
|
701 |
|
uint64_t u64; |
|
702 |
|
|
|
703 |
|
(void) fi; |
|
704 |
|
//fprintf(stderr, "read: path=%s size=%zu offset=%zd\n", |
|
705 |
|
// path, size, offset); |
|
706 |
|
|
|
707 |
|
if (size > sizeof(buf) - 1 - 4 - 1 - 8) |
|
708 |
|
size = sizeof(buf) - 1 - 4 - 1 - 8; |
|
709 |
|
|
|
710 |
|
path_len = strlen(path); |
|
711 |
|
len = 1 + 2 + 8 + 8 + path_len; |
|
712 |
|
if (len > sizeof(buf)) { |
|
713 |
|
fprintf(stderr, " buffer too small\n"); |
|
714 |
|
return -EIO; |
|
715 |
|
} |
|
716 |
|
|
|
717 |
|
i = 0; |
|
718 |
|
buf[i++] = 0x04; |
|
719 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
720 |
|
buf[i++] = len - 1 - 2; |
|
721 |
|
u64 = htobe64(offset); memcpy(buf + i, &u64, 8); i += 8; |
|
722 |
|
u64 = htobe64(size); memcpy(buf + i, &u64, 8); i += 8; |
|
723 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
724 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
725 |
|
|
|
726 |
|
i = 4; |
|
727 |
|
while (i < r) { |
|
728 |
|
cmd = buf[i++]; |
|
729 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
730 |
|
switch (cmd) { |
|
731 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
732 |
|
case 0x01: /* block */ |
|
733 |
|
u64 = be64toh(*(uint64_t *) (buf + i)); i += 8; |
|
734 |
|
//fprintf(stderr, " received %lu bytes block\n", u64); |
|
735 |
|
if (i + u64 > (unsigned int) r) { |
|
736 |
|
fprintf(stderr, " i=%d + u64=%lu > r=%d\n", |
|
737 |
|
i, u64, r); |
|
738 |
|
i += u64; |
|
739 |
|
break; |
|
740 |
|
} |
|
741 |
|
memcpy(out, buf + i, u64); i += u64; |
|
742 |
|
break; |
|
743 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
744 |
|
} |
|
745 |
|
} |
|
746 |
|
|
|
747 |
|
if (err != 0) { |
|
748 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
749 |
|
return err; |
|
750 |
|
} |
|
751 |
|
|
|
752 |
|
return u64; |
|
753 |
|
} |
|
754 |
|
|
|
755 |
|
static int rgfs_fuse_write(const char *path, const char *in, size_t size, |
|
756 |
|
off_t offset, struct fuse_file_info *fi) |
|
757 |
|
{ |
|
758 |
|
int r, err = 0, i; |
|
759 |
|
unsigned char buf[4 * 4096], cmd; |
|
760 |
|
uint16_t u16, path_len, len; |
|
761 |
|
uint64_t u64; |
|
762 |
|
|
|
763 |
|
(void) fi; |
|
764 |
|
|
|
765 |
|
#if 0 |
|
766 |
|
fprintf(stderr, "write: path=%s size=%zu offset=%zd: ", path, size, offset); |
|
767 |
|
for (unsigned int j = 0; j < 32; j++) |
|
768 |
|
fprintf(stderr, "%02hhx", in[j]); |
|
769 |
|
fprintf(stderr, "\n"); |
|
770 |
|
#endif |
|
771 |
|
|
|
772 |
|
path_len = strlen(path); |
|
773 |
|
len = 1 + 2 + 2 + 8 + path_len + size; |
|
774 |
|
if (len > sizeof(buf)) { |
|
775 |
|
fprintf(stderr, " buffer too small\n"); |
|
776 |
|
return -EIO; |
|
777 |
|
} |
|
778 |
|
|
|
779 |
|
i = 0; |
|
780 |
|
buf[i++] = 0x05; |
|
781 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
782 |
|
buf[i++] = len - 1 - 2; |
|
783 |
|
u16 = htobe16(path_len); memcpy(buf + i, &u16, 2); i += 2; |
|
784 |
|
u64 = htobe64(offset); memcpy(buf + i, &u64, 8); i += 8; |
|
785 |
|
memcpy(buf + i, path, path_len); i += path_len; |
|
786 |
|
memcpy(buf + i, in, size); i += size; |
|
787 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
788 |
|
|
|
789 |
|
i = 4; |
|
790 |
|
while (i < r) { |
|
791 |
|
cmd = buf[i++]; |
|
792 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
793 |
|
switch (cmd) { |
|
794 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
795 |
|
case 0x01: /* block */ |
|
796 |
|
u64 = be64toh(*(uint64_t *) (buf + i)); i += 8; |
|
797 |
|
if (u64 != size) |
|
798 |
|
fprintf(stderr, " wrote only %lu bytes\n", u64); |
|
799 |
|
break; |
|
800 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
801 |
|
} |
|
802 |
|
} |
|
803 |
|
|
|
804 |
|
if (err != 0) { |
|
805 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
806 |
|
return err; |
|
807 |
|
} |
|
808 |
|
|
|
809 |
|
return u64; |
|
810 |
|
} |
|
811 |
|
|
|
812 |
|
static int rgfs_fuse_rename(const char *old, const char *new) |
|
813 |
|
{ |
|
814 |
|
int r, err = 0, i; |
|
815 |
|
unsigned char buf[4 * 4096], cmd; |
|
816 |
|
uint16_t u16, old_len, new_len, len; |
|
817 |
|
|
|
818 |
|
//fprintf(stderr, "rename: old=%s new=%s\n", old, new); |
|
819 |
|
|
|
820 |
|
old_len = strlen(old); |
|
821 |
|
new_len = strlen(new); |
|
822 |
|
len = 1 + 2 + 2 + 2 + old_len + new_len; |
|
823 |
|
if (len > sizeof(buf)) { |
|
824 |
|
fprintf(stderr, " buffer too small\n"); |
|
825 |
|
return -EIO; |
|
826 |
|
} |
|
827 |
|
|
|
828 |
|
i = 0; |
|
829 |
|
buf[i++] = 0x0a; |
|
830 |
|
buf[i++] = (len - 1 - 2) >> 8; |
|
831 |
|
buf[i++] = len - 1 - 2; |
|
832 |
|
u16 = htobe16(old_len); memcpy(buf + i, &u16, 2); i += 2; |
|
833 |
|
u16 = htobe16(new_len); memcpy(buf + i, &u16, 2); i += 2; |
|
834 |
|
memcpy(buf + i, old, old_len); i += old_len; |
|
835 |
|
memcpy(buf + i, new, new_len); i += new_len; |
|
836 |
|
r = rgfs_send_recv(buf, i, buf, sizeof(buf)); |
|
837 |
|
|
|
838 |
|
i = 4; |
|
839 |
|
while (i < r) { |
|
840 |
|
cmd = buf[i++]; |
|
841 |
|
//fprintf(stderr, " cmd=0x%02hhx\n", cmd); |
|
842 |
|
switch (cmd) { |
|
843 |
|
case 0x00: err = - be32toh(*(uint32_t *) (buf + i)); i += 4; break; |
|
844 |
|
default: fprintf(stderr, "Unexpected subcode 0x%02hhx!\n", cmd); exit(EXIT_FAILURE); |
|
845 |
|
} |
|
846 |
|
} |
|
847 |
|
|
|
848 |
|
if (err != 0) { |
|
849 |
|
//fprintf(stderr, " server returned error %d!\n", err); |
|
850 |
|
return err; |
|
851 |
|
} |
|
852 |
|
|
|
853 |
|
return 0; |
|
854 |
|
} |
|
855 |
|
|
|
856 |
|
static const struct fuse_operations fuse_rgfs = { |
|
857 |
|
.getattr = rgfs_fuse_getattr, |
|
858 |
|
.readdir = rgfs_fuse_readdir, |
|
859 |
|
.open = rgfs_fuse_open, |
|
860 |
|
.create = rgfs_fuse_create, |
|
861 |
|
.mkdir = rgfs_fuse_mkdir, |
|
862 |
|
.unlink = rgfs_fuse_unlink, |
|
863 |
|
.rmdir = rgfs_fuse_rmdir, |
|
864 |
|
.truncate = rgfs_fuse_truncate, |
|
865 |
|
.read = rgfs_fuse_read, |
|
866 |
|
.write = rgfs_fuse_write, |
|
867 |
|
.rename = rgfs_fuse_rename, |
|
868 |
|
}; |
|
869 |
|
|
|
870 |
|
int main(int argc, char *argv[]) |
|
871 |
|
{ |
|
872 |
|
int r; |
|
873 |
|
|
|
874 |
|
if (gnutls_check_version("3.4.6") == NULL) { |
|
875 |
|
fprintf(stderr, "GnuTLS 3.4.6 or later is required!\n"); |
|
876 |
|
exit(EXIT_FAILURE); |
|
877 |
|
} |
|
878 |
|
|
|
879 |
|
/* for backwards compatibility with gnutls < 3.3.0 */ |
|
880 |
|
r = gnutls_global_init(); |
|
881 |
|
if (r != GNUTLS_E_SUCCESS) { |
|
882 |
|
fprintf(stderr, "gnutls error: cannot init!\n"); |
|
883 |
|
exit(EXIT_FAILURE); |
|
884 |
|
} |
|
885 |
|
|
|
886 |
|
/* X509 stuff */ |
|
887 |
|
r = gnutls_certificate_allocate_credentials(&xcred); |
|
888 |
|
if (r != GNUTLS_E_SUCCESS) { |
|
889 |
|
fprintf(stderr, "gnutls error: cannot allocate credentials!\n"); |
|
890 |
|
exit(EXIT_FAILURE); |
|
891 |
|
} |
|
892 |
|
|
|
893 |
|
/* sets the system trusted CAs for Internet PKI */ |
|
894 |
|
r = gnutls_certificate_set_x509_system_trust(xcred); |
|
895 |
|
if (r < 0) { |
|
896 |
|
fprintf(stderr, "gnutls error: cannot set system trust [%d]!\n", r); |
|
897 |
|
exit(EXIT_FAILURE); |
|
898 |
|
} |
|
899 |
|
|
|
900 |
|
/* If client holds a certificate it can be set using the following: |
|
901 |
|
gnutls_certificate_set_x509_key_file (xcred, "cert.pem", "key.pem", |
|
902 |
|
GNUTLS_X509_FMT_PEM); */ |
|
903 |
|
|
|
904 |
|
fprintf(stderr, "Running fuse...\n"); |
|
905 |
|
return fuse_main(argc, argv, &fuse_rgfs, NULL); |
|
906 |
|
|
|
907 |
|
#if 0 |
|
908 |
|
if (r < 0 && gnutls_error_is_fatal(r) == 0) { |
|
909 |
|
fprintf(stderr, "Warning: %s\n", gnutls_strerror(r)); |
|
910 |
|
} else if (r < 0) { |
|
911 |
|
fprintf(stderr, "Error: %s\n", gnutls_strerror(r)); |
|
912 |
|
exit(EXIT_FAILURE); |
|
913 |
|
} |
|
914 |
|
#endif |
|
915 |
|
|
|
916 |
|
} |
|
917 |
|
|