gcc and w32api not found - gcc

can anybody help me why these packages showed unavailable even they are installed?
I am trying to install NS2.3.5 on windows 10 64bit using cygwin.
as known, the install script of ns will check for required package in cygwin which are installed:
packages_base="gcc gcc-g++ gawk tar gzip make patch perl w32api"
packages_xorg="xorg-server xinit libX11-devel libXmu-devel"
you may notice that I modified the script to check for gcc instead of gcc4 and gcc-g++ instead of gcc4-g++, since the gcc4 is obsolete.
I also run the command gcc -dumpversion and I got the version 4.9.3
the basic command to check the package is:
cygcheck -c gcc
and the expected output is:
Package version Status
gcc-g++ 4.9.3-1 OK
however, the script that checks the packages failed to find gcc and w32api even they are installed. all other packages including gcc-g++ were checked successfully and get the exact version.

Okay,
Tried at my end ( as I already have a cygwin package installed ).
To me, this is more of an issue of "cygcheck" utility than anything else.
At my end too "cygcheck" failed to report details in proper for "gcc", with command "cygcheck -c gcc | grep gcc"
I am suggesting a trick here to over come this, but its just a trick.
In script "install" from "ns-2.35", find a function "test_packages" and change it something like below
test_packages() {
for i in $#; do
echo -n "Checking for ${i}... ";
cygcheck -c ${i} | grep ${i} >/dev/null 2>&1;^M
if [ "$?" -eq "0" ]; then
echo "ok";
else^M
cygcheck -l | grep ${i} >/dev/null 2>&1;
if [ "$?" -eq "0" ]; then
echo "ok";
else^M
echo "NO!";^M
echo "";
echo "Package ${i} is not present on your system.";
echo "";
echo "Please install it using Cygwin's setup.exe";
echo "before trying to install the ns-2 distribution.";
fi;
test_proceed;
fi;
done;
}
Basically rechecking again with "cygcheck -l" after first fail.
This passed the test but, I did not go further with installation.
Also there is a link which explains the installation os ns-2.35 on windows
which could be useful too.
http://www.slideshare.net/TBear76/ns235-installation-3395974

Please try out the 'Nov 2014 update', ns-allinone-2.35_gcc482.tar.gz
https://drive.google.com/file/d/0B7S255p3kFXNSGJCZ2YzUGJDVk0/view?usp=sharing
Can use all gcc/g++ versions 4.4.x .. 5.2.0
ns2

Related

Bash compare local neovim version to desired version

I am working on a script to determine if my local neovim version is below a desired version. I am using bash on PopOS 22.04.
The script will be used for a dev environment setup and lunarvim requires the Neovim version to be 0.8.0+.
The desired end result of the script would do three things:
Check if neovim is even installed.
If it is installed pull the local version and check it against a variable version.
If neovim is an older version it will uninstall it. Another part of the script runs an ansible playbook to add the unstable neovim repository then install neovim afterwards.
I have tried various iterations of using ansible, dpkg, neovim -v, and even trying to shorten the output of neovim -v. Any help is appreciated.
The bash version below is the latest variation of the comparison I have tried. I am running into the error if neovim is not installed it will error out on line three with nvim: command not found (expected error). Afterwards it will print out the final echo statement (unexpected output).
#!/bin/bash
has_nvim=$(command -v nvim >/dev/null)
nvim_version=$(nvim --version | head -1 | grep -o '[0-9]\.[0-9]')
if ! $has_nvim; then
echo "Nvim is not installed"
elif [ $(echo $nvim_version >= 0.9 | bc -l) ]; then
echo "Wrong version of Nvim is installed"
sudo apt remove neovim -y
else
echo "Nvim version 0.9 or greater is installed"
fi
You must add a if/else case not to get Nvim version if not installed.
A fixed version of your code :
#!/bin/bash
command -v nvim >/dev/null
if [[ $? -ne 0 ]]; then
echo "Nvim is not installed"
else
nvim_version=$(nvim --version | head -1 | grep -o '[0-9]\.[0-9]')
if (( $(echo "$nvim_version < 0.9 " |bc -l) )); then
echo "Wrong version of Nvim is installed"
sudo apt remove neovim -y
else
echo "Nvim version 0.9 or greater is installed"
fi
fi

Bash check if nvm installed

