Check if a port is installed on FreeBSD - freebsd

How can one check if a port is already installed on FreeBSD?
This is to be used in a shell script for provisioning. i.e. if port is already installed skip install, else call make command

Under FreeBSD 10+, you can use "pkg". The good reference is: https://wiki.freebsd.org/PkgPrimer
If your port is installed, it will result in:
# pkg info apache-jmeter
apache-jmeter-3.0.r2
Name : apache-jmeter
Version : 3.0.r2
Installed on : Thu May 5 18:58:45 2016 MSK
Origin : www/jmeter
Architecture : freebsd:10:x86:64
...
Otherwise:
# pkg info jmeter
pkg: No package(s) matching jmeter

You should never use "pkg delete"/"pkg remove" on software that you have installed via
the ports, but rather "make deinstall" from inside the ports tree. Doing "pkg install"
downloads a precompiled package to your system and installs it.
Doing "pkg info " will *not tell you if it was installed from ports.
I'm afraid the quoted statements are incorrect.
A 'port' is simply a 'package' that hasn't been compiled and installed yet.
Installed ports are in fact packages and can be treated like any other package regardless if it was downloaded pre-compiled and installed via pkg(8) or compiled locally from the ports tree and then installed. The terms 'port' and 'package' are synonymous once the software is 'installed'.
pkg delete/remove <portname> can and should be used and may be preferable as it will prompt to also uninstall no longer needed dependencies.
make deinstall in a specific port's directory will only uninstall that port and nothing else.
pkg info pkg info <portname> is the correct answer.

Related

npm does not install any package Cannot read property 'version' of null

i'm using node v16.7.0 and npm v7.20.3. I bought new laptop(w10) and installed node but since that(almost a week), i couldn't start any node related project because i can not install any npm package. Whenever i try to 'npm install'
npm install <package>
I get the error:
npm ERR! Cannot read property 'version' of null
I dig into all around web to find a solution for this but i couldn't get one. Can someone help me with this issue this is my first question in Stackoverflow.Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux) will i get less errors with development tools even though i'm into web development nothing to do with kernel. Thanks...
Edit: I had spaces and non English character in my username folder in Windows so i tried changing my username and username folder and it solved my problem.(Note that changing username does not reflect to username folder you have to set extra configuration for that).
The error message means that npm is trying to read the version property of the folder's package.json file but doesn't find the file.
Check that you have a package.json file inside your folder, and see what's the value of the version property.
If you need to create a package.json file out of the box, run npm init and follow the instructions. For more information, view the npm documentation about npm init.
Also, make sure that you've installed Node correctly. It's recommended to use a Node version manager to manage your Node installations.
Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux)
will i get less errors with development tools even though i'm into web
development nothing to do with kernel
Yes, and dual-booting with Ubuntu would be best. Virtual machines can be slow and require additional configurations to improve performance, and a lot of issues are reported on WSL.
Most development tools work natively with Linux and therefore run better on Linux. Ultimately, it depends on what language you're developing with and what environment you're developing for.
In general, Linux will make your development experience much less of a hassle. Information, tutorials, and troubleshooting about those tools is also more easily available for Linux.
One of the best things about switching from Windows to Linux is for package management and the command-line interface. Linux makes it easy and straightforward to run commands, whereas Windows can require additional configurations, other workarounds, and intermediary steps.

Install TCP Wrappers in Slackware 14.2

