Any idea how to get hold of pcre (and pcre-devel) libraries on OpenShift / RHEL? I can't directly install packages via yum.
For context, I am trying to install my Yesod/haskell app on openshift, and running into trouble with this pcre dependency during "cabal install".
remote: Configuring pcre-light-0.4.0.3...
remote: cabal: Missing dependency on a foreign library:
remote: * Missing C library: pcre
remote: This problem can usually be solved by installing the system package that
remote: provides this library (you may need the "-dev" version). If the library is
remote: already installed but in a non-standard location then you can use the flags
remote: --extra-include-dirs= and --extra-lib-dirs= to specify where it is.
remote: cabal: Error: some packages failed to install:
Well, I did essentially answer the question as currently titled. The starting point is the put this file in the pre_build hook of your openshift application's git repo (i.e., .openshift/action_hooks/pre_build).
https://gist.github.com/abn/7480593
I did have to add one line, shown below with the comment #AC
#!/bin/bash
# script to install pcre on openshift
# this can be called in your action_hooks to setup pcre
# useful if you want to use regex in uwsgi, or nginx
#
# NOTE:
# If scaling, make sure you call this in your pre_start* hook,
# ${OPENSHIFT_DATA_DIR} is not copied over for a new gear
PCRE_VERSION="8.33"
PCRE_NAME="pcre-${PCRE_VERSION}"
PCRE_TARBALL=${PCRE_NAME}.tar.gz
PCRE_SRC="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${PCRE_TARBALL}"
function setup_env()
{
if [ -z $(echo $PATH | grep "$OPENSHIFT_DATA_DIR/bin") ]; then
export PATH=$PATH:${OPENSHIFT_DATA_DIR}/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENSHIFT_DATA_DIR}/lib
fi
}
function cleanup()
{
rm -rf ${OPENSHIFT_DATA_DIR}/${PCRE_TARBALL}
rm -rf ${OPENSHIFT_DATA_DIR}/${PCRE_NAME}
}
function install_pcre()
{
cd ${OPENSHIFT_DATA_DIR} #AC
wget ${PCRE_SRC}
tar xvf ${PCRE_TARBALL}
cd ${PCRE_NAME}
./configure --prefix=${OPENSHIFT_DATA_DIR}
make
make install
}
if [ ! -f "$OPENSHIFT_DATA_DIR/bin/pcre-config" ]; then
install_pcre
setup_env
cleanup
fi
So now pcre is successfully installed on my openshift gear. Mission accomplished! Well, mostly. There is still a separate problem with library paths, but I will ask that separately if RedHat/OpenShift support doesn't come back with an answer.
Related
Recently I'm learning how to use autoyast to install SUSE unattendly via network with pxe.
My target is --
Unattended install Suse12.4 with pxe -- I have made it successfully with autoyast.xml and pxe
The install not only install Suse only, but also need to install some external packages -- eg. rlwrap and puppet client...
Follow the steps in https://documentation.suse.com/sles/12-SP4/html/SLES-all/configuration.html#CreateProfile-Software -- in Section 4.9.2
So I made a test with rlwrap package only, here are my steps--
Since my repository was http://192.168.95.77/12.4, so I copied rlwrap-0.43-lp152.3.8.x86_64.rpm to http://192.168.95.77/12.4/suse/x86_64 and make sure it's available from http.
Then I modified my autoyast.xml add this at the file end--
<add-on>
<add_on_products config:type="list">
<listentry>
<media_url>http://192.168.95.77/12.4/suse/x86_64/rlwrap-0.43-lp152.3.8.x86_64.rpm</media_url>
<product>rlwrap</product>
<alias>rlwrap</alias>
<product_dir></product_dir>
<priority config:type="integer">99</priority>
<ask_on_error config:type="boolean">false</ask_on_error>
<confirm_license config:type="boolean">false</confirm_license>
<name>eisen-repo-12.4</name>
</listentry>
</add_on_products>
</add-on>
Then I tested with a new VM, -- then I found this VM was successfully installed Suse12.4 again, But that rlwrap package was not installed and there's no error message found in installation.
Find the solution -- the init.sh part in the autoyast.xml can do it.
I wrote it like this --
<scripts>
<init-scripts config:type="list">
<script>
<debug config:type="boolean">true</debug>
<feedback config:type="boolean">false</feedback>
<filename>init.sh</filename>
<interpreter>shell</interpreter>
<location><![CDATA[]]></location>
<notification>customer initialization</notification>
<source><![CDATA[
#!/bin/bash
touch /tmp/flag
rpm --import http://192.168.95.77/puppet7/repodata/repomd.xml.key 2>&1 >> /tmp/flag
zypper addrepo -f http://192.168.95.77/puppet7 eisen-repo-puppet7 2>&1 >> /tmp/flag
zypper install -y rlwrap 2>&1 >> /tmp/flag
zypper install -y puppet-agent 2>&1 >> /tmp/flag
]]></source>
</script>
</init-scripts>
</scripts>
Then the 3rd party packages are installed successfully.
I am setting up Kubernetes on coreOS, on GCE. However, it is not going through due to the SDK dependency on Python. I downloaded python and tried installing it, but it is looking for a C compiler. Unfortunately I couldn't get one. Could someone help with this?
Below is the link I am following to set this up
https://github.com/rimusz/coreos-multi-node-k8s-gce/blob/master/README.md
You're probably better off using a cloud-init file that curls, installs and runs each binary for kubernetes as a systemd unit. So each would look like:
- name: kube-apiserver.service
command: start
content: |
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=etcd2.service setup-network-environment.service
After=etcd2.service setup-network-environment.service
[Service]
EnvironmentFile=/etc/network-environment
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
ExecStartPre=/usr/bin/curl -L -o /opt/bin/kube-apiserver -z /opt/bin/kube-apiserver https://storage.googleapis.com/kubernetes-release/release/v0.18.2/bin/linux/amd64/kube-apiserver
ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-apiserver
ExecStartPre=/usr/bin/curl -L -o /opt/bin/kubectl -z /opt/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v0.18.2/bin/linux/amd64/kubectl
ExecStartPre=/usr/bin/chmod 755 /opt/bin/kubectl
ExecStart=/opt/bin/kube-apiserver --portal_net=10.244.0.0/16 --etcd_servers=http://127.0.0.1:4001 --logtostderr=true --insecure_port=8080 --insecure_bind_address=0.0.0.0
Restart=always
RestartSec=10
And similar for each other binary. Just make sure you set them up to follow the chain of dependencies. This way the binaries are already compiled, compiling is something that coreos isn't exactly designed for.
I have an application written in PHP using Fuelphp 1.6.3 and want to deploy it on Openshift
As the framework required composer, when I access my app at http://audit-manhthang.rhcloud.com/public/, it showed the error
Composer is not installed. Please run "php composer.phar update" in
the root to install Composer
I have Google it and found an article here: https://www.openshift.com/content/support-for-git-clone-on-the-server-aka-support-php-composerphar
I've tried to follow the instruction, create the file name deploy in .openshift/action_hooks folder and added following:
unset GIT_DIR
cd $OPENSHIFT_REPO_DIR/libs
wget -qN http://getcomposer.org/composer.phar
php composer.phar install
But it doesn't work. I have tried to revise install by update
unset GIT_DIR
cd $OPENSHIFT_REPO_DIR/libs
wget -qN http://getcomposer.org/composer.phar
php composer.phar update
But nothing change.
I use PHP 5.3 Cartridge on Openshift
When I did composer update
cd app-root/runtime/repo/php
/usr/bin/php composer.phar update
I received error like this
[RuntimeException]
/var/lib/openshift/52d3b7bd500446f4300001a5/.composer/cache/vcs does not exist and could not be created.
Composer is using $HOME variable to find root path. So to fix that I did.
export HOME=/var/lib/openshift/52d3b7bd500446f4300001a5/app-root/runtime/repo/php
and then
/usr/bin/php composer.phar update
worked.
After update was done I reverted $HOME
export HOME=/var/lib/openshift/52d3b7bd500446f4300001a5
Looks like there have been some changes how openshift works now. I know that this is quite ugly workaround. If I will find something better, I will update this answer. Still, hope this will help someone.
EDIT
Got it! :)
Create new file under .openshift directory:
.openshift/action_hooks/deploy
and mark it as executable.
#!/bin/bash
# Run composer install
cd app-root/runtime/repo/php
export HOME_ORIGIN=$HOME
export HOME=$HOME/app-root/runtime/repo/php
/usr/bin/php composer.phar install
export HOME=$HOME_ORIGIN
After that on every push composer will be updated to current composer.lock place. Perfect! :)
Also make sure vendor/ path is empty. Better add to .gitignore so it not messed up by your local setup.
Here is a slightly better solution than the others mentioned:
http://stanlemon.net/2013/03/22/composer-on-openshift/
The deploy script mentioned in the blog post:
a. downloads composer if not present and stores it in the data directory so that it persists
across git pushes
b. enables composer to use cached versions of packages in the .composer dir stored in the persistent data directory, thus decreasing the time required when doing frequent pushes
There was a small issue with the script - that the php version it was referring to was being complained as being too old by composer
remote: #!/usr/bin/env php
remote: Some settings on your machine may cause stability issues with Composer.
remote: If you encounter issues, try to change the following:
remote:
remote: Your PHP (5.3.3) is quite old, upgrading to PHP 5.3.4 or higher is recommended.
remote: Composer works with 5.3.2+ for most people, but there might be edge case issues.
So I changed the paths to use the latest present on the system
[domain.rhcloud.com action_hooks]\> php --version
PHP 5.4.16 (cli) (built: Dec 6 2013 01:17:01)
[domain.rhcloud.com 5316aa83e0b8cdb61b00023a]\> which php
/opt/rh/php54/root/usr/bin/php
The script in my .openshift/action_hooks/deploy is
#!/bin/bash
# Run composer install
cd app-root/runtime/repo/
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer"
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
curl -s https://getcomposer.org/installer | /opt/rh/php54/root/usr/bin/php -- --install-dir=$OPENSHIFT_DATA_DIR
else
/opt/rh/php54/root/usr/bin/php $OPENSHIFT_DATA_DIR/composer.phar self-update
fi
( unset GIT_DIR ; cd $OPENSHIFT_REPO_DIR ; /opt/rh/php54/root/usr/bin/php $OPENSHIFT_DATA_DIR/composer.phar install )
As the blog post suggests - create an empty hot_deploy file in the markers subdirectory to further speed things up by saying that the servers should not be restarted during a push -
touch .openshift/markers/hot_deploy
git add .openshift/markers/hot_deploy
git add .openshift/action_hooks/deploy
git commit -m "Speeding up composer installs across pushes"
git push origin master
And watch your git pushes be fast even when using composer.
I figure it out. With openshift, I can access via SSH and go to app-root(or something like that)/repo/php and then type /usr/bin/php composer.phar update. That's it.
For reference, OpenShift comes with built-in support for Composer. Adding the use_composer marker file, simply an empty file named use_composer, in your OpenShift project's .openshift/markers directory will automatically enable Composer install/update on deployment.
More specifically, each time you git push to your OpenShift git repo...
When in 'production' mode (default):
echo -n "Checking composer.json for Composer dependency... "
if [ -f ${OPENSHIFT_REPO_DIR}composer.json ]; then
echo
composer install --no-interaction --no-ansi --no-scripts --optimize-autoloader --working-dir=${OPENSHIFT_REPO_DIR} || \
echo -e "\nSkipping Composer errors..\n\n Please, fix the errors either locally or in development mode.\n"
if [ ! -f ${OPENSHIFT_REPO_DIR}composer.lock ]; then
echo -e $composer_lock_msg
fi
else
echo "File not found."
fi
When in 'development' mode:
if [ -f ${OPENSHIFT_REPO_DIR}composer.lock ]; then
echo "Ignoring composer.lock file (development mode)"
fi
echo -n "Checking composer.json for Composer dependency... "
if [ -f ${OPENSHIFT_REPO_DIR}composer.json ]; then
echo
composer update --no-interaction --no-ansi --no-scripts --optimize-autoloader --working-dir=${OPENSHIFT_REPO_DIR}
echo -e $composer_lock_msg
else
echo "File not found."
fi
Check out the code beginning at line #142 of the OpenShift PHP Cartridge.
Check out the Developer Portal article on enabling PHP 'development' mode for more details.
Check out the Laravel 5 QuickStart for example-use or for an easy way to get started.
I do not have enough points to comment on wormhit's answer, so I will append it here:
The zend/php-*/etc/php.ini file needed an update for OpenShift to work with the latest version of composer.phar as described here:
extension=phar.so
extension=ctype.so
Adding these extensions to it fixes PHP's complaints about composer.phar
The next fix required using relative pathing:
php composer.phar install
INSTEAD of absolute pathing:
/usr/bin/php composer.phar install
to allow the extensions to load.
I am trying to build a .rpm package. I have just followed the steps to do that. Till now all steps were gone fine but now i just stuck with this step. I just ran the following command and got this error:
rpmbuild -ba asterisk.spec
error: Failed build dependencies:
gtk2-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
libsrtp-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
[... more ...]
freetds-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
uw-imap-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
I am using fedora-15. How to resolve this error?
How I do install all depencencies during installation of src.rpm package. Is it possible?
You can use the yum-builddep command from the yum-utils package to install all the build dependencies for a package.
The arguments can either be paths to spec files, paths to source RPMs or the names of packages which exist as source RPMs in a configured repository, for example:
yum-builddep my-package.spec
or
yum-builddep my-package.src.rpm
The same thing can be achieved on newer versions of Fedora that use dnf as their package manager by making sure that dnf-plugins-core is installed and then doing:
dnf builddep my-package.spec
or
dnf builddep my-package.src.rpm
yum-builddep doesn't seem to work if the mirror you use doesn't serve source RPMs. This may not handle all cases, but it usually works for me:
sudo yum install -y $(<rpmbuild> | fgrep 'is needed by' | awk '{print $1}')
where <rpmbuild> is your rpmbuild command (e.g., rpmbuild -ba foo.spec).
On PHP building - especially phpbrew I used dnf builddep php, it worked.
Any hints on how doing this? I tried with the auto-install from a downloaded zip from this here, extracted here: OPENSHIFT_DATA_DIR/hg and executable location here: OPENSHIFT_DATA_DIR/jenkins/data/tools/Mercurial/mercurial-2.2.1/bin/hg
I'm doing something wrong for sure, I'm not Linux saavy. Jenkins says is unable to find mercurial executable.
Any help is more than welcomed.
Here's the answer from here:
Thanks for the email discussion.
Mercurial includes a README which explains a couple of modes of execution:
Basic install:
$ make # see install targets
$ make install # do a system-wide install
$ hg debuginstall # sanity-check setup
$ hg # see help
Running without installing:
$ make local # build for inplace usage
$ ./hg --version # should show the latest version
"make install" will not work as it attempts to do a system-wide install. The user on the gears will not have access to write to system files.
"make install-home" will not work either.
"make local" works and will install it in cwd such that running the following will should work just fine:
./hg --version
Mercurial Distributed SCM (version 2.2.1)
(see http://mercurial.selenic.com for more information)