Install Racket package only if not installed - package

I can install a Racket package with:
raco pkg install <pkg-name>
If the package is not installed, it installs it. If the package is already installed however, it will complain that the package is already installed. While this is fine, is there a better way to check if a package is installed, and only try to install it if its not already installed?
For context, I want this because I have a (non-package) Racket project that relies on certain packages being installed. I could put them in an info.rkt file, but as far as I can tell, these won't get installed unless I try to install the project as a package, which doesn't make sense for this domain.
So, is there anyway to determine if a Racket package is installed? Additionally, can I use this information to only install a package if its not already installed?

Yes, in fact you can. If you are using a shell program or makefile (basically, using the raco pkg tool from the command line), you can pass it the --skip-installed parameter. This will only try to install the package if its not already installed. So you could do something like this in a mace file:
all: # Replace spaces here with tabs, because make...
raco pkg install --skip-installed <important-pkg>
<rest-of-makefile>
Alternatively, if you are looking for an 'in Racket' solution, you can use the installed-pkg-table function to get a hash table containing all of the installed packages. From there, its easy enough to do a hash-has-key? to see if the package is in the table. From there, you can use pkg-install-command to install the package. Your total code will look something like this:
(unless (hash-has-key? (installed-pkg-table) "<important-pkg>")
(pkg-install-command #:deps 'search-auto i))
I should note that there is a slight chance that the package database will change between searching for the key and installing the package. If that is important to you, check out with-pkg-lock

Related

tcms-api 5.3 package incompatible with Windows

I attempted to upgrade my tcms-api library from 5.0 to 5.3 using:
pip install tcms-api --upgrade
on a Windows 10 machine, I saw a lot of errors when trying to install the dependent package of kerberos. Even though this is old, I saw a similar set of errors. The package installation failed since the kerberos package isn't supported on Windows and I was left at tcms-api 5.0.
Please file a bug against https://github.com/kiwitcms/tcms-api.
We can do a quick fix by providing 2 package names:
tcms-api and tcms-api[kerberos]
The first one will not install the kerberos package.
The proposed workaround makes sense but changing the underlying kerberos implementation needs careful testing which isn't a quick job.
OTOH https://github.com/kiwitcms/python-social-auth-kerberos uses gssapi which seems to be the latest and most actively maintained implementation of Kerberos for Python. There is an open issue to migrate to that in tcms-api so you can contribute if you want.
As a workaround, I was able to do the following (caveat: I haven't extensively tested my installation yet):
Clone the tcms-api repo from GitHub
Edit setup.py to change the install_requires line to use 'kerberos-sspi' rather than 'kerberos'
Install the following pip packages: Setuptools, Wheel, Twine
CD to repo folder and run: python setup.py bdist_wheel
That creates a package under the dist folder
Run pip install dist\tcms_api-5.3-py3-none-any.whl
Celebrate successful package install
The steps were modified from this page.
Update:
I confirmed the things I need the API to do work with my custom package (create and update test runs). However, I'm in a situation where I don't need to specifically harden my Kiwi instance using kerberos authentication.

Installing mongodb-enterprise-server error

Hello guys. Can someone help me about this one? I cant install mongodb because of dependency problem. I already tried updating my linux mint terminal.
dpkg: dependency problems prevent configuration of mongodb-enterprise-server:
mongodb-enterprise-server depends on libcurl3 (>= 7.16.2); however:
Package libcurl3 is not installed.
mongodb-enterprise-server depends on snmp; however:
Package snmp is not installed.
Installing via dpkg -i mongodb.deb will not include additional package dependencies. You should be able to fix your installation by following up with sudo apt --fix-broken install.
Unless you have strong reasons to avoid the standard process I would recommend following the tutorial to Install MongoDB Enterprise by adding the appropriate repo definitions. Adding the normal package repo will also make it easier for you to update to newer minor releases of MongoDB 4.0.x.

How to build Mongodb C driver without sudo

I am trying to build the C driver of MongoDB afetr I have build MongoDB and started it.
On github, I have found that I need root privileges to build it (I need to run it with sudo).
Is it possible to do it without sudo ?
The instructions there state
make
sudo make install
So you ARE building as a normal user, but of course, installing it will require root privileges.
On a side note: using DESTDIR will install with a prefix the binaries don't know about. Software installed with DESTDIR is typically not runnable from the place it is installed. If you want to install in a non-standard location, do it at build-time (e.g. if the project uses autotools, pass a --prefix=/home/foo/mytree to ./configure).
DESTDIR is only useful for creating packages. I use my own little package manager implemented in perl for managing installations in the /usr/local tree. It works by setting DESTDIR to /usr/local/pkg/<product_name> with make install and then symlinking everything to its correct location.
I have just now realised that I can change the installation directory while installing using DESTDIR as a destination directory.
In my case it would look like this: make DESTDIR=new_path install

how to create a debian package using “equivs-build” which can be “upgraded” if already installed?

I have created a .deb package using equivs-build command and providing necessary control, preinst, postinst, etc. I noticed that version can also be mentioned in control file. Now I want to create a .deb package with updated source code and I want to enable user to upgrade the package if it is already installed (and is of previous version, of course), as I won't be changing conf related files, etc. One way I can think of is to write a shell-script which will first check for installed version, and will take actions accordingly (i.e. if installed, just update the source-code, database-migrations, etc. and if not, install the package using dpkg -i <package-name>). I was wondering if there was a way to achieve using dpkg only (something like dpkg upgrade <package-name>) which will handle installation or up-gradation as required.
That's already how it works.
dpkg -i package_0.123.deb will upgrade if the version of package is less than 0.123, removing the previous version if necessary (there's an option to force a downgrade, too). apt-get install package will install the newest version of package, removing the old one and upgrading to a new one if necessary. apt-get upgrade will upgrade all packages to the newest version.
Basically, just take care to monotonically upgrade the version number each time you publish a new build.
If you didn't specify a version previously, the default will be something simple like 1.0. Just make it bigger than that.

Solaris pkgadd ignores dependencies

I have a Solaris package with depend file. When I install the package, it ignores the dependencies.
My depend file looks like this:
P SUNWcsu Core Solaris, (Usr)
P XXCore My core package
I am able to install the package even if XXCore is not installed.
My Prototype looks like this:
i pkginfo
i depend
i request
Thanks in advance.
BTW, other install files (request, checkinstall, etc) are handled correctly.
UPDATE:
I have made some changes to the depend file so it looks like one that works fine. I only changed Tab to white space. Now it behaves differently - I get the following:
Verifying package dependencies.
WARNING:
The XXCore package "My core package" is a
prerequisite package and should be installed.
Do you want to continue with the installation?
It is better, but I want the installation to stop, without the option to continue
Should you want to enforce a prerequisite, you can prevent the package installation by using a checkinstall or preinstall script that check for required the package presence and exit in error if not.

Resources