ballerina-distribution
ballerina-distribution copied to clipboard
ballerina deb installer not working in ubuntu
Description:
When we have previous versions installed, ballerina deb installer gives an error.
Steps to reproduce:
Affected Versions: swan-lake versions
OS, DB, other environment details and versions: Ubuntu
Related Issues (optional):
Suggested Labels (optional):
Suggested Assignees (optional):
When there is no other previous version installed, deb installer works fine. But we have to remove all the files (not only /usr/lib/ballerina
directory).
I tested with the flag --force-overwrite
suggested and it works and can be accepted as a workaround.
Related issue ballerina-platform/ballerina-update-tool#225. But this is for installing for the first time.
I added a preinst script to deb package installer to remove the usr/lib/ballerina/COPYRIGHT.txt
file. It seems like the file was removed successfully when I try to use deb package installer but it gives the same error as above.
I deleted usr/lib/ballerina
folder and tried to install another version. It gives the same error even if the file does not exist.
There is a set of files related to installed version in /var/lib/dpkg/info
directory. When we remove those files, we can install through deb installer.
I installed a version and then deleted files in /var/lib/dpkg/info
directory related to installed version.
Then I tried to install another version using deb installer and it was installed without any issue. The issue lies within those files.
When we are using a preinst (runs before installation) script, we can remove ballerina related files in /var/lib/dpkg/info
directory. But the error message gives eventhough the files have been deleted. In the second attempt, it installs without any issue since the files have been deleted in the previous attempt. There is some kind of a check prior to pre-installation script.
I think this is a security feature of dpkg not to mistakenly change files related to another installation. I think a simple solution is not to have shared files across different ballerina versions. That way, we should have clean installs and uninstallations as well.
As an example, COPYRIGHT.txt
can be in a unique location to the installation version.
Else if we conditionally check if we need to update COPYRIGHT.txt
and only update it necessary most of the setups will work. But when we have an update to the COPYRIGHT.txt
file now, we should ask the user to delete that file to update it. But is it ethical and allowed to have the COPYRIGHT.txt
file for the common files shared with older versions on ballerina as well?
By deleting /var/lib/dpkg/info
, we may be fooling the system that we don't have any or any older versions of ballerina versions installed. I believe /var/lib/dpkg/info
path keeps the information about shared files and locations of all the files installed by a package in more important locations like COPYRIGHT.txt
and thus deleting it resolves the error message. But that is not the fix. Indeed solution is not to have shared files across versions.
If the conditional checks work on updating files. We can ask the user to use --force-overwrite
when installing the new version of the ballerina. But this may break older versions. So we suggest cleaning and re-installation.
Maybe a conditional check for file hashes of common files to decide whether to update or not. My concern is allowing a common shared file may encourage in the future to have shared files related to the compiler, in which case the new forced installation will break older versions.