Portable erlang - erlang

Is there a recommended way to "bootstrap" an Erlang distribution? I would like to run erlang on the bunch of machines where I do not have root elevation nor development tool-set (no compilers etc ...) . My thinking was to pre-package (on the machine with the same architecture) as much as I can before. What are the minimal requirements for an usable Erlang environment?

You can use the different erlware tools. Using the latest Sinan, you can even create a standalone release with the erts bundled.

Ok, I should have read it before ... (from INSTALL.md)
* Install using the `release` target. Instead of doing `make install` you
can create the installation in whatever directory you like using the
`release` target and run the `Install` script yourself. `RELEASE_ROOT`
is used for specifying the directory where the installation should be
created. This is what by default ends up under `/usr/local/lib/erlang`
if you do the install using `make install`. All installation paths
provided in the `configure` phase are ignored, as well as `DESTDIR`,
and `INSTALL_PREFIX`. If you want links from a specific `bin` directory
to the installation you have to set those up yourself. An example where
Erlang/OTP should be located at `/home/me/OTP`:
$ ./configure
$ make
$ make RELEASE_ROOT=/home/me/OTP release
$ cd /home/me/OTP
$ ./Install -minimal /home/me/OTP
$ mkdir -p /home/me/bin
$ cd /home/me/bin
$ ln -s /home/me/OTP/bin/erl erl
$ ln -s /home/me/OTP/bin/erlc erlc
$ ln -s /home/me/OTP/bin/escript escript

You can look at Wing3D for example.
CouchDB is another example. (Credit to tbikeev.)

Related

Lumber: Command 'lumber' not found

I just setup a Rails Application in my Ubuntu 18 machine, and I want to connect it to Forest Admin. However, Forest Admin requires that I set up a Node Application using npm first. The node application requires the installation of Lumber CLI tool in order to install Forest Admin.
I have however installed Lumber CLI tool by running the command below:
npm install -g lumber-cli#latest -s
When I run the command below npm lumber -version in my command line terminal, I get the response:
6.13.4
But when I try to generate the Forest Admin using the command below:
lumber generate "my_project"...
I get the following error:
Command 'lumber' not found
I need some help. Thank you.
Here's how I solved it:
The issue is because NPM does not have the write access to the directory that will contain the package you want to install (here lumber-cli).
To solve this issue, override the default directory where your global NPM packages will be stored:
mkdir ~/.npm-global
Then, configure NPM to use this directory instead of the default one:
npm config set prefix '~/.npm-global'
Then, make the node executables accessible from your PATH. To do so, export the environment variable PATH by opening or creating the file ~/.profile and add this line at the end:
export PATH=~/.npm-global/bin:$PATH
Finally, reload the ~/.profile file:
source ~/.profile
Try installing lumber cli again using the command below:
npm install -g lumber-cli#latest -s
It should be able to install lumber without any error, and also display the directory where lumber-cli is installed.
Reference: Prevent permission errors at installation
That's all
I hope this helps

Makefile for building an rpm works locally, but not in Jenkins

I have a makefile for building debian and rpm packages. I have two Jenkins environments, one for Ubuntu and one for CentOS. The debian package works no problem, and the rpm make command works on my machine, but not on Jenkins. Jenkins returns the following error:
cp: cannot stat /root/rpmbuild/SOURCES/myfile.file': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.mII8KL (%install)
I was getting similar errors when developing the package but eventually figured everything out, and all was good. I think the problem may lie with $RPM_BUILD_ROOT, %{buildroot}, or _topdir options. Nothing I have tried has led me anywhere however.
Here is my (modified) Makefile:
# a list of tools we depend on and must install if they're missing
DEBTOOLS=/usr/bin/debuild-pbuilder
RPMTOOLS=/usr/bin/rpmbuild
# convenience target for "make deb"
deb: my-package_1.0_all.deb
# convenience target for "make rpm".
rpm: my-package-1.0-Public.x86_64.rpm
# the target package (on Ubuntu at least)
my-package_1.0_all.deb: $(DEBTOOLS)
cd my-package; debuild-pbuilder -us -uc
my-package-1.0-Public.x86_64.rpm: $(RPMTOOLS)
cd rpmbuild; rpmbuild -bb SPECS/my-package.spec
/usr/bin/debuild-pbuilder:
apt-get -y install pbuilder
/usr/bin/rpmbuild:
yum -y install rpm-build
This is my spec file:
Summary: My Package
Name: my-package
Version: 1.0
Release: Public
Group: Applications/System
License: Public
Requires: external-package
Source1: myfile.file
%description
blah blah
%files
%config /etc/myfile.file
%install
mkdir -p $RPM_BUILD_ROOT/etc/
cp %{SOURCE1} %{buildroot}/etc/myfile.file
%post
ln -sf /etc/myfile.file /etc/external-package.conf
The problem was in fact that the file wasn't being found (obviously). For me this had a lot to do with the confusing nature of building rpm files. When the make command is executed, and the rpmbuild command is called, I needed to be able to specify the directory. When reading the documentation, it was stated you could use rpmbuild -D '_topdir .' -bb path/to/spec.spec to set the _topdir variable to the local directory you call from. This made sense as . represents this in linux.
However the actual call needs to be
rpmbuild -D "_topdir `pwd`" -bb path/to/spec.spec
This doesn't look all that different except it is crucial to use double-quotes. Using this command will run the build within the directory you call it from. After this rpmbuild will copy and handle the files for you as it should (which is confusing in itself).

