Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing in a chroot envrionment gives errors #91

Open
intelliant01 opened this issue Jan 14, 2022 · 2 comments
Open

Installing in a chroot envrionment gives errors #91

intelliant01 opened this issue Jan 14, 2022 · 2 comments

Comments

@intelliant01
Copy link
Contributor

intelliant01 commented Jan 14, 2022

Have a squashfs Ubuntu 20.04 OS image which I have loop mounted and tried to update the kolibri-server package.
Package - kolibri-server_0.4.0-0ubuntu2_all.deb

I got these errors -

root@server:/# apt install kolibri-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  kolibri-server
1 upgraded, 0 newly installed, 0 to remove and 106 not upgraded.
Need to get 0 B/22.5 kB of archives.
After this operation, 2,048 B of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 421367 files and directories currently installed.)
Preparing to unpack .../kolibri-server_0.4.0-0ubuntu2_all.deb ...
Running in chroot, ignoring request.
INFO: Already stopped: Stopped
invoke-rc.d: initscript kolibri-server, action "stop" failed.
dpkg: warning: old kolibri-server package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Running in chroot, ignoring request.
INFO: Already stopped: Stopped
invoke-rc.d: initscript kolibri-server, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/kolibri-server_0.4.0-0ubuntu2_all.deb (--unpack):
 new kolibri-server package pre-removal script subprocess returned error exit status 1
Running in chroot, ignoring request.
Errors were encountered while processing:
 /var/cache/apt/archives/kolibri-server_0.4.0-0ubuntu2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

The install process should have completed without any errors in the chroot envrionment.

@intelliant01
Copy link
Contributor Author

@jredrejo Only two lines in the respective files, that are being generated by the debhelper seem to be the cause of the above issue in a chroot env wherein no services are active.

Specifically the exit 1 in /var/lib/dpkg/info/kolibri-server.prerm results in the above error.

In /var/lib/dpkg/info/kolibri-server.prerm:

# Automatically added by dh_installinit/11.1.6ubuntu2
if [ -x "/etc/init.d/kolibri-server" ]; then
        invoke-rc.d kolibri-server stop || exit 1
fi
# End automatically added section

should be

# Automatically added by dh_installinit/11.1.6ubuntu2
if [ -x "/etc/init.d/kolibri-server" ]; then
        invoke-rc.d kolibri-server stop || ! ischroot && exit 1
fi
# End automatically added section

In /var/lib/dpkg/info/kolibri-server.postinst:

# Automatically added by dh_installinit/11.1.6ubuntu2
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
        if [ -x "/etc/init.d/kolibri-server" ]; then
                update-rc.d kolibri-server defaults >/dev/null
                invoke-rc.d kolibri-server start || exit 1
        fi
fi
# End automatically added section

should be

# Automatically added by dh_installinit/11.1.6ubuntu2
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
        if [ -x "/etc/init.d/kolibri-server" ]; then
                update-rc.d kolibri-server defaults >/dev/null
                invoke-rc.d kolibri-server start || ! ischroot && exit 1
        fi
fi
# End automatically added section

invoke-rc.d is inherently chroot safe i.e. it identifies a chroot and prevents execution of the "action". However, the additional exit 1 added by the dh_installinit generated code causes the termination. I tried reading up on how to override the addition of exit 1 or make it conditional with a ! ischroot, but could not find a solution.

@intelliant01
Copy link
Contributor Author

With the help of @cyberorg figured out that the root of the problem is in /etc/init.d/kolibri-server in the start and stop cases -

Detecting chroot and exiting with status 0 helps fix it -

# diff /etc/init.d/kolibri-server.old  /etc/init.d/kolibri-server
136a137
>     ischroot && exit 0
149a151
>     ischroot && exit 0

This seems to be the only feasible method because $SU_COMMAND $KOLIBRI_USER -c "$KOLIBRI_COMMAND stop" always returns an exit status 1 in chroot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant