pkgsrc-Bugs archive

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

pkg/45047: pkgtools/pkg_install minix support



>Number:         45047
>Category:       pkg
>Synopsis:       pkgtools/pkg_install minix support
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 10 15:55:00 +0000 2011
>Originator:     Thomas Cort
>Release:        N/A
>Organization:
Minix3
>Environment:
Minix 192.168.122.210 3.2.0 i686
>Description:
Some changes need to be made to pkg_install for it to work properly on Minix. 
The release and version info returned in struct utsname is slightly different 
than on most systems. For Minix 3.2.0, release is "3" and version is "2.0". 
However, most other operating systems would store the whole thing ("3.2.0") in 
release. Also, some Minix systems use GNU ar (gar) instead of ar, so configure 
should also check for gar. Additionally, a few header files need to be included 
in some C source files. Lastly, the dependency checking should prevent endless 
recursion for circular dependencies.
>How-To-Repeat:
Try using pkg_install on Minix
>Fix:
diff --git a/pkgtools/pkg_install/Makefile b/pkgtools/pkg_install/Makefile
index 392093c..b262265 100644
--- a/pkgtools/pkg_install/Makefile
+++ b/pkgtools/pkg_install/Makefile
@@ -142,6 +142,10 @@ LIBS+=             -larchive
 CPPFLAGS+=     -I${WRKDIR}/libfetch
 LDFLAGS+=      -L${WRKDIR}/libfetch
 
+.  if ${OPSYS} == "Minix"
+LIBS+=         -larchive -lbz2 -lz
+.  endif
+
 CONFIGURE_ENV+=        LIBS=${LIBS:Q}
 
 do-extract:
diff --git a/pkgtools/pkg_install/files/add/perform.c 
b/pkgtools/pkg_install/files/add/perform.c
index aa3dff3..cf7a5c5 100644
--- a/pkgtools/pkg_install/files/add/perform.c
+++ b/pkgtools/pkg_install/files/add/perform.c
@@ -52,6 +52,7 @@ __RCSID("$NetBSD: perform.c,v 1.98 2010/09/14 22:26:18 gdt 
Exp $");
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <assert.h>
 
 #include <archive.h>
 #include <archive_entry.h>
@@ -126,7 +127,12 @@ static const struct pkg_meta_desc {
        { 0, NULL, 0, 0 },
 };
 
-static int pkg_do(const char *, int, int);
+struct dependency_stack {
+       struct dependency_stack *prev;
+       const char *pkgpath;
+};
+
+static int pkg_do(const char *, int, int, struct dependency_stack *);
 
 static int
 end_of_version(const char *opsys, const char *version_end)
@@ -738,7 +744,7 @@ extract_files(struct pkg_task *pkg)
                        continue;
 
                case PLIST_CMD:
-                       if (format_cmd(cmd, sizeof(cmd), p->name, pkg->prefix, 
last_file))
+                       if (format_cmd(cmd, sizeof(cmd), p->name, 
pkg->install_prefix, last_file))
                                return -1;
                        printf("Executing '%s'\n", cmd);
                        if (!Fake && system(cmd))
@@ -858,6 +864,35 @@ pkg_register_depends(struct pkg_task *pkg)
        free(text);
 }
 
+#ifdef __minix
+static void
+normalise_version(char *release, char *version)
+{
+       char actual_version[50];
+       int l1, l2;
+
+       assert(release && version);
+
+       l1 = strlen(release);
+       l2 = strlen(version);
+
+       assert(l1 + l2 + 2 < sizeof(actual_version));
+
+       if(l1 > 0 && l2 > 0)
+               snprintf(actual_version, sizeof(actual_version),
+                       "%s.%s", release, version);
+        else if(strlen(release) > 0)
+               strncpy(actual_version, release, sizeof(actual_version)-1);
+       else if(strlen(version) > 0)
+               strncpy(actual_version, version, sizeof(actual_version)-1);
+       else
+               errx(EXIT_FAILURE, "no version info");
+
+       strcpy(release, actual_version);
+       version[0] = '\0';
+}
+#endif
+
 /*
  * Reduce the result from uname(3) to a canonical form.
  */
@@ -870,6 +905,9 @@ normalise_platform(struct utsname *host_name)
        span = strspn(host_name->release, "0123456789.");
        host_name->release[span] = '\0';
 #endif
+#ifdef __minix
+       normalise_version(host_name->release, host_name->version);
+#endif
 }
 
 /*
@@ -880,7 +918,7 @@ check_platform(struct pkg_task *pkg)
 {
        struct utsname host_uname;
        const char *effective_arch;
-       int fatal;
+       int fatal = 0;
 
        if (uname(&host_uname) < 0) {
                if (Force) {
@@ -906,6 +944,10 @@ check_platform(struct pkg_task *pkg)
        else
                fatal = 0;
 
+#ifdef __minix
+       normalise_version(host_uname.release, host_uname.version);
+#endif
+
        if (fatal ||
            compatible_platform(OPSYS_NAME, host_uname.release,
                                pkg->buildinfo[BI_OS_VERSION]) != 1) {
@@ -1093,7 +1135,7 @@ check_implicit_conflict(struct pkg_task *pkg)
 }
 
 static int
-check_dependencies(struct pkg_task *pkg)
+check_dependencies(struct pkg_task *pkg, struct dependency_stack 
*dependency_stack)
 {
        plist_t *p;
        char *best_installed;
@@ -1124,7 +1166,7 @@ check_dependencies(struct pkg_task *pkg)
                                    p->name);
                                continue;
                        }
-                       if (pkg_do(p->name, 1, 0)) {
+                       if (pkg_do(p->name, 1, 0, dependency_stack)) {
                                if (ForceDepends) {
                                        warnx("Can't install dependency %s, "
                                            "continuing", p->name);
@@ -1373,12 +1415,33 @@ check_license(struct pkg_task *pkg)
  * Install a single package.
  */
 static int
-pkg_do(const char *pkgpath, int mark_automatic, int top_level)
+pkg_do(const char *pkgpath, int mark_automatic, int top_level, 
+       struct dependency_stack *dependency_stack)
 {
        char *archive_name;
        int status, invalid_sig;
        struct pkg_task *pkg;
 
+       /* workaround 2010-12-10: prevent endless recursion for circular 
dependencies */
+       struct dependency_stack dependency_stack_top;
+
+       dependency_stack_top.prev = dependency_stack;
+       dependency_stack_top.pkgpath = pkgpath;
+
+       while (dependency_stack) {
+               if (strcmp(dependency_stack->pkgpath, pkgpath) == 0) {
+                       fprintf(stderr, "warning: ignoring circular 
dependency:\n");
+                       dependency_stack = &dependency_stack_top;
+                       while (dependency_stack) {
+                               fprintf(stderr, "- %s\n", 
dependency_stack->pkgpath);
+                               dependency_stack = dependency_stack->prev;
+                       }
+                       return 0;
+               }
+               dependency_stack = dependency_stack->prev;
+       }
+       /* end workaround */
+       
        pkg = xcalloc(1, sizeof(*pkg));
 
        status = -1;
@@ -1490,7 +1553,7 @@ pkg_do(const char *pkgpath, int mark_automatic, int 
top_level)
                        pkg->install_logdir_real = NULL;
                }
 
-               if (check_dependencies(pkg))
+               if (check_dependencies(pkg, &dependency_stack_top))
                        goto nuke_pkgdb;
        } else {
                /*
@@ -1498,7 +1561,7 @@ pkg_do(const char *pkgpath, int mark_automatic, int 
top_level)
                 * Install/update dependencies first and
                 * write the current package to disk afterwards.
                 */ 
-               if (check_dependencies(pkg))
+               if (check_dependencies(pkg, &dependency_stack_top))
                        goto clean_memory;
 
                if (write_meta_data(pkg))
@@ -1582,7 +1645,7 @@ pkg_perform(lpkg_head_t *pkgs)
        lpkg_t *lpp;
 
        while ((lpp = TAILQ_FIRST(pkgs)) != NULL) {
-               if (pkg_do(lpp->lp_name, Automatic, 1))
+               if (pkg_do(lpp->lp_name, Automatic, 1, NULL))
                        ++errors;
                TAILQ_REMOVE(pkgs, lpp, lp_link);
                free_lpkg(lpp);
diff --git a/pkgtools/pkg_install/files/configure 
b/pkgtools/pkg_install/files/configure
index 0be4828..232aaf1 100755
--- a/pkgtools/pkg_install/files/configure
+++ b/pkgtools/pkg_install/files/configure
@@ -3431,8 +3431,10 @@ else
   RANLIB="$ac_cv_prog_RANLIB"
 fi
 
-# Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
+for ac_prog in gar ar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with 
args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_prog_AR+:} false; then :
@@ -3448,7 +3450,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x 
"$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AR="ar"
+    ac_cv_prog_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" 
>&5
     break 2
   fi
@@ -3468,6 +3470,9 @@ $as_echo "no" >&6; }
 fi
 
 