How to install TCP Wrappers using the appropriate package manager? When I run pkgtool, I can see in the list that tcp_wrappers is included tcp_wrappers-7.6-x86_64-1. I want to install it.
I tried the command below, with no luck.
installpkg tcp_wrappers-7.6-x86_64-1.tgz
Whenever I run the command above, it says
Cannot install, file not found.
So I navigated to /var/log/packages, where the list of Slackware packages are listed and I found there tcp_wrappers-7.6-x86_64-1 file. So what I did is:
mv tcp_wrappers-7.6-x86_64-1 tcp_wrappers-7.6-x86_64-1.tgz
installpkg tcp_wrappers-7.6-x86_64-1.tgz
The prompt message is :
Verifying package tcp_wrappers-7.6-x86_64-1.tgz
gzip : stdin : not in gzip format
Installing package tcp_wrappers-7.6-x86_64-1.tgz:
PACKAGE DESCRIPTION:
WARNING: Package has not been created with 'makepkg'
Package tcp_wrappers-7.6-x86_64-1.tgz installed.
After, I verified whether the tcp_wrappers is already installed using the commands below, with no luck.
rpm -q tcp_wrappers
rpm -q tcp_wrappers-7.6-x86_64-1
rpm -q tcp_wrappers-7.6-x86_64-1.tgz
It just say:
package tcp_wrappers is not installed
package tcp_wrappers-7.6-x86_64-1 is not installed
package tcp_wrappers-7.6-x86_64-1.tgz is not installed
what shall I do?
If it is in /var/log/packages, then it's already installed. Files in this directory are simple text files with package description, list of installed files etc. Try for example:
less /var/log/packages/tcp_wrappers-7.6-x86_64-1
On my box it shows:
PACKAGE NAME: tcp_wrappers-7.6-x86_64-1
COMPRESSED PACKAGE SIZE: 77.0K
UNCOMPRESSED PACKAGE SIZE: 340K
PACKAGE LOCATION: /usb-stick/slackware64/n/tcp_wrappers-7.6-x86_64-1.txz
PACKAGE DESCRIPTION:
tcp_wrappers: tcp_wrappers (TCP/IP daemon wrapper library and utilities)
tcp_wrappers:
tcp_wrappers: With this package you can monitor and filter incoming requests for
tcp_wrappers: network services for access control, and detection things like host
tcp_wrappers: name spoofing and host address spoofing. Nearly all the network
tcp_wrappers: daemons on Slackware are "wrapped" using this library, and most
tcp_wrappers: daemons in /etc/inetd.conf use tcp_wrappers' tcpd wrapper daemon.
tcp_wrappers: If you plan to do much networking, you will need tcp_wrappers.
tcp_wrappers:
tcp_wrappers: tcp_wrappers was written by Wietse Venema.
tcp_wrappers:
FILE LIST:
./
install/
install/slack-desc
usr/
usr/doc/
usr/doc/tcp_wrappers_7.6/
usr/doc/tcp_wrappers_7.6/BLURB
usr/doc/tcp_wrappers_7.6/CHANGES
usr/doc/tcp_wrappers_7.6/DISCLAIMER
usr/doc/tcp_wrappers_7.6/README
usr/doc/tcp_wrappers_7.6/README.NIS
usr/include/
usr/include/tcpd.h
[ cut ]
rpm is RedHat tool. It will not show this package as installed, because pkgtool used by Slackware is not related to rpm in any way - it doesn't update rpm package database. rpm is installed in Slackware only for installing rpm packages, not to manage packages installed by native pkgtool.
To test, whether the packet has been installed or not, one should simply issue the command:
slackpkg search tcp_wrappers
Output will be (e.g. on Slackware 12.0)
The list below shows all packages with the selected pattern.
[ installed ] - tcp_wrappers-7.6-i486-1
The `slackpkg' allows to install, remove, list etc packets in the system. Please see the get the help option.
As for TCP_wrappers, it is included in Slackware long ago, I think

How to install Node.js only if needed (not already installed) on a vagrant shell?

I'm using vagrant shell provisioning here.
I've installed on my vm Node.js along with many other packages.
I want to avoid running parts in my provisioning script when I don't need them.
For example - I already successfully installed via my script Node.js & nginx, so when I want to add additional packages like mysql or redis, I want to add it to the script, I want to run the script to test that it runs properly, but I DO NOT want to re-install Node.js or nginx again...
I need a simple conditional statement that would detect if a package is already installed, and install it only if it is not already installed.
Is there a generic check or will it be different from package to package?
Thanks
Ajar
dpkg -s <pkg-name> 2>/dev/null >/dev/null || sudo apt-get -y install <pkg-name>
This should be what you're looking for.
What's going on here:
This is a conditional assignment of the form <condition> && <value if true> || <value if false>
The first part of the expression uses dpkg to check to if the package is installed, suppressing the output. The second part is evaluated if the condition returns false. The "true" case is omitted.
This dependes on the Linux distribution you are using. Usually, a package manager comes with some kind of mechanism to skipp already installed packages.
For Ubuntu, this is built in - running apt-get install nodejs with Node.js already installed will not reinstall it; it will skip the target (unless there is new version available)
For ArchLinux, you can add run pacman -Sy node --needed to skip already installed packages.
A platform-independent mechanism would be to check if the executable (or any other known file for that package) exists. In Bash, you can do:
which node > /dev/null && echo "Yup, this is installed"
(the > /dev/null part supresses which's output - it prints the path where the found executable resides; we do not care about that, we only want to know if it is installed)
If you want to avoid writing custom Bash scripts for such basic checks I can recommend that you configure your boxes with tools dedicated for exactly what you are trying to achieve. The usual suspects here are:
Ansible
Puppet
Chef
CFEngine
All of these are supported by Vagrant so integrating them should not be a problem. You can find detailed guides on integrating these into your existing Vagrant recipe here.
PS. For a simple exapmle you can check out my Ansible provisioning recipe for Banana Pi machine running ArchLinux (note: it does not really follow best practices, but it might be a good starting point). There are many examples available online, check them out, too.

macports install obsolete port

When I execute sudo port install py33-pyqt5 in my terminal, I get this error message:
---> Configuring py33-pyqt5
Error: py33-pyqt5 has been made obsolete by the port py34-pyqt5. Please install py34-pyqt5 instead.
Error: org.macports.configure for port py33-pyqt5 returned: obsolete port
Please see the log file for port py33-pyqt5 for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_python_py-graveyard/py33-pyqt5/main.log
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port py33-pyqt5 failed
But I need to install py33-pyqt5 and not py34-pyqt5. Is there a possible way to install the old version?
You can use the same approach that is used to install an older port: http://trac.macports.org/wiki/howto/InstallingOlderPort. For a Python port that uses the subport feature, that probably means finding an older version of the Portfile that now provides py34-pyqt5 that did still provide py33-pyqt5 and running sudo port install -- subport=py33-pyqt5 in a directory that contains this older Portfile. Note that the Portfile and the directory must be readable by the macports user, so your home directory will probably not work very well. I recommend a place in /tmp.
There has been a decision to phase out support for python 3.3 in MacPorts, though -- you will run into more and more problems when trying to use Python 3.3, so you should really consider switching to a newer version.

Error while install gcc49 in Ubuntu by using linuxbrew

I want to install the latest gcc49 in a Ubuntu Linux, and I am familiar with Homebrew in Mac, so I would like to use the Linux version of it, i.e., Linuxbrew. So I installed Linuxbrew and typed
$ brew install gcc49
The dependencies gmp4, mpfr2 and etc. will be installed first. I have added a if OS.mac? condition in gmp4 so it can be installed successfully, but when installing mpfr2 (also added the condition), the make check failed with the error:
...
/tmp/mpfr2-i5YD/mpfr-2.4.2/tests/.libs/lt-tpow_all: error while loading shared libraries: libgmp.so.3: cannot open shared object file: No such file or directory
FAIL: tpow_all
=======================
148 of 148 tests failed
=======================
As you can see, the tests can not find libgmp.so.3 which is just installed. But gmp4 is keg only since it will conflict with gmp in main repository.
But the configure options are set with the correct location of gmp4:
./configure --disable-dependency-tracking --prefix=/home/dongli/.linuxbrew/Cellar/mpfr2/2.4.2 --with-gmp=/home/dongli/.linuxbrew/opt/gmp4
How to solve this problem? Thanks!
You think you are doing it wrong by insisting on a third-party scripting solution that is not native to the OS.
There are prebuilt versions of gcc et al provided by the same maintainers in this PPA on Launchpad. These are previews / testreleases of what will be in the next Ubuntu releases.
I found the problem, that is the environment has been reset after each system call in Ruby formula. So we need to set the correct LD_LIBRARY_PATH as
if OS.linux?
ENV["LD_LIBRARY_PATH"] = "#{Formula["..."].opt_prefix}/lib:...:$LD_LIBRARY_PATH"
end
so that LD_LIBRARY_PATH persists during the build processes.

Resources