Skip to content

Commit

Permalink
Add info command to show OS version and URLs
Browse files Browse the repository at this point in the history
Fixes #218.

Signed-off-by: Caio Marcelo de Oliveira Filho <[email protected]>
  • Loading branch information
cmarcelo authored and matthewrsj committed Jan 25, 2018
1 parent a463e2e commit 88eea5f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions docs/swupd.1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions docs/swupd.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand Down
1 change: 1 addition & 0 deletions include/swupd-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 42 additions & 0 deletions src/info.c
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*/

#define _GNU_SOURCE
#include <stdio.h>

#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;
}
1 change: 1 addition & 0 deletions src/swupd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};

Expand Down

0 comments on commit 88eea5f

Please sign in to comment.