For a Debian installer script, if there is an error within the postinst script or the user uses Ctrl+C to kill the process, is it possible to have the entire install be rolled back? It looks like even if I return a non zero exit code, it still leaves the program installed.
Rollback on Error in PostInst Script in Debian Installer
818 views Asked by rsjohnso At
1
There are 1 answers
Related Questions in BASH
- When does Bash read heredocs?
- Why `set -o pipefail` gives different output even though the pipe is not failing
- Run an external command within jq to manipulate each values of a particular key
- API key 401 error in .env.development file
- How to "Enable mobile data" on a Huawei E3372 4G USB dongle using a bash script in Windows
- ImageMagick / Bash : pipe ignored(?) when filename format variable used
- MacOS Bash-Script: while read p and echo
- Parse command line arguments and write useful usage message without additional code
- JQ JSON - Values to Array
- why variable substitution is so different?
- postbank_pdf2csv: how to setup with Cygwin in Windows?
- Custom Bash functions & custom statements - Need some advice
- unexpected operator == in square brackets when trying to use gum lib
- How to disable a bash builtin inside a docker container
- Use sed or rename find series of alphabet then replace with with the same alphabet and a dash -
Related Questions in INSTALLATION
- INSTALL_FAILED_DUPLICATE_PERMISSION: Package
- How can i install pyaudio on MacOS
- Problem installing Manim on Windows 11. Error regarding the wrong "decorator" version
- 'No such file or directory' installing RTC-Tools through pip
- Install Postfix Mail Server
- Plugin with id 'com.android.application' not found in Github Winlator Project
- OSError: [WinError 5] Access is denied: 'c:\\python311\\scripts\\pip.exe' Consider using the `--user` option
- Installing the C compiler for LC3
- Why is installation of MySQL on my mac is always halted
- OS: Parrot OS (hashcat : Depends: libminizip1t64 but it is not installable)
- GROMACS 2024 with CP2K 9.1 BUILD
- After the installation process When the server is running, nothing is displayed on the page myddleware
- PHP php_mongodb.dll for 32bit
- A given package is installed but spyder won't see it
- I cant install libraries?
Related Questions in ROLLBACK
- Rollback to Savepoint with H2 Database
- How to Revert Database Changes Made in a Session Without Using Transaction Management?
- Unwanted Rollback in Postgres - missing data after commit
- How to add the transaction and rollback for the query in the repository layer for the python api
- Rollback Mechanism For Third Party Services
- Wordpress - Azure AppService database "rollback"
- Ansible rollback on multiple hosts when one of the roles fail. How to pass variables between different plays?
- Liquibase - fix wrong rollback statement
- How to undo Git - All conflicts fixed but you are still merging
- Rollback migration in laravel
- Get Second Last commit SHA of a branch using GitHub Actions
- Rollback to 120.0.2210.144
- access airflow task arguments in the on_failure_callback function
- How to implement rollback of multi-statement transaction in SQLite?
- Rollback statement Oracle
Related Questions in DEB
- DEB how do I save the configuration files of packages that are deleted during the installation of my package?
- How to uninstall a package using python-apt and also remove dependencies?
- Read information from inside DEB package in preinst
- MPR makedeb/mist is not working for the python3-krfzf-py-git 0.0.4.r1.e403493-2 package: unrecognized argument: --prefix=/usr
- Sonatype Nexus Private Repository unable to prompt for username and password in runtime while pulling the package using cli
- Create .debs using Makefile in linux
- How can I sign a Debian package created from rust project?
- Building a .deb-file for Raspberry Pi
- App icon from deb package not showing on Gnome
- SSL verification problem when uploading a deb package using dput
- How to add custom metadata using fpm for rpm/deb pacakges
- cpack -B build/ fails in parent directory
- Create changelogs for reprepro debian repository
- Make deb-package which updates another deb-package
- MD5 Error while installing package libc6:i386 on Crostini
Related Questions in POST-INSTALL
- Whats the difference of Podfile post_install config loops in build_configurations
- Problem deploying project (prisma, crud, nextjs, netlify)
- Does Xcode post install supports relative path
- Can not import post-install events from Branch to Google
- npm 8.19 (node 18) not running prepare or postinstall scripts from packages
- Add postinst script to hello-traditional Debian package
- In which directory does npm postinstall run?
- npm not found in debian package post installation script
- .Deb package postinst file not appending data to ~/.bashrc
- How to get Nuxt 3 postinstall hooks log to stderr instead of /tmp/.../build.log in GitHub Actions?
- Why postinst not running after installation?
- Is there a way to only run npm scripts for installed packages (opposite of --ignore-scripts)
- Is there a way to run `postinstall` only when installing locally and not when being installed as a dependency?
- lerna bootstrap info undefined@undefined~postinstall: undefined@undefined
- Npm install postinstall cannot find module
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
No.
Well, it's probably possible, because the
postinstruns as root and can do all sorts of tricky stuff to subvert the system. Butdpkgtries to protect against this as much as possible using locks, because maintainer scripts should not ever change the "desired" status of packages.I haven't verified this, but I would guess that if you cancel a
postinstscript with Ctrl+C, it counts as apostinstfailure, and the package is marked as being in thehalf-configuredstate. So, it's not left fully-installed, exactly, but yeah, it might be hard for the user to tell the difference.So, some potential solutions for you:
If your package provides a service, you could have a flag (e.g., a file in some place like
/var/lib/$yourpackage) which is set only when the package is fully installed (at the end of thepostinst). The service would check for this flag on startup, and if it's not present, the service would not start, and might even print a warning message about not being fully installed. This solution would be similar in some respects to having the package totally uninstalled. Remember to unset the flag or remove the file at in theprermand at the beginning of thepostinst(in case a Ctrl+C occurs during an upgrade instead of on the first install).You could catch the Ctrl+C (
SIGINT) in thepostinst, and print a message saying something like "This package will be left in the Failed-Config state. To remove it entirely, run (dpkg -P/apt purge/whatever). To attempt to complete installation, run dpkg --configure -a." (Then exit thepostinstwith a nonzero exit code, so that dpkg knows about the failure.)If you are in a position to do this, make your users more aware of when they have brokenly-installed packages, so they can make the decisions about reinstalling or removing quickly.
You could take whatever thing in your
postinstis most likely to be Ctrl+C'd, and move it to thepreinst. If thepreinstfails, thendpkgwill call thepostrmwith theabort-installaction. Thepostrmis expected to clean up anything that thepreinstalready did. If thepostrmsucceeds, then the package is left cleanly and entirely uninstalled. Of course, if this step of thepostinstneeds the files from your package to be unpacked and present, this isn't really an option.