+  test -n "$AR" && break
+done
+
 
 # Extract the first word of "chmod", so it can be a program name with args.
 set dummy chmod; ac_word=$2
diff --git a/pkgtools/pkg_install/files/configure.ac 
b/pkgtools/pkg_install/files/configure.ac
index ece6517..74da9ff 100644
--- a/pkgtools/pkg_install/files/configure.ac
+++ b/pkgtools/pkg_install/files/configure.ac
@@ -16,7 +16,7 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_RANLIB
-AC_CHECK_PROG(AR, ar, ar)
+AC_CHECK_PROGS(AR, [gar ar])
 
 AC_PATH_PROG(CHMOD, chmod)
 AC_PATH_PROG(CMP, cmp)
diff --git a/pkgtools/pkg_install/files/info/show.c 
b/pkgtools/pkg_install/files/info/show.c
index e44a6c9..89940e3 100644
--- a/pkgtools/pkg_install/files/info/show.c
+++ b/pkgtools/pkg_install/files/info/show.c
@@ -60,6 +60,9 @@ __RCSID("$NetBSD: show.c,v 1.31 2010/11/22 09:00:12 joerg Exp 
$");
 #if HAVE_ERR_H
 #include <err.h>
 #endif
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
 
 #include "defs.h"
 #include "lib.h"
diff --git a/pkgtools/pkg_install/files/lib/plist.c 
b/pkgtools/pkg_install/files/lib/plist.c
index f1b6c6d..d171ad4 100644
--- a/pkgtools/pkg_install/files/lib/plist.c
+++ b/pkgtools/pkg_install/files/lib/plist.c
@@ -514,6 +514,7 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean 
NoDeleteFiles,
        int     fail = SUCCESS;
        Boolean preserve;
        char    tmp[MaxPathSize];
+       char    cmd[MaxPathSize];
        const char *prefix = NULL, *name = NULL;
 
        if (!pkgdb_open(ReadWrite)) {
@@ -580,10 +581,12 @@ delete_package(Boolean ign_err, package_t *pkg, Boolean 
NoDeleteFiles,
                case PLIST_UNEXEC:
                        if (NoDeleteFiles)
                                break;
-                       format_cmd(tmp, sizeof(tmp), p->name, prefix, 
last_file);
-                       printf("Executing `%s'\n", tmp);
-                       if (!Fake && system(tmp)) {
-                               warnx("unexec command for `%s' failed", tmp);
+                       (void) snprintf(tmp, sizeof(tmp), "%s%s%s",
+                                       destdir ? destdir : "", destdir ? "/" : 
"", prefix);
+                       format_cmd(cmd, sizeof(cmd), p->name, tmp, last_file);
+                       printf("Executing `%s'\n", cmd);
+                       if (!Fake && system(cmd)) {
+                               warnx("unexec command for `%s' failed", cmd);
                                fail = FAIL;
                        }
                        break;



Home | Main Index | Thread Index | Old Index