Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package wtmpdb for openSUSE:Factory checked 
in at 2023-08-10 15:33:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/wtmpdb (Old)
 and      /work/SRC/openSUSE:Factory/.wtmpdb.new.11712 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "wtmpdb"

Thu Aug 10 15:33:00 2023 rev:7 rq:1103168 version:0.8.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/wtmpdb/wtmpdb.changes    2023-07-12 
17:26:52.842329775 +0200
+++ /work/SRC/openSUSE:Factory/.wtmpdb.new.11712/wtmpdb.changes 2023-08-10 
15:33:08.515879929 +0200
@@ -1,0 +2,6 @@
+Wed Aug  9 14:13:17 UTC 2023 - Thorsten Kukuk <ku...@suse.com>
+
+- Update to version 0.8.0
+  - wtmpdb boottime: print boot time
+
+-------------------------------------------------------------------
@@ -11 +17 @@
-- Update to ersion 0.7.1
+- Update to version 0.7.1

Old:
----
  wtmpdb-0.7.1.tar.xz

New:
----
  wtmpdb-0.8.0.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ wtmpdb.spec ++++++
--- /var/tmp/diff_new_pack.lFRv4E/_old  2023-08-10 15:33:09.067883371 +0200
+++ /var/tmp/diff_new_pack.lFRv4E/_new  2023-08-10 15:33:09.071883397 +0200
@@ -18,7 +18,7 @@
 
 %define lname   libwtmpdb0
 Name:           wtmpdb
-Version:        0.7.1
+Version:        0.8.0
 Release:        0
 Summary:        Database for recording the last logged in users and system 
reboots
 License:        BSD-2-Clause

++++++ wtmpdb-0.7.1.tar.xz -> wtmpdb-0.8.0.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wtmpdb-0.7.1/NEWS new/wtmpdb-0.8.0/NEWS
--- old/wtmpdb-0.7.1/NEWS       2023-06-29 14:05:36.000000000 +0200
+++ new/wtmpdb-0.8.0/NEWS       2023-08-09 16:12:24.000000000 +0200
@@ -1,3 +1,7 @@
+Version 0.8.0
+* Fix linking with clang
+* wtmdb boottime: show boot time
+
 Version 0.7.1
 * wtmpdb last: Support "YYYY-MM-DD", "today" and "yesterday" as time option
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wtmpdb-0.7.1/include/wtmpdb.h 
new/wtmpdb-0.8.0/include/wtmpdb.h
--- old/wtmpdb-0.7.1/include/wtmpdb.h   2023-06-29 14:05:36.000000000 +0200
+++ new/wtmpdb-0.8.0/include/wtmpdb.h   2023-08-09 16:12:24.000000000 +0200
@@ -57,6 +57,9 @@
 extern int wtmpdb_rotate (const char *db_path, const int days, char **error, 
                          char **wtmpdb_name, uint64_t *entries);
 
+/* Returns last "BOOT_TIME" entry as usec */
+extern uint64_t wtmpdb_get_boottime (const char *db_path, char **error);
+
 /* helper function */
 extern int64_t wtmpdb_get_id (const char *db_path, const char *tty,
                              char **error);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wtmpdb-0.7.1/lib/libwtmpdb.map 
new/wtmpdb-0.8.0/lib/libwtmpdb.map
--- old/wtmpdb-0.7.1/lib/libwtmpdb.map  2023-06-29 14:05:36.000000000 +0200
+++ new/wtmpdb-0.8.0/lib/libwtmpdb.map  2023-08-09 16:12:24.000000000 +0200
@@ -12,3 +12,8 @@
   global:
         wtmpdb_rotate;
 } LIBWTMPDB_0.1;
+LIBWTMPDB_0.8 {
+  global:
+        wtmpdb_get_boottime;
+} LIBWTMPDB_0.7;
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wtmpdb-0.7.1/lib/sqlite.c 
new/wtmpdb-0.8.0/lib/sqlite.c
--- old/wtmpdb-0.7.1/lib/sqlite.c       2023-06-29 14:05:36.000000000 +0200
+++ new/wtmpdb-0.8.0/lib/sqlite.c       2023-08-09 16:12:24.000000000 +0200
@@ -650,3 +650,55 @@
 
   return 0;
 }