How to build LLVM doxygen in HTML ? I tried but failed

I want to get a copy of the doxygen web-pages of llvm, so I can work with it without the internet.
I did as follows:
$ cd LLVM_ROOT_DIR
$ mkdir out
$ cd out/
$ ../configure --enable-doxygen
$ make ENABLE_OPTIMIZED=1
But it only built llvm without documentation. I also tried
$ make BUILD_FOR_WEBSITE=1 ENABLE_OPTIMIZED=1
and
$ make ENABLE_OPTIMIZED=1 EXTRA_DIST=1
All of them did not work.
How could I build the web pages ?
Thanks a lot.
Using recent versions of LLVM, an in-source build is prohibited by configure. Luckily the documentation can be built using cmake.
$ mkdir out
$ cd out/
$ cmake -DLLVM_ENABLE_DOXYGEN=On ../
$ make doxygen-llvm
The process will take a while, but after it you should have the full documentation.
Once you enable doxygen in the configure step, you can run make doxygen-llvm on the docs/ folder in your build directory.
You can run make help to check the available options.
I collect the web-site by wget.

Make no rule found 'kernel-toolchain' . Stop

I am trying got port FreeBSD on the ARMv8 foundation model.
I am following the wiki from [1]. But, I am not able to get past the step of building the tool chain.
a) According to step one, I could download all the binutils and it is in my home directory.
b) Next it is asking to change PATH of root Makefile. So I changed it as
**export PATH= $PATH:/aarch64-freebsd-sandbox/toolchain/build/aarch64-none-freebsd10/bin/**
c) Next, the step is to make kernel toolchain. But when I type
**make kernel-toolchain TARGET=arm64**
It gives an error saying
**make: *** No rule to make target `kernel-toolchain'. Stop.**
I did echo $PATH and found that the path is added correctly.
What might be the problem?
[1] https://wiki.freebsd.org/arm64
Thank you!
To do this, you have to start with a working FreeBSD system. Cross compiling from Linux won't work. If you are on FreeBSD 10, you can use the included svnlite, if you are on an earlier version, you need to install the /usr/ports/devel/subversion port.
First you need to build the binutils as described on the wiki.
Then you should download the branch that is mentioned on the wiki page. This branch should be installed at /usr/src (make a backup of the contents first in case you have to rebuil your current system!);
# mv /usr/src /usr/orig-src
# mkdir /usr/src
# svnlite co https://svn0.us-west.FreeBSD.org/base/projects/arm64 /usr/src
Then edit the Makefile in /usr/src to contain the path for the special binutils first. Otherwise the normal binaries for whatever architecture you're running will be found first, which will not work.
After then you can build the kernel toolchain;
# cd /usr/src
# make kernel-toolchain TARGET=arm64
# make _includes TARGET=arm64
Then you'll have to build the loader;
# make buildenv TARGET=arm64
This will open a new shell. From that shell you should run;
# make -C lib/libstand obj all
# make -C sys/boot -DWITHOUT_FORTH obj all
Don't exit that shell, because there is more. I assume that the kernel build procedure is more or less standard, it is not mentioned on the wiki;
# make buildkernel
This command needs to run in the shell that was opened by make buildenv.
Note: do not run make installkernel. That would presumably leave your x86 PC with an ARM kernel. :-)
The wiki doesn't mention building a userland, and it only shows the boot process, so I don't know if it even works.
You'll need a Linux box (or VM) to run the ARMv8 emulator. You will have to supply the kernel and boot loader that you built to this emulator, but I don't know how to do that. You definitly need to take that up on the freebsd-arm mailing list!

How to use erlang-examples

I just downloaded Erlang using apt-get onto Ubuntu 10.10. How do I run the examples that come with Erlang (the examples you can get through apt-get install erlang-examples). I tried going to the directory where they were stored and compiling ball.erl, but I got this error:
ball.bea#: error writing file
error
The directory where those examples are stored isn't writeable by normal users. To compile a .erl file, the compiler needs to be able to write out the compiled .beam file.
One way around this is to copy the files to a directory you can write to and compile them there:
$ mkdir erlex
$ cd erlex
$ cp /usr/lib/erlang/lib/gs-1.5.11/examples/src/* .
$ erlc *.erl
You need the erlang-dev package installed for that to work.
You can run the ball example like so:
$ erl -s ball
ball here is the module name, and the Erlang emulator defaults to calling the start/0 function in that module, which is correct in this case.
You don't actually have to compile these examples, however. The Ubuntu erlang-examples package ships with them already compiled:
$ cd /usr/lib/erlang/lib/gs-1.5.11/examples/ebin
$ erl -s ball
After closing the GUI window in each, say q(). to get out of the emulator. This may seem weird to you until you realize that everything about Erlang is designed with long uptimes in mind. The mere fact that the last process the emulator was running has stopped isn't enough reason for the BEAM emulator to shut itself down. Something else might be started in that same emulator later, after all.

Resources