Radix cross Linux package tools

Package Tools – is a set of utilities to create, install, and update RcL packages

3 Commits   0 Branches   2 Tags
author: kx <kx@radix.pro> 2023-10-23 21:39:58 +0300 committer: kx <kx@radix.pro> 2023-10-23 21:39:58 +0300 commit: a745159c7d8001491589a912af581ee7ffa2218d parent: 11c606a6888dc269ef018359469a7276c3ad8f67
Commit Summary:
Bump version to 0.2.2: Update parallel installation process
Diffstat:
1 file changed, 61 insertions, 38 deletions
diff --git a/src/install-package.c b/src/install-package.c
index 9b73bf7..cf2a2f9 100644
--- a/src/install-package.c
+++ b/src/install-package.c
@@ -78,7 +78,7 @@ char *root = NULL, *pkgs_path = NULL, *rempkgs_path = NULL,
      *pkg_fname = NULL, *asc_fname = NULL, *pkglog_fname = NULL, *pkglist_fname = NULL,
      *tmpdir = NULL, *curdir = NULL, *log_fname = NULL;
 
-int   ask = 0, rqck = 0, gpgck = 0, ignore_chrefs_errors = 0;
+int   ask = 0, rqck = 0, gpgck = 0, ignore_chrefs_errors = 0, disable_chrefs = 0;
 char *description = NULL;
 
 int   exit_status = EXIT_SUCCESS; /* errors counter */
@@ -196,6 +196,7 @@ void usage()
   fprintf( stdout, "                                and located in the same directory as the package.\n" );
 #endif
   fprintf( stdout, "  --ignore-chrefs-errors        Ignore change references errors (code: 48).\n" );
+  fprintf( stdout, "  --disable-chrefs              Do not manage references to the package.\n" );
 #if defined( HAVE_DIALOG )
   fprintf( stdout, "  -i,--info-dialog              Show package description during install\n" );
   fprintf( stdout, "                                process using ncurses dialog.\n" );
@@ -683,6 +684,7 @@ void get_args( int argc, char *argv[] )
 #endif
 
 #define IGNORE_CHREFS_ERRORS 872
+#define DISABLE_CHREFS       873
 
   const struct option long_options[] =
   {
@@ -694,6 +696,7 @@ void get_args( int argc, char *argv[] )
     { "gpg-verify",           no_argument,       NULL, 'g' },
 #endif
     { "ignore-chrefs-errors", no_argument,       NULL, IGNORE_CHREFS_ERRORS },
+    { "disable-chrefs",       no_argument,       NULL, DISABLE_CHREFS },
 #if defined( HAVE_DIALOG )
     { "info-dialog",          no_argument,       NULL, 'i' },
     { "menu-dialog",          no_argument,       NULL, 'm' },
@@ -758,6 +761,12 @@ void get_args( int argc, char *argv[] )
         break;
       }
 
+      case DISABLE_CHREFS:
+      {
+        disable_chrefs = 1;
+        break;
+      }
+
       case 'p':
       {
         if( optarg != NULL )
@@ -1509,8 +1518,8 @@ static void read_service_files( void )
 
 static void check_package( void )
 {
-  pid_t p = (pid_t) -1;
-  int   rc;
+  pid_t  p = (pid_t) -1;
+  int   rc = EXIT_SUCCESS;
 
   int   len = 0;
   char *cmd = NULL;
@@ -2184,12 +2193,25 @@ static void pre_install_routine( void )
   }
 }
 
+static int __nstreams( void )
+{
+  int ret    = 1;
+  int nprocs = get_nprocs();
+
+  if( nprocs > 4 )
+  {
+    ret = nprocs / 2;
+  }
+
+  return ret;
+}
+
 static const char *fill_decompressor( char *buffer, char compressor )
 {
   switch( compressor )
   {
     case 'J':
-      (void)sprintf( buffer, "xz --threads=%d -dc", get_nprocs() );
+      (void)sprintf( buffer, "xz --threads=%d -dc", __nstreams() );
       break;
     case 'j':
       (void)sprintf( buffer, "bzip2 -dc" );
@@ -2206,8 +2228,8 @@ static const char *fill_decompressor( char *buffer, char compressor )
 
 static void uncompress_package( void )
 {
-  pid_t p = (pid_t) -1;
-  int   rc;
+  pid_t  p = (pid_t) -1;
+  int   rc = EXIT_SUCCESS;
 
   int   len = 0;
   char *cmd = NULL;
@@ -2442,48 +2464,51 @@ static void finalize_installation( void )
   /*********************************************
     Increment references in the Setup Database:
    */
-  if( group )
-    len = snprintf( &cmd[0], PATH_MAX,
-                    "%s/chrefs --operation=inc --destination=%s %s/%s > /dev/null 2>&1",
-                    selfdir, pkgs_path, group, basename( (char *)pkglog_fname ) );
-  else
-    len = snprintf( &cmd[0], PATH_MAX,
-                    "%s/chrefs --operation=inc --destination=%s %s > /dev/null 2>&1",
-                    selfdir, pkgs_path, basename( (char *)pkglog_fname ) );
-  if( len == 0 || len == PATH_MAX - 1 )
+  if( !disable_chrefs )
   {
-    FATAL_ERROR( "Cannot increment '%s-%s' package references", pkgname, pkgver );
-  }
-  p = sys_exec_command( cmd );
-  rc = sys_wait_command( p, (char *)NULL, PATH_MAX );
+    if( group )
+      len = snprintf( &cmd[0], PATH_MAX,
+                      "%s/chrefs --operation=inc --destination=%s %s/%s > /dev/null 2>&1",
+                      selfdir, pkgs_path, group, basename( (char *)pkglog_fname ) );
+    else
+      len = snprintf( &cmd[0], PATH_MAX,
+                      "%s/chrefs --operation=inc --destination=%s %s > /dev/null 2>&1",
+                      selfdir, pkgs_path, basename( (char *)pkglog_fname ) );
+    if( len == 0 || len == PATH_MAX - 1 )
+    {
+      FATAL_ERROR( "Cannot increment '%s-%s' package references", pkgname, pkgver );
+    }
+    p = sys_exec_command( cmd );
+    rc = sys_wait_command( p, (char *)NULL, PATH_MAX );
 
-  free( cmd );
+    free( cmd );
 
-  if( (rc != 0) && !ignore_chrefs_errors )
-  {
-    free( tmp );
+    if( (rc != 0) && !ignore_chrefs_errors )
+    {
+      free( tmp );
 
-    rollback();
+      rollback();
 
-    exit_status = 48;
+      exit_status = 48;
 
-    if( install_mode != CONSOLE )
-    {
+      if( install_mode != CONSOLE )
+      {
 #if defined( HAVE_DIALOG )
-      info_pkg_box( "Install:", pkgname, pkgver, strprio( priority, 0 ),
-                    "\n\\Z1Cannot increment package references in Setup Database.\\Zn\n", 5, 0, 0 );
+        info_pkg_box( "Install:", pkgname, pkgver, strprio( priority, 0 ),
+                      "\n\\Z1Cannot increment package references in Setup Database.\\Zn\n", 5, 0, 0 );
 #else
-      fprintf( stdout, "\nCannot increment '%s-%s' package references in Setup Database.\n\n", pkgname, pkgver );
+        fprintf( stdout, "\nCannot increment '%s-%s' package references in Setup Database.\n\n", pkgname, pkgver );
 #endif
-    }
-    else
-    {
-      fprintf( stdout, "\nCannot increment '%s-%s' package references in Setup Database.\n\n", pkgname, pkgver );
-    }
+      }
+      else
+      {
+        fprintf( stdout, "\nCannot increment '%s-%s' package references in Setup Database.\n\n", pkgname, pkgver );
+      }
 
-    if( tmpdir ) { _rm_tmpdir( (const char *)tmpdir ); free( tmpdir ); }
-    free_resources();
-    exit( exit_status );
+      if( tmpdir ) { _rm_tmpdir( (const char *)tmpdir ); free( tmpdir ); }
+      free_resources();
+      exit( exit_status );
+    }
   }
 
   /*************************************************