Ticket #37 (closed defect: fixed)

Opened 15 months ago

Last modified 13 months ago

archmobile: ldconfig cannot be executed

Reported by: harlekin Owned by: harlekin
Priority: minor Milestone: 0.1
Component: Installer Keywords:
Cc:

Description (last modified by harlekin) (diff)

When installing the base system using the installer, glibc's scriptlet fails to execute with the following error message:

sh: /media/sd_storage/sbin/ldconfig: file or directory not found

Change History

Changed 15 months ago by harlekin

  • owner set to harlekin
  • component changed from Archlinux to Installer

Changed 15 months ago by harlekin

  • status changed from new to accepted

Changed 15 months ago by harlekin

  • milestone 0.2 deleted

Changed 15 months ago by harlekin

  • milestone set to 0.1

Changed 15 months ago by harlekin

  • status changed from accepted to closed
  • resolution set to fixed

Condition not present in development version of installer. Will be released soon.

Changed 15 months ago by harlekin

  • status changed from closed to reopened
  • resolution fixed deleted

This issue remains when installing with -b only.

Changed 15 months ago by harlekin

The information that ldconfig only fails when installing with --build was wrong. This happens because pacman doesn't chroot when trying to execute ldconfig. Thus if qemu-static-arm is not installed in the host system, ldconfig cannot be executed.

Possible work-arounds:

  1. Installing qemu-static-arm to the host system should fix the problem.
  2. Ignore the error and run ldconfig manually in the chrooted environment (build environment) or on the phone (regular installation)

A proper fix would probably require to patch pacman.

Changed 15 months ago by harlekin

Here's a patch for pacman (libalpm) fixing the issue in my test cases. Can this be considered a pacman bug and justify opening a ticket?

  • lib/libalpm/add.c

    diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
    index 3c0074f..d09ba14 100644
    a b  
    887887        } 
    888888 
    889889        /* run ldconfig if it exists */ 
    890         _alpm_log(PM_LOG_DEBUG, "running \"ldconfig -r %s\"\n", handle->root); 
     890        _alpm_log(PM_LOG_DEBUG, "running \"ldconfig\" under chroot (%s)\n", 
     891                        handle->root); 
    891892        _alpm_ldconfig(handle->root); 
    892893 
    893894        return(0); 
  • lib/libalpm/remove.c

    diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
    index 9dfff9c..370aa81 100644
    a b  
    395395 
    396396        /* run ldconfig if it exists */ 
    397397        if(trans->type != PM_TRANS_TYPE_REMOVEUPGRADE) { 
    398                 _alpm_log(PM_LOG_DEBUG, "running \"ldconfig -r %s\"\n", handle->root); 
     398                _alpm_log(PM_LOG_DEBUG, "running \"ldconfig\" under chroot (%s)\n", 
     399                        handle->root); 
    399400                _alpm_ldconfig(handle->root); 
    400401        } 
    401402 
  • lib/libalpm/util.c

    diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
    index 75f6042..c2d505d 100644
    a b  
    456456 
    457457int _alpm_ldconfig(const char *root) 
    458458{ 
    459         char line[PATH_MAX]; 
    460  
    461         snprintf(line, PATH_MAX, "%setc/ld.so.conf", root); 
    462         if(access(line, F_OK) == 0) { 
    463                 snprintf(line, PATH_MAX, "%ssbin/ldconfig", root); 
    464                 if(access(line, X_OK) == 0) { 
    465                         char cmd[PATH_MAX]; 
    466                         snprintf(cmd, PATH_MAX, "%s -r %s", line, root); 
    467                         system(cmd); 
     459        pid_t pid; 
     460        char cwd[PATH_MAX]; 
     461        const char *ldconfig = "/sbin/ldconfig"; 
     462        const char *ldsoconf = "/etc/ld.so.conf"; 
     463        int retval = 0; 
     464 
     465        /* Flush open fds before fork() to avoid cloning buffers */ 
     466        fflush(NULL); 
     467 
     468        pid = fork(); 
     469        if(pid == -1) { 
     470                _alpm_log(PM_LOG_ERROR, _("could not fork a new process (%s)\n"), 
     471                                        strerror(errno)); 
     472                retval = 1; 
     473        } 
     474        if(pid == 0) { 
     475                /* this code runs for the child only (the actual chroot/exec) */ 
     476                _alpm_log(PM_LOG_DEBUG, "chrooting in %s\n", root); 
     477                if(chroot(root) != 0) { 
     478                        _alpm_log(PM_LOG_ERROR, _("could not change directory to / (%s)\n"), 
     479                                        strerror(errno)); 
     480                        exit(1); 
     481                } 
     482                if(chdir("/") != 0) { 
     483                        _alpm_log(PM_LOG_ERROR, _("could not change directory to / (%s)\n"), 
     484                                        strerror(errno)); 
     485                        exit(1); 
     486                } 
     487                /* Somehow it fails if we check for the necessary files using access(). 
     488                 * Any suggestions why? */ 
     489                /*if(access(ldsoconf, F_OK) != 0) { 
     490                        _alpm_log(PM_LOG_ERROR, _("%s not found\n"), 
     491                                        ldsoconf, strerror(errno)); 
     492                        exit(1); 
     493                } 
     494                if(access(ldconfig, X_OK) != 0) { 
     495                        _alpm_log(PM_LOG_ERROR, _("%s cannot be executed\n"), 
     496                                        ldconfig, strerror(errno)); 
     497                        exit(1); 
     498                }*/ 
     499                if (execl(ldconfig, ldconfig, (char *) NULL) == -1) { 
     500                        exit(1); 
     501                } 
     502        } else { 
     503                /* this code runs for the parent only (wait on the child) */ 
     504                pid_t retpid; 
     505                int status; 
     506                while((retpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR); 
     507                if(retpid == -1) { 
     508                        _alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)\n"), 
     509                                        strerror(errno)); 
     510                        retval = 1; 
     511                } else { 
     512                        if(WIFEXITED(status)) { 
     513                                _alpm_log(PM_LOG_DEBUG, "call to waitpid succeeded\n"); 
     514                                if(WEXITSTATUS(status) != 0) { 
     515                                        retval = 1; 
     516                                } 
     517                        } 
    468518                } 
    469519        } 
     520        if(retval != 0) { 
     521                _alpm_log(PM_LOG_ERROR, _("ldconfig failed to execute correctly\n")); 
     522        } 
    470523 
    471         return(0); 
     524        return(retval); 
    472525} 
    473526 
    474527/* Helper function for comparing strings using the 

By the way, does anyone know why checking for access() fails?

Changed 15 months ago by harlekin

I filed a  bug report for pacman to get some insight from the pacman devs. To my understanding this is a pacman bug. If it is not we'll have to add a work around to the installer.

Changed 15 months ago by harlekin

PS. The patch attached to pacman's bug report is a modified version of the patch which bypasses the access() misbehaviour and which follows the original pacman code more strictly.

Changed 14 months ago by harlekin

  • summary changed from archOnFr: ldconfig cannot be executed to archmobile: ldconfig cannot be executed

Changed 14 months ago by harlekin

  • description modified (diff)

Changed 14 months ago by harlekin

Apparently a patch by shining has been accepted and will be added to the pacman mainline. I'll fix this ticket once a new pacman snapshot is released and once our pacman packages are recompiled against that version.

Changed 14 months ago by harlekin

  • priority changed from major to minor

Changed 13 months ago by harlekin

  • status changed from reopened to closed
  • resolution set to fixed

This is fixed in pacman 3.3.0. I am currently uploading the new packages.

Note: See TracTickets for help on using tickets.