How to use CLIPS rule based engine in a linux environment - rhel

I am new to computer science. My project requires to use CLIPS rule based engine and it runs in a RHEL box. Looking at the download link for clips
(http://sourceforge.net/projects/clipsrules/files/CLIPS/6.30/) there is no linux package available. I was wondering if this means I need to build it out of the source files to use it in RHEL?
Thanks in advance.

There are instructions in section 2 of the Advanced Programming Guide, http://clipsrules.sourceforge.net/documentation/v630/apg.htm, for recompiling CLIPS on different platforms. The simplest way to create an executable is to place the core source code in a directory and compile it with a single line command:
gcc -o clips -DLINUX=1 *.c -lm
If you get any errors, try compiling with the GENERIC flag rather than LINUX:
gcc -o clips -DGENERIC=1 *.c -lm

For Ubuntu 20.04 (Focal Fossa) you'll have to download and manually install the packages libclips, clips-common, and clips (in that order) from
https://packages.ubuntu.com/groovy/clips
Use the following command for each package file:
$ sudo dpkg -i packagefilename

for ubuntu:
$ sudo apt-get install clips

First you go into https://sourceforge.net/projects/clipsrules/files/CLIPS/6.40/
Download the core file, name : clips_core_source_640.tar.gz
Then unzip the folder,you will find a folder there named Core.
Go inside the folder,open terminal and run "make" command like this
make
Then you will be able to run clips with
./clips
You can run clips only in the core file
EDIT:
I found out how you can run clips from everywhere,
Go inside the core folder and run:
sudo cp clips /usr/local/bin
sudo cp libclips.a /usr/local/lib
sudo cp clips.h /usr/local/include
With this way you will be able just to type clips and run it wherever you are.

Related

Is it possible to generate linux .rpm packages from flutter linux app?

As far as I know, Flutter for linux app only targets snap packaging format.
Is it possible to generate .rpm and .deb (cross-linux platform) software packages from the flutter build?
Kindly post any help on how to package a flutter-linux app as RPM package
Building RPMs and DEBs is doable, but a pretty involved process. I will try to outline the basic process for RPM's as best as I can. The process of making a DEB is mostly the same with a few differences. I will stick to RPM's for now.
The main thing which is a pain is that to build packages you need specific tools which are only available on the distros. So if you want to do this cross platform (generate a RPM on a ubuntu machine for example) we need to use Docker.
Create a Dockerfile which in which we will install the rpm-build package which contains all tools to build RPMs.
FROM centos:7
RUN yum install -y -q rpm-build
Build this dockerfile and remember the docker image, we will need it later.
Execute the following command mkdir -p build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}. This will create the directory structure required for rpmbuild
Create a .spec file, this file is a config file for the rpmbuild command and place it in the build/SPECS directory. The contents of this file are very specific to the what the package has to do. RPMs are very flexible and can do lots of stuff ranging from just copying files to running complex bash scripts on the target machine to perform compilation on the target machine and perform complex installations. Here are some guides which I found useful: package guide, fedora guide, and redhat guide.
Download the files you want to package, often they are distributed as tarballs and place it in the build/SOURCES directory.
Now we can execute the following command docker run --rm -v $(pwd)/build:/rpmbuild {name of image} /bin/bash -c "cd /rpmbuild && rpmbuild --define '_topdir /rpmbuild' -ba SPECS/flutter.spec"
I will break the command down.
docker run --rm -v $(pwd)/build:/rpmbuild {name of image} - we start a container from the image we created earlier, and mount the build dir in which our .spec and .tar.gz are located so the container can see them. --rm cleans up the container after we are done since we don't need it after the first command.
/bin/bash -c - this is a trick since we need to execute 2 command inside the docker container, if we don't do this our shell will thing the && is meant after the docker command and not passed to the container.
"cd /rpmbuild && rpmbuild --define '_topdir /rpmbuild' -ba SPECS/flutter.spec" - move to the mounted build directory and build the RPM package. the -ba option tells rpmbuild to build both the binary and source packages in case you want the source package as well.
If all went well your should now have an .rpm file in the build/RPMS and a source package in the build/SRPMS directory.
For DEB the process is almost the same, except you need a debian or ubuntu docker image, you use the dpkg-deb command to build and you need a control file instead of a .spec file(same purpose different format)
I will also go over some of the key parts of building rpm packages for flutter applications in case the previous answer was ambiguous.
I have already written an article going into details but here I will only highlight the key parts. You can find the article here
Also for simplicity of explanation, I will be using cool-app as an example throughout this post.
1- Run flutter build linux to get the Linux build inside the build folder in your project root directory.
2- Copy your bundle folder someplace else and there, rename it according to app-name-version semantic. e.g. cool-app-1.0.0
3- Create a .desktop file. e.g. cool-app.desktop will look like the following :
[Desktop Entry]
Name=My Cool App
Comment=A cool app that does everything
Exec=/usr/bin/cool-app/cool-app
Icon=/usr/bin/cool-app/data/flutter_assets/assets/icon.svg
Terminal=false
Type=Application
Categories=Utility;
change the properties accordingly and place the .desktop file inside cool-app-1.0.0 directory
4- run mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} in your home directory.
5- copy the cool-app-1.0.0 directory to ~/rpmbuild/SOURCES.
Due to a problem that as the time of writing this still persists, the rpath for lib*_plugin.so files point to user's build tree path which results in rpmbuild failure.
6- Run patchelf --print-rpath * inside cool-app-1.0.0/lib and check the output. If the output contains a path from your home directory, run patchelf --set-rpath '$ORIGIN' * to fix the rpaths, then check again. now all paths must be $ORIGIN. (This was the way I was able to fix it, not sure if it's the best solution)
You can check this github issue for further information.
7- cd into ~/rpmbuild/SOURCES and run tar --create --file cool-app-1.0.0.tar.gz cool-app-1.0.0 to create a tar.gz file.
8- Create a file named cool-app.spec inside ~/rpmbuild/SPECS directory.
Sample cool-app.spec file :
Name: cool-app
Version: 1.0.0
Release: 1%{?dist}
Summary: Very cool app
BuildArch: x86_64
URL: https://github.com/CoolDev/cool-app
License: GPLv3
Source0: %{name}-%{version}.tar.gz
Requires: bash
%description
A very cool app that does everything
%prep
%setup -q
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_bindir}/%{name}
cp %{name} $RPM_BUILD_ROOT/%{_bindir}/%{name}
cp -R lib $RPM_BUILD_ROOT/%{_bindir}/%{name}
cp -R data $RPM_BUILD_ROOT/%{_bindir}/%{name}
desktop-file-install %{name}.desktop
%clean
rm -rf $RPM_BUILD_ROOT
%files
%{_bindir}/%{name}
/usr/share/applications/
You could use the same template and only change Name,Version,Summery,Release,BuildArch,URL,License,%description and you will most likely be fine.
I went over the spec file in more detail in my article mentioned in the beginning of this post.
9- run rpmbuild --bb cool-app.spec to get your rpm file inside ~/rpmbuild/RPMS directory.

How do I "install" a program once I compile it, so I can run it from the command line?

Archlinux.
I downloaded mtools, which includes mcopy, which is what I'm after. The instructions in the INSTALL file say do this:
# ./configure
# make
These worked fine, now I have a bunch of .o files and of course executables.
What do I need to do, so I can just type
# mcopy
and have it run? Since I don't have it "installed" right now, doing that just says
-bash: mcopy: command not found
The usual linux build sequence is
./configure
make
make check
sudo make install
make check attempts to validate if the build took place correctly; not all Makefiles have it but many do. Note you will need sudo make install to do the install in the usual system directories if you are not root.
You can determine which of these options is available for your particular Makefile by
cat Makefile
and reading the labels on the left of the file.
You could create a symbolic link to the application in your /usr/bin folder like
ln -s /fullpath/to/app /usr/bin/aliasnameforapp
Then you can simple call aliasnameforapp from anywhere.

Files installed from debian package with dpkg do not belong to root

I created a binary package with this command:
dpkg-deb --build -z9 -Zlzma $(DEB_SRC_DIR) $(DEB_DEST_DIR)
and install it on my Ubuntu 12.04 with this command:
sudo dpkg -i /path/to/package
The contents of the package I think are irrelevant.
Despite the sudo command the files in the installation directory belong to the current user and not to root as I expected.
How can I fix that?
Try to run the dpkg-deb command with fakeroot:
`fakeroot dpkg-deb ...`
(This will only help if the files in the source directory already have the correct ownership, which they probably dont. The problem you're actually trying to solve here, is to create an archive with files in it that belong to user root, which is where fakeroot theoretically helps.)
Let me say though, that what you are doing is not the best way for creating a binary package (far from it).
Instead, create a debian/ directory with dh_make (from the dh-make package), and edit the control file and changelog accordingly. You also need a file debian/install that lists what files you are installing and where they should go. There are various guides on the net (and on Stack Overflow) that explain this process. For example, look at the Debian New Maintainers' Guide.
You can then use dpkg-buildpackage to create a real, standard-conforming Debian package with your files in a reproducible way.
dpkg-deb is a low-level tool for manipulating existing deb files; it's not meant to be used for package creation.

How can I tell if Mono is installed properly on Linux?

I asked IT to install Mono on CentOS using the following commands:
$yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget
$cd /usr/local/src
$wget http://download.mono-project.com/sources/mono/mono-3.2.5.tar.bz2
$tar jxf mono-3.2.5.tar.bz2
$cd mono-3.2.5
$./configure --prefix=/opt/mono
$make && make install
However, when I run mono myapp.exe I get
-bash: mono: command not found
I know nothing about Linux - I feel like I'm in Japan. Assuming Linux has a path variable or something like it, maybe mono isn't in the path?
I can't even find an executable called mono in /usr/local/src, just a mono folder. Mind you I can't work out how to even search for a file so I might not be looking properly.
How can I tell whether its installed correctly? Maybe its just not available to the non-admin account I use?
I'm lost. Help!
If mono is properly installed, you should not get a message like -bash: mono: command not found. If something is installed then it most typically is in the $PATH.
On my system the executable is located on /usr/bin/mono (as most things are) but things may be different on a RPM-based system.
Your ./configure, however, got the prefix /opt/mono, so probably your executable also is located under that special path. (And thus mono isn't properly installed.) Why did you install it there? Anyway. If this is the fact, then you can execute it using sth like
/opt/mono/bin/mono foo.exe
to find the executable below your prefix path you could use
find /opt/mono -name mono
to see all directory entries which are named exactly mono. One of those should be your executable.
If your programm is properly installed you will usually find it's executable using "which"
which programm
like:
which firefox
/usr/bin/firefox
There are many guides and tutorials out there that recommend installing in /opt/mono in order to not conflict with the mono supplied by official distribution packages (which would be installed in /usr).
However what most of those guides miss is that /opt/mono is a non-standard prefix that will not be taken in account by the system when trying to find the executables (the system looks at the $PATH environment variable).
There are 2 possible solutions to this:
Instead of using the prefix /opt/mono use /usr/local (which is actually what ./configure or ./autogen.sh uses by default if you don't supply any prefix!). This prefix is normally included in the $PATH environment variable of most distributions.
Use your custom mono installation from a Parallel Environment. This is a bit more complicated to set up, but it's specially recommended for people who want to install two versions of mono in parallel (i.e. a very modern version, and a more stable version supplied by the official distribution packages), and have good control of when they can use one or another.
The reason that many internet tutorials recommend /opt/mono instead of /usr/local is actually because most of them are based on the wiki page (referenced above) that explains how to set up a Mono Parallel Environment, but they of course don't include the other steps to properly set up such an environment (they just borrowed the bit about how to call configure).

Install librsync on Amazon EC2 instance

I have trouble installing this library called librsync on an Amazon standard linux instance.
I tried this:
yum install librsync-devel
but I got No package librsync available (fair enough I guess!)
I also followed the install instructions, which says:
To build and test librsync from the extracted distribution do;
$ ./configure
$ make all check
I'm no linux expert, I extracted the library files and run these commands:
[ec2-user#ip-**-***-**-*** librsync]$ ./configure
-bash: ./configure: Permission denied
[ec2-user#ip-**-***-**-*** librsync]$ sudo ./configure
sudo: ./configure: command not found
[ec2-user#ip-**-***-**-*** librsync]$ sudo configure
sudo: configure: command not found
I changed permission of the configure file and run the ./configure command again. I got a long list of yes (full log here) and then this:
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
I'm totally lost. Any idea how to install this librsync library on EC2 linux instance?
From the error, it looks like your configure script is not set to be executable. You can check with ls -l configure. You should see a line that starts with something like -rwxr-xr-x. If not, you can run chmod +x configure to add executable permission to it.
If the permissions on that file are not right, it would be good to check the rest of the files in the distribution. How did you get the file? Downloading the tarball from Sourceforge? Download the ZIP from Github? Checking out from Github? And how did you extract it? If you could fill those details in to your question, as well as the full output of ls -l, that might help us figure out what happened.
edit to add: It looks from your configure log like cpp (the C preprocessor) is looking for cc1plus, which is part of g++. You can install that with yum install gcc-c++ (remember to run as root or with sudo).
Also, in regards to your comment, I would recommend copying the .tar.gz file directly to the Linux machine, and extracting it with tar xvzf myfile.tar.gz rather than extracting it on a Windows machine and uploading it. There are enough differences in the filesystem (how permission bits work, case sensitivity), that the process of extracting files on Windows and uploading the extracted files with something like winscp can cause problems like this.

Resources