How to comment cmake code in ruby - ruby

I need to comment a line in this Ruby code (I'm using Atom to edit files ... )
The line is the follow .. -DPROJ4_LIBRARY:FILEPATH=#{prefix_dir}/lib/libproj.so and here you're the code ...
bash 'build-and-install-libgeotiff' do
user "root"
code <<-EOH
cd "/tmp"
tar xzf libgeotiff-#{version}.tar.gz
cd libgeotiff-#{version}
export MAKEFLAGS='-j2'
[ -d build ] || mkdir build
cd build
cmake3 .. \
-DCMAKE_INSTALL_PREFIX=#{prefix_dir} \
-DWITH_JPEG=ON \
-DWITH_ZLIB=ON \
-DWITH_PROJ4=ON \
-DPROJ4_INCLUDE_DIR:PATH=#{prefix_dir}/include \
-DPROJ4_LIBRARY:FILEPATH=#{prefix_dir}/lib/libproj.so
-DPROJ4_LIBRARY:FILEPATH=/usr/lib64/libproj.so
make && make install
EOH
I've tried to use # but it seems not right because my editor put automatically #{} ... here you're the transformed code ...
bash 'build-and-install-libgeotiff' do
user "root"
code <<-EOH
cd "/tmp"
tar xzf libgeotiff-#{version}.tar.gz
cd libgeotiff-#{version}
export MAKEFLAGS='-j2'
[ -d build ] || mkdir build
cd build
cmake3 .. \
-DCMAKE_INSTALL_PREFIX=#{prefix_dir} \
-DWITH_JPEG=ON \
-DWITH_ZLIB=ON \
-DWITH_PROJ4=ON \
-DPROJ4_INCLUDE_DIR:PATH=#{prefix_dir}/include \
#{}-DPROJ4_LIBRARY:FILEPATH=#{prefix_dir}/lib/libproj.so
-DPROJ4_LIBRARY:FILEPATH=/usr/lib64/libproj.so
make && make install
EOH
How may I comment my line in this code?

In Bash, if you comment out something in a sequence of lines joined by \, you comment out everything after the #.
Here's a quick and dirty workaround.
code <<-EOH
cd "/tmp"
tar xzf libgeotiff-#{version}.tar.gz
cd libgeotiff-#{version}
export MAKEFLAGS='-j2'
[ -d build ] || mkdir build
cd build
so_arg="-DPROJ4_LIBRARY:FILEPATH=#{prefix_dir}/lib/libproj.so"
cmake3 .. \
-DCMAKE_INSTALL_PREFIX=#{prefix_dir} \
-DWITH_JPEG=ON \
-DWITH_ZLIB=ON \
-DWITH_PROJ4=ON \
-DPROJ4_INCLUDE_DIR:PATH=#{prefix_dir}/include \
$so_arg \
-DPROJ4_LIBRARY:FILEPATH=/usr/lib64/libproj.so
make && make install
EOH
Now, you can simply sed -i s/so_arg=/\1#/' file to comment it out.

Related

Error loading shared library libresolv.so.2 : No such file or directory (needed by /lib/libclntsh.so)

I get this Error everytime i try to connect to the Oracle DB:
DPI-1047: Cannot locate a 64-bit Oracle Client library: "Error loading shared library libnsl.so.1: N
o such file or directory (needed by /lib/libclntsh.so)". See https://oracle.github.io/node-oracledb/INSTALL.html for help
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
And in my Dockerfile i have this code in it:
ENV LD_LIBRARY_PATH=/lib
RUN curl -OL https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
unzip instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
cp -r instantclient_19_6/* /lib && \
rm -rf instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
apk add --no-cache libaio && \
apk add --no-cache libaio libnsl libc6-compat && \
cd /lib && \
# Linking ld-linux-x86-64.so.2 to the lib/ location (Update accordingly)
ln -s /lib64/* /lib && \
ln -s libnsl.so.2 /usr/lib/libnsl.so.1 && \
ln -s libc.so.6 /usr/lib/libresolv.so.2
What am i doing wrong? I also tried ln -s libc.so /usr/lib/libresolv.so.2
It seems, it can't find libresolv.so.2
I fixed the problem
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh && \
mkdir /opt/oracle && \
cd /opt/oracle && \
curl -OL https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
unzip instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
rm -rf instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
cd /opt/oracle/instantclient_19_6 && \
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 && \
ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \
apk add --no-cache libaio libnsl libc6-compat && \
echo "export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_6:/lib64:$LD_LIBRARY_PATH" >> /etc/profile.d/oracle_client.sh && \
echo "export PATH=/opt/oracle/instantclient_19_6:$PATH" >> /etc/profile.d/oracle_client.sh

Singularity 3.6.2 Installation

I have problems with installation of singularity 3.6.2 in linux mint, I followed the instructions of https://sylabs.io/guides/3.0/user-guide/installation.html.
I installed the dependencies and Go.
Then I run the command for install the latest version:
export VERSION=3.6.2 && # adjust this as necessary \
mkdir -p $GOPATH/src/github.com/sylabs && \
cd $GOPATH/src/github.com/sylabs && \
wget https://github.com/sylabs/singularity/releases/download/v${VERSION}/singularity-${VERSION}.tar.gz && \
tar -xzf singularity-${VERSION}.tar.gz && \
cd ./singularity && \
./mconfig
The error is:
Configuring for project `singularity' with languages: C, Golang
=> running pre-basechecks project specific checks ...
=> running base system checks ...
checking: host C compiler... cc
checking: host C++ compiler... c++
checking: host Go compiler (at least version 1.13)... not found!
mconfig: could not complete configuration
I have go (go version)
go version go1.15.2 linux/amd64
I don't know what happend!
Thanks so much!
I was struggling with the same error. All the suggestions say that probably you have an older version of Go and that's why. But turned out it's even more important to place Go and Singularity in the right locations.
I found these docs https://github.com/hpcng/singularity/blob/release-3.5/INSTALL.md are the most useful and correct about where to put what in terms of directories.
The key is to clone Singularity in a directory which is GOPATH:
You won't have this directory by default so create it first
$ mkdir -p ${GOPATH}/src/github.com/sylabs && \
cd ${GOPATH}/src/github.com/sylabs && \
git clone https://github.com/sylabs/singularity.git && \
cd singularity
Make sure your singularity is here: {GOPATH}/src/github.com/sylabs/singularity
To summarize:
The Go itself is located here /usr/local/go
GOPATH would be something like home/your_username/go and the singularity will be located inside in e.g. home/your_username/go/src/github.com/sylabs/singularity
The issue was reported in 5099.
# 5320 also mentions:
I deleted the PPO python 3.6 and this worked fine!
Make sure nothing is executed as root, which would have a $PATH different from your current user.
If someone faces this issue, follow this installation guide.
sudo apt-get update && \
sudo apt-get install -y build-essential \
libseccomp-dev pkg-config squashfs-tools cryptsetup
sudo rm -r /usr/local/go
export VERSION=1.13.15 OS=linux ARCH=amd64 # change this as you need
wget -O /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/go${VERSION}.${OS}-${ARCH}.tar.gz && \
sudo tar -C /usr/local -xzf /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz
echo 'export GOPATH=${HOME}/go' >> ~/.bashrc && \
echo 'export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin' >> ~/.bashrc && \
source ~/.bashrc
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh |
sh -s -- -b $(go env GOPATH)/bin v1.21.0
mkdir -p ${GOPATH}/src/github.com/sylabs && \
cd ${GOPATH}/src/github.com/sylabs && \
git clone https://github.com/sylabs/singularity.git && \
cd singularity
git checkout v3.6.3
cd ${GOPATH}/src/github.com/sylabs/singularity && \
./mconfig && \
cd ./builddir && \
make && \
sudo make install
singularity version

Command `source` doesn't work in Dockerfile

I want build my images, here is my Dockerfile:
FROM ubuntu:16.04
MAINTAINER 'hulei886#aliyun.com'
ENV PHANTOMJS_VERSION 2.1.1
ENV PYTHON_VERSION 3.6.3
# install python3.6.3
RUN apt-get update \
&& apt-get install -y build-essential \
git \
curl \
libssl-dev \
zlib1g-dev \
libncurses5-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
&& apt-get install -y libgdbm-dev \
libdb5.3-dev \
libbz2-dev \
libexpat1-dev \
liblzma-dev \
tk-dev \
&& cd ~ \
&& git clone https://github.com/pyenv/pyenv.git .pyenv \
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc \
&& echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \
&& echo 'eval "$(pyenv init -)"' >> ~/.bashrc \
&& source ~/.bashrc \
&& curl -L https://raw.githubusercontent.com/yyuu/pyenv- installer/master/bin/pyenv-installer | bash \
&& pyenv install PYTHON_VERSION \
&& pyenv global PYTHON_VERSION \
&& cd .. \
CMD [python]
but when i run "docker build . -t [mytag]",
git clone command didn't clone anything,here is screenshot:
I need help to fix this problem,thanks!
The error message is pretty clear:
/bin/sh: 1: source: not found
No problem with git clone but with source in a /bin/sh shell. You need to use the . (dot) command instead.
When writing a Dockerfile, it's better to test the commands in a container with /bin/sh shell.
In your case, after the source error, there are other errors:
space in the curl URL
env variable wrongly used: missing $ prefix
useless cd ~: only WORKDIR instruction will change the current directory when running containers from the resulting image
CMD instruction wrongly inserted in the RUN instruction
A fixed version would be:
[...]
&& git clone https://github.com/pyenv/pyenv.git .pyenv \
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc \
&& echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \
&& echo 'eval "$(pyenv init -)"' >> ~/.bashrc \
&& . ~/.bashrc \
&& curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash \
&& pyenv install $PYTHON_VERSION \
&& pyenv global $PYTHON_VERSION
WORKDIR /root
CMD [python]
You have to use source alternative in bash. You can do something like
. somefile
instead of
source somefile

Compiling XNU kernel 2050

I'm a bit confused on the best way to compile the latest version of the XNU kernel. I've seen lots of instructions for older kernels that came with Mac OS X 10.4 but the newer sources lack a lot of the things that the instructions contain. Just running make on the XNU kernel source brings a lot of errors about not finding ctfconvert, ctfmerge and ctfdump. Does anyone have a good "howto" to build a new kernel?
A new book by Wiley details the complete set of how-to in chapter 9.
Try this:
#
# Getting C++ filter
#
$ curl http://opensource.apple.com/tarballs/cxxfilt/cxxfilt-9.tar.gz > cxx.tar.gz
$ tar xvf cxx.tar.gz
$ cd cxxfilt-9
$ mkdir -p build obj sym
$ make install RC_ARCHS="i386 x86_64" RC_CFLAGS="-arch i386 -arch x86_64 -pipe" \
RC_OS=macos RC_RELEASE=Lion SRCROOT=$PWD OBJROOT=$PWD/obj \ SYMROOT=$PWD/sym DSTROOT=$PWD/build
#
# Getting DTrace – This is required for ctfconvert, a kernel build tool
#
$ curl http://opensource.apple.com/tarballs/dtrace/dtrace-90.tar.gz > dt.tar.gz
$ tar zxvf dt.tar.gz
$ cd dtrace-90
$ mkdir -p obj sym dst
$ xcodebuild install -target ctfconvert -target ctfdump -target ctfmerge \ ARCHS="i386 x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym \ DSTROOT=$PWD/dst
#
# Getting Kext Tools
#
$ wget http://opensource.apple.com/tarballs/Kext_tools/Kext_tools-180.2.1.tar.gz \ > kt.tar.gz
$ tar xvf kt.tar.gz
$ cd Kext_tools-180.2.1
$ mkdir -p obj sym dst
$ xcodebuild install -target Kextsymboltool -target setsegname \ ARCHS="i386 x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym \
DSTROOT=$PWD/dst
#
# Getting Bootstrap commands – newer versions are available, but would # force xcodebuild
#
$ curl http://opensource.apple.com/tarballs/bootstrap_cmds/bootstrap_cmds-72.tar.gz \ > bc.tar.gz
$ tar zxvf bc.tar.gz
$ cd bootstrap_cmds-84
$ mkdir -p obj sym dst
$ make install RC_ARCHS="i386" RC_CFLAGS="-arch i386 -pipe" RC_OS=macos \
RC_RELEASE=Lion SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
The tar ball versions are now different (e.g. DTrace is 96, not 90) but this should work to satisfy dependencies. Once you have them, you just run the usual make (make ARCH_CONFIGS=" X86_64" KERNEL_CONFIGS="RELEASE"). You might want to add DEBUG, to get the great debug and trace messages which are disabled by default.
This works with XCode 4.4. Just tried it now, actually.
I don't think this will apply to Lion kernels, which will need a later version of XCode, but the way I got around the ctf* errors while building 10.6.8 kernels, was to use XCode 3.2.*
ctf* binaries are created during the "dtrace" compile.
Just run this script from a directory without any spaces, (eg ~/xnu is perfect). The end result should be a working 10.6.8 kernel. The later (and indeed, earlier) kernels are all simpler than 10.6.8.
#!/usr/bin/env bash
# Builds 10.6.8 kernel - most other builds are easier, this one needs a little patching.
# Script assembled by sfinktah
# Invaluable source: slice - http://www.projectosx.com/forum/lofiversion/index.php/t1922.html
# Note, two (got this down to one) patches necessary to build 10.6.8 - source: http://www.insanelymac.com/forum/index.php?showtopic=261736
# This is automatically applied, but I will detail here:
#
# You will have to do this: (Automated now, but just in case)
# Define CPUFAMILY_INTEL_SANDYBRIDGE in ~/xnu-1504.15.3/osfmk/mach/machine.h
# #define CPUFAMILY_INTEL_SANDYBRIDGE 0x5490b78c
#
# Skipped this step, seemed not to be needed (eventually). Leaving notes in, just in case.
# Add line 1 in ~/xnu-1504.15.3/makedefs/MakeInc.def:
# export BUILD_STABS = 1
#
# You should probaby use a local proxy, since this script makes no effort not to redownload
# existing items. Uncomment this line accordingly.
# export http_proxy=192.168.1.6:3128
export PATH="/usr/local/bin:$PATH"
CURL="curl -O "
echo "Download the build tools source(s)"
KEXT=kext_tools-180.2.1
BOOTSTRAP=bootstrap_cmds-79
DTRACE=dtrace-90
CXXFILT=cxxfilt-9
KERNEL=xnu-1504.15.3
CCTOOLS=cctools-806
# DYLD=dyld-132.13
# LD64=ld64-95.2.12
$CURL http://www.opensource.apple.com/tarballs/cxxfilt/$CXXFILT.tar.gz \
&& $CURL http://www.opensource.apple.com/tarballs/dtrace/$DTRACE.tar.gz \
&& $CURL http://www.opensource.apple.com/tarballs/kext_tools/$KEXT.tar.gz \
&& $CURL http://www.opensource.apple.com/tarballs/bootstrap_cmds/$BOOTSTRAP.tar.gz \
&& $CURL http://www.opensource.apple.com/tarballs/cctools/$CCTOOLS.tar.gz &&
# && # $CURL http://www.opensource.apple.com/tarballs/dyld/$DYLD.tar.gz
# && # $CURL http://www.opensource.apple.com/tarballs/ld64/$LD64.tar.gz
echo "Unpack the tools" \
&&
tar zxf $CXXFILT.tar.gz \
&& tar zxf $DTRACE.tar.gz \
&& tar zxf $KEXT.tar.gz \
&& tar zxf $BOOTSTRAP.tar.gz \
&& tar zxf $CCTOOLS.tar.gz &&
# && # tar zxf $LD64.tar.gz
# && # tar zxf $DYLD.tar.gz
# Copy folder cctools-8xx/include/mach-o/ to /usr/include/mach-o/
sudo cp -a $CCTOOLS/include/mach-o /usr/include/ \
&&
echo "Build cxxfilt" \
&&
cd $CXXFILT \
&& mkdir -p obj sym dst \
&& make install RC_ARCHS="i386 x86_64" RC_CFLAGS="-arch i386 -arch x86_64 -pipe" RC_OS=macos RC_RELEASE=SnowLeopard SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst \
&& sudo ditto $PWD/dst/usr/local /usr/local \
&& cd .. \
&&
echo "Build dtrace" \
&&
cd $DTRACE \
&& mkdir -p obj sym dst \
&& xcodebuild install -target ctfconvert -target ctfdump -target ctfmerge ARCHS="i386 x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst \
&& sudo ditto $PWD/dst/usr/local /usr/local \
&& cd .. \
&&
echo "Build kext_tools" \
&&
cd $KEXT \
&& mkdir -p obj sym dst \
&& xcodebuild install -target kextsymboltool -target setsegname ARCHS="i386 x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst \
&& sudo ditto $PWD/dst/usr/local /usr/local \
&& cd .. \
&&
echo "Build bootstrap_cmds" \
&&
cd $BOOTSTRAP \
&& mkdir -p obj sym dst \
&& make install RC_ARCHS="i386" RC_CFLAGS="-arch i386 -pipe" RC_OS=macos RC_RELEASE=SnowLeopard SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst \
&& sudo ditto $PWD/dst/usr/local /usr/local \
&& cd .. \
&&
echo "Download the xnu source" \
&&
$CURL http://www.opensource.apple.com/tarballs/xnu/$KERNEL.tar.gz \
&&
echo "Unpack xnu" \
&&
tar zxf $KERNEL.tar.gz \
&&
echo "Build xnu" \
&&
cd $KERNEL \
&& sed -i -e '1s/.*/#define CPUFAMILY_INTEL_SANDYBRIDGE 0x5490b78c \/*/' osfmk/mach/machine.h \
&& make ARCH_CONFIGS="I386 X86_64" KERNEL_CONFIGS="RELEASE" \
&& file BUILD/obj/RELEASE_*/mach_kernel &&
# && # Removing AppleProfileFamily.kext - http://lists.apple.com/archives/darwin-kernel/2009/Dec/msg00000.html
echo "Complete. Remember to remove /System/Library/Extensions/AppleProfileFamily.kext from target." \
|| echo "Failed"
# vim: set ts=180 sts=0 sw=3 noet:

Installing Magento automatically

I'm thinking about installing magento in automatical way. I suppose that I need to create some script or something... but I guess I'm not first person whom need it. So do you know about any good resource or solution how to it? It would work in Windows and Linux OS. Thanks. Jaro.
There are probably others out there but here is a quick and dirty script I use form time to time to install Magento checkout my svn repo and initialise modman. It could be extended to create database if required etc, but it works fine for me as is:
#!/bin/bash
# Required Script Variables
DB_NAME=
DB_USER=
DB_HOST=
DB_PASS=
URL=
MAGENTO_VERSION="1.7.0.0"
ADMIN_FIRSTNAME=
ADMIN_SURNAME=
ADMIN_EMAIL=
ADMIN_USER=
ADMIN_PASS=
SVN_REPO=
# Download and install Magento
wget http://www.magentocommerce.com/downloads/assets/$MAGENTO_VERSION/magento-$MAGENTO_VERSION.tar.gz
printf "\n\nUnpacking and preparing to install Magento...\n"
tar -zxvf magento-$MAGENTO_VERSION.tar.gz
mv magento/* magento/.htaccess .
chmod -R o+w media var
chmod o+w app/etc
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
rm -rf magento/ magento-$MAGENTO_VERSION.tar.gz
printf "\n\nInstalling Magento...\n"
/usr/local/bin/php -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_GB" \
--timezone "Europe/London" \
--default_currency "GBP" \
--db_host "$DB_HOST" \
--db_name "$DB_NAME" \
--db_user "$DB_USER" \
--db_pass "$DB_PASS" \
--url "$URL" \
--use_rewrites "yes" \
--use_secure "no" \
--secure_base_url "" \
--use_secure_admin "no" \
--skip_url_validation "yes" \
--admin_firstname "$ADMIN_FIRSTNAME" \
--admin_lastname "$ADMIN_SURNAME" \
--admin_email "$ADMIN_EMAIL" \
--admin_username "$ADMIN_USER" \
--admin_password "$ADMIN_PASS"
# Setup svn and modman
modman init
mkdir .modman/modules
svn co $SVN_REPO .modman/modules
modman update-all

Resources