+
+static uint64_t
+search_boottime (sqlite3 *db, char **error)
+{
+  uint64_t boottime = 0;
+  sqlite3_stmt *res;
+  char *sql = "SELECT Login FROM wtmp WHERE User = 'reboot' ORDER BY Login 
DESC LIMIT 1;";
+
+  if (sqlite3_prepare_v2 (db, sql, -1, &res, 0) != SQLITE_OK)
+    {
+      if (error)
+        if (asprintf (error, "Failed to execute statement: %s",
+                      sqlite3_errmsg (db)) < 0)
+          *error = strdup ("Out of memory");
+
+      return -1;
+    }
+
+  int step = sqlite3_step (res);
+
+  if (step == SQLITE_ROW)
+    boottime = sqlite3_column_int64 (res, 0);
+  else
+    {
+      if (error)
+        if (asprintf (error, "Boot time not found (%d)", step) < 0)
+          *error = strdup("Out of memory");
+
+      sqlite3_finalize (res);
+      return -1;
+    }
+
+  sqlite3_finalize (res);
+
+  return boottime;
+}
+
+uint64_t
+wtmpdb_get_boottime (const char *db_path, char **error)
+{
+  sqlite3 *db;
+  uint64_t retval;
+
+  if ((db = open_database_ro (db_path?db_path:_PATH_WTMPDB, error)) == NULL)
+    return -1;
+
+  retval = search_boottime (db, error);
+
+  sqlite3_close (db);
+
+  return retval;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wtmpdb-0.7.1/meson.build new/wtmpdb-0.8.0/meson.build
--- old/wtmpdb-0.7.1/meson.build        2023-06-29 14:05:36.000000000 +0200
+++ new/wtmpdb-0.8.0/meson.build        2023-08-09 16:12:24.000000000 +0200
@@ -11,7 +11,7 @@
                  'b_pie=true',
                  'warning_level=3',],
   license : ['BSD-2-Clause',],
-  version : '0.7.1',
+  version : '0.8.0',
 )
 
 conf = configuration_data()
@@ -47,7 +47,11 @@
                  '-Wstrict-prototypes',
                  '-Wundef',
                  ]
+possible_ld_flags = [
+                  '-flto',
+                  ]
 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language 
: 'c')
+add_project_link_arguments(cc.get_supported_arguments(possible_ld_flags), 
language : 'c')
 
 fs = import('fs')
 if get_option('split-usr') == 'auto'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wtmpdb-0.7.1/src/wtmpdb.c 
new/wtmpdb-0.8.0/src/wtmpdb.c
--- old/wtmpdb-0.7.1/src/wtmpdb.c       2023-06-29 14:05:36.000000000 +0200
+++ new/wtmpdb-0.8.0/src/wtmpdb.c       2023-08-09 16:12:24.000000000 +0200
@@ -452,7 +452,7 @@
   FILE *output = (retval != EXIT_SUCCESS) ? stderr : stdout;
 
   fprintf (output, "Usage: wtmpdb [command] [options]\n");
-  fputs ("Commands: last, boot, rotate, shutdown\n\n", output);
+  fputs ("Commands: last, boot, boottime, rotate, shutdown\n\n", output);
   fputs ("Options for last:\n", output);
   fputs ("  -a, --hostlast      Display hostnames as last entry\n", output);
   fputs ("  -d, --dns           Translate IP addresses into a hostname\n", 
output);
@@ -474,6 +474,10 @@
   fputs ("  -f, --file FILE     Use FILE as wtmpdb database\n", output);
   fputs ("\n", output);
 
+  fputs ("Options for boottime (print time of last system boot):\n", output);
+  fputs ("  -f, --file FILE     Use FILE as wtmpdb database\n", output);
+  fputs ("\n", output);
+
   fputs ("Options for rotate (exports old entries to wtmpdb_<datetime>)):\n", 
output);
   fputs ("  -f, --file FILE     Use FILE as wtmpdb database\n", output);
   fputs ("  -d, --days INTEGER  Export all entries which are older than the 
given days\n", output);
@@ -781,6 +785,53 @@
 }
 
 static int
+main_boottime (int argc, char **argv)
+{
+  struct option const longopts[] = {
+    {"file", required_argument, NULL, 'f'},
+    {NULL, 0, NULL, '\0'}
+  };
+  char *error = NULL;
+  int c;
+  uint64_t boottime;
+
+  while ((c = getopt_long (argc, argv, "f:", longopts, NULL)) != -1)
+    {
+      switch (c)
+        {
+        case 'f':
+          wtmpdb_path = optarg;
+          break;
+        default:
+          usage (EXIT_FAILURE);
+          break;
+        }
+    }
+
+  if (argc > optind)
+    {
+      fprintf (stderr, "Unexpected argument: %s\n", argv[optind]);
+      usage (EXIT_FAILURE);
+    }
+
+  boottime = wtmpdb_get_boottime (wtmpdb_path, &error);
+  if (error)
+    {
+      fprintf (stderr, "Couldn't read boot entry: %s\n", error);
+      free (error);
+      exit (EXIT_FAILURE);
+    }
+
+  char timebuf[32];
+  format_time (TIMEFMT_CTIME, timebuf, sizeof (timebuf),
+              boottime/USEC_PER_SEC);
+
+  printf ("system boot %s\n", timebuf);
+
+  return EXIT_SUCCESS;
+}
+
+static int
 main_shutdown (int argc, char **argv)
 {
   struct option const longopts[] = {
@@ -867,6 +918,8 @@
     return main_boot (--argc, ++argv);
   else if (strcmp (argv[1], "shutdown") == 0)
     return main_shutdown (--argc, ++argv);
+  else if (strcmp (argv[1], "boottime") == 0)
+    return main_boottime (--argc, ++argv);
   else if (strcmp (argv[1], "rotate") == 0)
     return main_rotate (--argc, ++argv);
 

Reply via email to