How can I detirmine if nvm (Node Version Manager) is installed in bash?
I already have it installed in my system but I haven't been able to make any bash script that can detect it. I am making a script that should be used by others which depends on nvm, so I want to output if it's not installed and exit if it isn't..
This doesn't work: https://stackoverflow.com/a/26759734/846348 it says that nvm isn't installed but the bash script can use nvm..
Would be nice if it supported Mac Terminal, Mac iTerm and Windows with Linux shell at least.
one can check with command -v nvm:
$ command -v nvm >/dev/null 2>&1 || { echo >&2 "nvm is required, but it's not installed. Aborting."; exit 1; }
The nvm install script checks if nvm is installed using roughly the following logic:
if [ -d "${HOME}/.nvm/.git" ]; then echo "nvm installed"; else echo "nvm not installed"; fi
This just checks if the directory ~/.nvm/.git exists.
To exit with failure if the directory ~/.nvm/.git does not exist, you could use:
if [ ! -d "${HOME}/.nvm/.git" ]; then exit; fi
Check if nvm installed using a Makefile
NVM_EXISTS := $(shell if [ -d "${HOME}/.nvm/.git" ]; then echo "nvm installed"; fi)
.PHONY: check
check:
ifndef NVM_EXISTS
$(error Please install nvm: https://github.com/nvm-sh/nvm)
endif
Note on nvm install.sh
The actual install script uses the following functions to determine the nvm installation directory (rather than assuming ${HOME}/.nvm). But if you are using the default location ${HOME}/.nvm, you can skip these checks.
nvm_default_install_dir() {
[ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm"
}
nvm_install_dir() {
if [ -n "$NVM_DIR" ]; then
printf %s "${NVM_DIR}"
else
nvm_default_install_dir
fi
}

How to debug this distro dector in bash?

I am trying to make a distribution checker for an installer but am getting errors that I can not figure out. Would someone help with this distribution checker - am I doing the variable declaration wrong here? The script gives me the errors:
read: `NAME=Fedora': not a valid identifier and blank.
Is there any other way I could achieve the same thing without uname? I'll check uname after I have fixed this so that I can have the installer work on mac as well.
#!/usr/bin/bash
#distribution detection system
NAME=$(head -n 1; grep NAME= "/etc/os-release")
#installer promt
read -p "Install tools [y/n]?" insatll_base
case "$insatll_base" in
y|Y ) echo "installing addtional programs and tools";
#checks for fedora
read $NAME;
if [$NAME="Fedora"]; then
dnf install cpan -y;
cpan install Menu::Item;
fi;
read $NAME;
if [$NAME="NAME=Redhat"]; then
dnf install cpan -y;
cpan install Menu::Item;
fi;
Some observations:
There's no need to use head or grep for /etc/os-release. Just put a . before it, and all its variables are loaded.
When two then ... fi blocks contain the same code, there's no need for two if statements.
Myrddin Emrys' answer to How do I prompt for Yes/No/Cancel input in a Linux shell script? provides a good minimal example of how to use case.
Here is one way to do it:
#!/usr/bin/bash
#distribution detection system
if [ -s /etc/os-release ] ; then
. /etc/os-release
#installer prompt
read -p "Install tools [y/n]?" yn
if [ "${yn,,}" = y ] ; then
echo "Installing additional programs and tools...";
#checks for Fedora or Redhat
case "$NAME" in
Fedora|Redhat) dnf install cpan -y
cpan install Menu::Item ;;
esac
fi
fi

check if gpg-agent is installed from bash

I'm looking for the best way to check if gpg-agent is installed in a a machine.
I need to check from a shell script.
Thank you.
You may have to modify the path. Tested with RHEL 6 and 7.
if test -x /usr/bin/gpg-agent; then echo installed; else echo not installed; fi
Or:
if [ -x /usr/bin/gpg-agent ]; then echo insatlled; else echo not installed; fi
Further Reading: help test.

Using Cygwin for FFMPEG build error cmp: command not found

I've been trying to use Cygwin to build ffmpeg but I'm running into the error ./configure: line 1132: cmp: command not found. I tried looking around online for solutions but found none. I also checked if I just didn't download the right package when I downloaded Cygwin but I found nothing relating to cmd. I'm not sure if there is a workaround or not. The code from line 1132 is:
cp_if_changed(){
cmp -s "$1" "$2" && echo "$2 is unchanged" && return
mkdir -p "$(dirname $2)"
$cp_f "$1" "$2"
}
Thanks
You want to install the cygwin diffutils package.

Resources