1 /*
2  * libosinfo: An installation media for a (guest) OS
3  *
4  * Copyright (C) 2009-2020 Red Hat, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <glib-object.h>
22 #include <gio/gio.h>
23 #include <osinfo/osinfo_entity.h>
24 #include <osinfo/osinfo_os_variantlist.h>
25 
26 #ifndef __OSINFO_MEDIA_H__
27 # define __OSINFO_MEDIA_H__
28 
29 # include "osinfo/osinfo_macros.h"
30 
31 GQuark
32 osinfo_media_error_quark (void) G_GNUC_CONST;
33 
34 # define OSINFO_MEDIA_ERROR (osinfo_media_error_quark ())
35 
36 /**
37  * OsinfoMediaError:
38  * @OSINFO_MEDIA_ERROR_NO_DESCRIPTORS: No descriptors.
39  * @OSINFO_MEDIA_ERROR_INSUFFICIENT_METADATA: Not enough metadata.
40  * @OSINFO_MEDIA_ERROR_NOT_BOOTABLE: Install media not bootable.
41  * @OSINFO_MEDIA_ERROR_NO_PVD: No Primary volume descriptor.
42  * @OSINFO_MEDIA_ERROR_NO_SVD: No supplementary volume descriptor.
43  * @OSINFO_MEDIA_ERROR_NO_DIRECTORY_RECORD_EXTENT: No directory record extent
44  * found.
45  *
46  * #GError codes used for errors in the #OSINFO_MEDIA_ERROR domain, during
47  * reading of data from install media location.
48  */
49 typedef enum {
50     OSINFO_MEDIA_ERROR_NO_DESCRIPTORS,
51     OSINFO_MEDIA_ERROR_NO_PVD,
52     OSINFO_MEDIA_ERROR_NO_SVD,
53     OSINFO_MEDIA_ERROR_INSUFFICIENT_METADATA,
54     OSINFO_MEDIA_ERROR_NOT_BOOTABLE,
55     OSINFO_MEDIA_ERROR_NO_DIRECTORY_RECORD_EXTENT
56 } OsinfoMediaError;
57 
58 /**
59  * OsinfoMediaDetectFlags
60  * OSINFO_MEDIA_DETECT_REQUIRE_BOOTABLE: Requires a media to be bootable.
61  *
62  * Flags used for detecting a media.
63  *
64  * Since: 1.6.0
65  */
66 typedef enum {
67     OSINFO_MEDIA_DETECT_REQUIRE_BOOTABLE = 1 << 0,
68 } OsinfoMediaDetectFlags;
69 
70 # define OSINFO_TYPE_MEDIA (osinfo_media_get_type ())
71 OSINFO_DECLARE_TYPE_WITH_PRIVATE_AND_CLASS(OsinfoMedia,
72                                            osinfo_media,
73                                            OSINFO,
74                                            MEDIA,
75                                            OsinfoEntity)
76 
77 # define OSINFO_MEDIA_PROP_ARCHITECTURE   "architecture"
78 # define OSINFO_MEDIA_PROP_URL            "url"
79 # define OSINFO_MEDIA_PROP_VOLUME_ID      "volume-id"
80 # define OSINFO_MEDIA_PROP_SYSTEM_ID      "system-id"
81 # define OSINFO_MEDIA_PROP_PUBLISHER_ID   "publisher-id"
82 # define OSINFO_MEDIA_PROP_APPLICATION_ID "application-id"
83 # define OSINFO_MEDIA_PROP_KERNEL         "kernel"
84 # define OSINFO_MEDIA_PROP_INITRD         "initrd"
85 # define OSINFO_MEDIA_PROP_LIVE           "live"
86 # define OSINFO_MEDIA_PROP_INSTALLER      "installer"
87 # define OSINFO_MEDIA_PROP_INSTALLER_REBOOTS "installer-reboots"
88 # define OSINFO_MEDIA_PROP_LANG           "l10n-language"
89 # define OSINFO_MEDIA_PROP_LANG_REGEX     "l10n-language-regex"
90 # define OSINFO_MEDIA_PROP_LANG_MAP       "l10n-language-map"
91 # define OSINFO_MEDIA_PROP_VARIANT        "variant"
92 # define OSINFO_MEDIA_PROP_VOLUME_SIZE    "volume-size"
93 # define OSINFO_MEDIA_PROP_EJECT_AFTER_INSTALL "eject-after-install"
94 # define OSINFO_MEDIA_PROP_INSTALLER_SCRIPT "installer-script"
95 # define OSINFO_MEDIA_PROP_BOOTABLE        "bootable"
96 
97 OsinfoMedia *osinfo_media_new(const gchar *id, const gchar *architecture);
98 OsinfoMedia *osinfo_media_create_from_location(const gchar *location,
99                                                GCancellable *cancellable,
100                                                GError **error);
101 void osinfo_media_create_from_location_async(const gchar *location,
102                                              gint priority,
103                                              GCancellable *cancellable,
104                                              GAsyncReadyCallback callback,
105                                              gpointer user_data);
106 OsinfoMedia *osinfo_media_create_from_location_finish(GAsyncResult *res,
107                                                       GError **error);
108 
109 OsinfoMedia *osinfo_media_create_from_location_with_flags(const gchar *location,
110                                                           GCancellable *cancellable,
111                                                           guint flags,
112                                                           GError **error);
113 void osinfo_media_create_from_location_with_flags_async(const gchar *location,
114                                                         gint priority,
115                                                         GCancellable *cancellable,
116                                                         GAsyncReadyCallback callback,
117                                                         guint flags,
118                                                         gpointer user_data);
119 OsinfoMedia *osinfo_media_create_from_location_with_flags_finish(GAsyncResult *res,
120                                                                  GError **error);
121 
122 const gchar *osinfo_media_get_architecture(OsinfoMedia *media);
123 const gchar *osinfo_media_get_url(OsinfoMedia *media);
124 const gchar *osinfo_media_get_volume_id(OsinfoMedia *media);
125 const gchar *osinfo_media_get_system_id(OsinfoMedia *media);
126 const gchar *osinfo_media_get_publisher_id(OsinfoMedia *media);
127 const gchar *osinfo_media_get_application_id(OsinfoMedia *media);
128 const gchar *osinfo_media_get_kernel_path(OsinfoMedia *media);
129 const gchar *osinfo_media_get_initrd_path(OsinfoMedia *media);
130 gboolean osinfo_media_is_bootable(OsinfoMedia *media);
131 OsinfoOs *osinfo_media_get_os(OsinfoMedia *media);
132 OsinfoOsVariantList *osinfo_media_get_os_variants(OsinfoMedia *media);
133 GList *osinfo_media_get_languages(OsinfoMedia *media);
134 gboolean osinfo_media_get_installer(OsinfoMedia *media);
135 gboolean osinfo_media_get_live(OsinfoMedia *media);
136 gint osinfo_media_get_installer_reboots(OsinfoMedia *media);
137 gint64 osinfo_media_get_volume_size(OsinfoMedia *media);
138 gboolean osinfo_media_get_eject_after_install(OsinfoMedia *media);
139 gboolean osinfo_media_supports_installer_script(OsinfoMedia *media);
140 void osinfo_media_add_install_script(OsinfoMedia *media, OsinfoInstallScript *script);
141 OsinfoInstallScriptList *osinfo_media_get_install_script_list(OsinfoMedia *media);
142 
143 #endif /* __OSINFO_MEDIA_H__ */
144