1 |
Signed-off-by: Mykyta Holubakha <hilobakho@×××××.com> |
2 |
|
3 |
I'm proposing to add a new eclass: appimage.eclass, to facilitate |
4 |
extraction off AppImage bundles. The rationale is that some upstreams |
5 |
have migrated to distributing their proprietary software exclusively as |
6 |
AppImage bundles. (for instance dev-util/staruml-bin). |
7 |
|
8 |
An example ebuild can be seen at https://git.io/fx3Mg |
9 |
|
10 |
I'd like to ask the following questions: |
11 |
|
12 |
1. Can I put myself and proxy-maint under @MAINTAINER (or do I need to |
13 |
find a gentoo dev)? |
14 |
|
15 |
2. Are we OK with executing AppImage bundles downloaded from the |
16 |
Internet (an alternative would be to implement a proper extractor |
17 |
program, which would unpack the images without executing them, and add |
18 |
it to DEPENDs). |
19 |
|
20 |
Thanks |
21 |
|
22 |
--- |
23 |
eclass/appimage.eclass | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ |
24 |
1 file changed, 69 insertions(+) |
25 |
create mode 100644 eclass/appimage.eclass |
26 |
|
27 |
diff --git a/eclass/appimage.eclass b/eclass/appimage.eclass |
28 |
new file mode 100644 |
29 |
index 00000000000..454bdedc07b |
30 |
--- /dev/null |
31 |
+++ b/eclass/appimage.eclass |
32 |
@@ -0,0 +1,69 @@ |
33 |
+# Copyright 2018 Gentoo Foundation |
34 |
+# Distributed under the terms of the GNU General Public License v2 |
35 |
+ |
36 |
+# @ECLASS: appimage.eclass |
37 |
+# @MAINTAINER: |
38 |
+# maintainer-wanted@g.o |
39 |
+# @AUTHOR: |
40 |
+# Mykyta Holubakha <hilobakho@×××××.com> |
41 |
+# @BLURB: convenience eclass for extracting AppImage bundles |
42 |
+# @DESCRIPTION: |
43 |
+# This eclass provides a src_unpack function to extract AppImage bundles |
44 |
+ |
45 |
+case "${EAPI:-0}" in |
46 |
+ 6|7) |
47 |
+ ;; |
48 |
+ *) |
49 |
+ die "EAPI ${EAPI:-0} is not supported" |
50 |
+ ;; |
51 |
+esac |
52 |
+ |
53 |
+EXPORT_FUNCTIONS src_unpack |
54 |
+ |
55 |
+# @VARIABLE: APPIMAGE_EXTRACT_DIR |
56 |
+# @DEFAULT_UNSET: squashfs_root |
57 |
+# @DESCRIPTION: |
58 |
+# This variable specifies the directory, in which the AppImage bundle |
59 |
+# is expected to be extracted. |
60 |
+ |
61 |
+# @VARIABLE: APPIMAGE_EXTRACT_DEST |
62 |
+# @DEFAULT_UNSET: ${P} |
63 |
+# @DESCRIPTION: |
64 |
+# This variable specifies the directory, to which the extracted image |
65 |
+# will be moved. |
66 |
+ |
67 |
+# @FUNCTION: appimage_src_unpack |
68 |
+# @DESCRIPTION: |
69 |
+# Unpack all the AppImage bundles from ${A} (with .appimage extension). |
70 |
+# Other files are passed to regular unpack. |
71 |
+appimage_src_unpack() { |
72 |
+ debug-print-function ${FUNCNAME} "${@}" |
73 |
+ |
74 |
+ local extract_dir="${APPIMAGE_EXTRACT_DIR:-squashfs-root}" |
75 |
+ local extract_dest="${APPIMAGE_EXTRACT_DEST:-${P}}" |
76 |
+ |
77 |
+ local f |
78 |
+ for f in ${A} |
79 |
+ do |
80 |
+ case "${f}" in |
81 |
+ *.appimage|*.AppImage) |
82 |
+ cp "${DISTDIR}/${f}" "${WORKDIR}" |
83 |
+ debug-print "${FUNCNAME}: unpacking bundle ${f} to ${extract_dest}" |
84 |
+ chmod +x "${f}" \ |
85 |
+ || die "Failed to add execute permissions to bundle" |
86 |
+ "${WORKDIR}/${f}" --appimage-help >/dev/null 2>/dev/null \ |
87 |
+ || die "Invalid AppImage bundle" |
88 |
+ "${WORKDIR}/${f}" --appimage-extract >/dev/null 2>/dev/null \ |
89 |
+ || die "Failed to extract AppImage bundle" |
90 |
+ rm -f "${f}" || die "Failed to remove bundle copy" |
91 |
+ mv "${extract_dir}" "${extract_dest}" \ |
92 |
+ || die "Failed to move AppImage bundle to destination" |
93 |
+ ;; |
94 |
+ *) |
95 |
+ debug-print "${FUNCNAME}: falling back to unpack for ${f}" |
96 |
+ unpack "${f}" |
97 |
+ ;; |
98 |
+ esac |
99 |
+ done |
100 |
+} |
101 |
+ |
102 |
-- |
103 |
2.15.1 |