Re: [PATCH 07/10] tools, install-script: Allow arg to be a media file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 07, 2015 at 05:36:42PM +0100, Zeeshan Ali (Khattak) wrote:
> Now that we have API to generate scripts for specific media and since
> its the recommended path to generating scripts, let's allow users of

"it is", not "its"

> this tool to provide an installer or live media as argument.
> ---
>  tools/osinfo-install-script.c | 56 ++++++++++++++++++++++++++++++-------------
>  1 file changed, 40 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/osinfo-install-script.c b/tools/osinfo-install-script.c
> index 5d5f0e2..96f7bc4 100644
> --- a/tools/osinfo-install-script.c
> +++ b/tools/osinfo-install-script.c
> @@ -220,7 +220,7 @@ static gboolean list_script_inj_method(OsinfoOs *os)
>  }
>  
>  
> -static gboolean generate_script(OsinfoOs *os)
> +static gboolean generate_script(OsinfoOs *os, OsinfoMedia *media)
>  {
>      OsinfoInstallScriptList *scripts = osinfo_os_get_install_script_list(os);
>      OsinfoInstallScriptList *profile_scripts;
> @@ -253,12 +253,21 @@ static gboolean generate_script(OsinfoOs *os)
>          if (prefix)
>              osinfo_install_script_set_output_prefix(script, prefix);
>  
> -        osinfo_install_script_generate_output(script,
> -                                              os,
> -                                              config,
> -                                              dir,
> -                                              NULL,
> -                                              &error);
> +        if (media != NULL) {
> +            osinfo_install_script_generate_output_for_media(script,
> +                                                            media,
> +                                                            config,
> +                                                            dir,
> +                                                            NULL,
> +                                                            &error);
> +        } else {
> +            osinfo_install_script_generate_output(script,
> +                                                  os,
> +                                                  config,
> +                                                  dir,
> +                                                  NULL,
> +                                                  &error);
> +        }
>          if (error != NULL) {
>              g_printerr(_("Unable to generate install script: %s\n"),
>                         error->message ? error->message : "unknown");
> @@ -287,6 +296,7 @@ gint main(gint argc, gchar **argv)
>      OsinfoLoader *loader = NULL;
>      OsinfoDb *db = NULL;
>      OsinfoOs *os = NULL;
> +    OsinfoMedia *media = NULL;
>      gint ret = 0;
>  
>      setlocale(LC_ALL, "");
> @@ -338,11 +348,22 @@ gint main(gint argc, gchar **argv)
>      }
>  
>      db = osinfo_loader_get_db(loader);
> -    os = find_os(db, argv[1]);
> -    if (!os) {
> -        g_printerr(_("Error finding OS: %s\n"), argv[1]);
> -        ret = -4;
> -        goto EXIT;
> +
> +    /* First assume its a path to a media that can be indentified */

s/its/it is/
s/indentified/identified/

> +    media = osinfo_media_create_from_location(argv[1], NULL, NULL);
> +    if (media != NULL)
> +        if (!osinfo_db_identify_media (db, media))
> +            media = NULL;

You are leaking 'media' here.

> +
> +    if (media == NULL) {
> +        os = find_os(db, argv[1]);
> +        if (!os) {
> +            g_printerr(_("Error finding OS: %s\n"), argv[1]);
> +            ret = -4;
> +            goto EXIT;
> +        }
> +    } else {
> +        os = osinfo_media_get_os (media);
>      }
>  
>      if (list_config) {
> @@ -361,7 +382,7 @@ gint main(gint argc, gchar **argv)
>              goto EXIT;
>          }
>      } else {
> -        if (!generate_script(os)) {
> +        if (!generate_script(os, media)) {
>              ret = -5;
>              goto EXIT;
>          }
> @@ -370,6 +391,8 @@ gint main(gint argc, gchar **argv)
>  EXIT:
>      if (config)
>          g_object_unref(config);
> +    if (media != NULL)
> +        g_object_unref(media);
>      g_clear_error(&error);
>      g_clear_object(&loader);
>      g_option_context_free(context);
> @@ -386,13 +409,14 @@ osinfo-install-script - generate a script for automated installation
>  
>  =head1 SYNOPSIS
>  
> -osinfo-install-script [OPTIONS...] OS-ID
> +osinfo-install-script [OPTIONS...] MEDIA-FILE|OS-ID
>  
>  =head1 DESCRIPTION
>  
>  Generate a script suitable for performing an automated installation
> -of C<OS-ID>. C<OS-ID> should be a URI identifying the operating
> -system, or its short ID.
> +for C<MEDIA_FILE> or C<OS-ID>. C<MEDIA_FILE> should be a path to an

I'd tend to keep "of <MEDIA_FILES>" rather than "for", but very not
sure, both sound acceptable to me.

Christophe

Attachment: pgppx7xIhQVZn.pgp
Description: PGP signature

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux