From 88eea5f9e9fd3196885c2acacbc4b4b70577a6b9 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 24 Jan 2018 22:58:46 -0800 Subject: [PATCH] Add info command to show OS version and URLs Fixes #218. Signed-off-by: Caio Marcelo de Oliveira Filho --- Makefile.am | 4 +++- docs/swupd.1 | 7 +++++++ docs/swupd.1.rst | 4 ++++ include/swupd-internal.h | 1 + src/info.c | 42 ++++++++++++++++++++++++++++++++++++++++ src/swupd.c | 1 + 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/info.c diff --git a/Makefile.am b/Makefile.am index fea23f155..2568425f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,8 @@ swupd_SOURCES = \ $(clr_bundle_rm_SOURCES) \ $(clr_bundle_ls_SOURCES) \ $(swupd_autoupdate_SOURCES) \ - $(swupd_search_SOURCES) + $(swupd_search_SOURCES) \ + $(swupd_info_SOURCES) SWUPD_COMMON_SOURCES = \ src/archives.c \ @@ -66,6 +67,7 @@ clr_bundle_rm_SOURCES = src/clr_bundle_rm.c clr_bundle_ls_SOURCES = src/clr_bundle_ls.c swupd_hashdump_SOURCES = src/hashdump.c +swupd_info_SOURCES = src/info.c AM_CPPFLAGS = $(AM_CFLAGS) $(libarchive_CFLAGS) -I$(top_srcdir)/include SWUPD_COMPRESSION_LIBS = $(lzma_LIBS) $(zlib_LIBS) $(bzip2_LIBS) diff --git a/docs/swupd.1 b/docs/swupd.1 index 3554f20d5..1622dd277 100644 --- a/docs/swupd.1 +++ b/docs/swupd.1 @@ -459,6 +459,13 @@ Matches nothing, because paths are never empty. .UNINDENT .UNINDENT .UNINDENT +.sp +\fBinfo\fP +.INDENT 0.0 +.INDENT 3.5 +Shows the current OS version and the URLs used for updates. +.UNINDENT +.UNINDENT .SH EXIT STATUS .sp On success, 0 is returned. A non\-zero return code signals a failure. diff --git a/docs/swupd.1.rst b/docs/swupd.1.rst index 3f256c3ee..ae397ccc5 100644 --- a/docs/swupd.1.rst +++ b/docs/swupd.1.rst @@ -323,6 +323,10 @@ SUBCOMMANDS Matches nothing, because paths are never empty. +``info`` + + Shows the current OS version and the URLs used for updates. + EXIT STATUS =========== diff --git a/include/swupd-internal.h b/include/swupd-internal.h index 8ae29c819..6b1cb3660 100644 --- a/include/swupd-internal.h +++ b/include/swupd-internal.h @@ -10,5 +10,6 @@ extern int update_main(int argc, char **argv); extern int verify_main(int argc, char **argv); extern int check_update_main(int argc, char **argv); extern int search_main(int argc, char **argv); +extern int info_main(int argc, char **argv); #endif diff --git a/src/info.c b/src/info.c new file mode 100644 index 000000000..0fc53750b --- /dev/null +++ b/src/info.c @@ -0,0 +1,42 @@ +/* + * Software Updater - client side + * + * Copyright © 2018 Intel Corporation. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#define _GNU_SOURCE +#include + +#include "swupd.h" + +int info_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) +{ + int current_version; + + copyright_header("info"); + + if (!init_globals()) { + return EINIT_GLOBALS; + } + + current_version = get_current_version(path_prefix); + printf("Installed version: %d\n", current_version); + printf("Version URL: %s\n", version_url); + printf("Content URL: %s\n", content_url); + + free_globals(); + return 0; +} diff --git a/src/swupd.c b/src/swupd.c index 5c79f4d0d..d33e7c06b 100644 --- a/src/swupd.c +++ b/src/swupd.c @@ -43,6 +43,7 @@ static struct subcmd commands[] = { { "verify", "Verify content for OS version", verify_main }, { "check-update", "Check if a new OS version is available", check_update_main }, { "search", "Search Clear Linux for a binary or library", search_main }, + { "info", "Show the version and the update URLs", info_main }, { 0 } };