Heroku buildpacks - installing executables that are used by Python packages - heroku

I am trying to install M2Crypto on Heroku. This relies on SWIG being installed.
I've created a custom compiled swig executable and a custom buildpack.
I then git push my code up to Heroku, the custom buildpack installs SWIG then tries to install M2Crypto but fails because it can't find swig.
This is the buildpack customisation:
# Install SWIG
if [ ! -d $CACHE_DIR/swig ]; then
cd $BUILD_DIR
echo "-----> Fetching and installing SWIG 2"
curl -O https://s3.amazonaws.com/guybowden/swig.tar.gz >/dev/null 2>&1
echo "-----> Installing ..."
tar xzvf swig.tar.gz >/dev/null 2>&1
mv swig $CACHE_DIR/swig
rm swig.tar.gz
echo "SWIG installed" | indent
fi
mkdir -p .paybox
cp -R $CACHE_DIR/swig .paybox
echo "updating path..." | indent
PATH=$PATH:/app/.paybox/swig/bin/
export PATH
echo $PATH | indent
echo "setting SWIG_LIB environment var"
export SWIG_LIB=/app/.paybox/swig/share/swig/2.0.5/
This happens before any pip install commands are run.
If I heroku run bash and then manually run source .heroku/venv/bin/activate && pip install M2Crypto it installs no problem and my App works inside the bash prompt for the lifetime of that instance.
I think there's a problem with the PATH setting when the initial pip install -r requirements runs... any ideas?

And the answer is..
PATH=$PATH:$BUILD_DIR/.paybox/swig/bin/
export PATH
echo $PATH | indent
echo "setting SWIG_LIB environment var"
export SWIG_LIB=$BUILD_DIR/.paybox/swig/share/swig/2.0.5/
$BUILD_DIR is where the stuff is built when the buildpack is executed - not /app/ (which is where it lives when the app runs!

Related

Is there a way to unarchive a dmg file like a tar.gz file? (Using Mac OS)

I'm trying to use a program that uses Linux versions of other programs.
I ran this in bash:
c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
mkdir -p "${SCRIPTPATH}/depends/c3d/"
wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-Linux-x86_64.tar.gz && \
tar -xzvf c3d-nightly-Linux-x86_64.tar.gz && mv c3d-1.1.0-Linux-x86_64/* "${SCRIPTPATH}/depends/c3d/" && \
rm c3d-nightly-Linux-x86_64.tar.gz
export PATH="${SCRIPTPATH}/depends/c3d/c3d-1.1.0-Linux-x86_64/bin/:$PATH"
fi
But it downloads the linux version of the program files into my directory -- yielding the error:
{..omitted}/HippMapp3r/depends/c3d/bin/c3d: cannot execute binary file
Return Code: 126
I understand in order for this to work on my computer, I need to use the version for Mac OS, however, I stuck on how one might go about "unarchiving" the files contained within a .dmg file so I can access c3d in bin.
I edited it to this, but I understand I cannot use the tar -xzvf command in this context -- is there an equivalent to tar -xzvf to "unpack" dmg files?
c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
mkdir -p "${SCRIPTPATH}/depends/c3d/"
wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-MacOS-x86_64.dmg && \
tar -xzvf c3d-nightly-MacOS-x86_64.dmg * "${SCRIPTPATH}/depends/c3d/" && \
rm c3d-nightly-MacOS-x86_64.dmg
export PATH="${SCRIPTPATH}/depends/c3d/c3d-nightly-MacOS-x86_64/bin/:$PATH"
fi
Try using 7-zip. You can install it on a Mac with homebrew using:
brew install p7zip
Then run it with:
7z
Please see comment by #StefanSchmidt about a possible alternative package.
First you have to mount the DMG file.
command: hdiutil mount test.dmg

Unable to install Ruby on Ubuntu

I'm trying to install Ruby 2.6.1 on Ubuntu but keep coming across this error.
Have tried uninstalling Ubuntu, googling the problem, running in administrator mode, downloading a different version.
This is the error:
:~$ rvm install 2.6.1
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.6.1.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
mkdir: cannot create directory ‘/usr/share/rvm/log/1625135668_ruby-2.6.1’: Permission denied
tee: /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log: No such file or directory
Updating system..jaydene password required for 'apt-get --quiet --yes update':
Sorry, try again.
jaydene password required for 'apt-get --quiet --yes update':
..
Error running 'requirements_debian_update_system ruby-2.6.1',
please read /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log
Requirements installation failed with status: 1.
:~$
you can use a gorails website to checkout ruby on rails installation. And ruby installs version as per dependencies on your system. If it's not founding 2.6.1 it will install next supported version for ex. 2.6.7.
check this website: https://gorails.com/setup/ubuntu/21.04
Check this: How do I install Ruby 1.9.3 on Ubuntu without RVM? but SO says to avoid link answers so here is the script:
#!/usr/bin/env bash
# -- this really is the only solution that worked for me on snap :/
ruby -v
if ! command -v ruby &> /dev/null
then
echo "Going to try to install ruby (ideally 3.1.2)"
# - install rebenv (following ruby-build really is needed eventhough it doesn't look like it)
mkdir -p ~/.rbenv
cd ~/.rbenv
git clone https://github.com/rbenv/rbenv.git .
# if $HOME/.rbenv/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ ":$PATH:" != *":$HOME/.rbenv/bin:"* ]]; then
echo "might want to put $HOME/.rbenv/bin in your path"
export PATH="$HOME/.rbenv/bin:$PATH"
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc.lfs
fi
eval "$(rbenv init -)"
rbenv -v
# - install ruby-build, odd, this really is needed for ruby to install despite it not looking like ruby build is need at the bottom
mkdir -p ~/.ruby-build
cd ~/.ruby-build
git clone https://github.com/rbenv/ruby-build.git .
# if $HOME/.ruby-build/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ $PATH != *"$HOME/.ruby-build/bin"* ]]; then
echo "might want to put $HOME/.ruby-build/bin in your path"
export PATH="$HOME/.ruby-build/bin:$PATH"
# echo 'export PATH="$HOME/.ruby-build/bin:$PATH"' >> ~/.bashrc.lfs
fi
ruby-build --version
# - install ruby without sudo -- using rbenv
mkdir -p ~/.local
# ruby-build 3.1.2 ~/.local/
rbenv install 3.1.2
rbenv global 3.1.2
fi
ruby -v
# - Original Prover doesn't work on SNAP
# Proverbot's way to install ruby
# # First, install Ruby, as that is for some reason required to build the "system" project
# git clone https://github.com/rbenv/ruby-build.git ~/ruby-build
# mkdir -p ~/.local
# PREFIX=~/.local ./ruby-build/install.sh
# ~/.local/ruby-build 3.1.2 ~/.local/
# ref: https://superuser.com/questions/340490/how-to-install-and-use-different-versions-of-ruby/1756372#1756372

Bash script unable to download source packages from a list

I have a list of packages installed on my Ubuntu 16.04. I have a bash script which tries to download their sources one by one in the appropriate directories (created). I am getting an error:
Reading package lists...
E: Unable to find a source package for xxxx
~/source
~/sourcexxx
My bash script looks like this:
#!/bin/bash
while read package
do
#cd /mnt
mkdir $package
pushd $package
apt-get -d -q source $package
popd
done < ins.txt
I don't want to update any system files.
apt-get -d -q source xxx works on its own, but not in the script above. What could be the reason?
A part of my ins.txt:
adduser
adium-theme-ubuntu
adwaita-icon-theme
alacarte
alsa-base
alsa-utils
amd64-microcode
anacron
apg
app-install-data
app-install-data-partner
apparmor
apparmor-easyprof
When I do individually for eg apt-get -d -q source adduser , it works
Using your list, this seems to work fine for me (on Ubuntu 16.04) after removing the dpkg-query -f | part :
#!/bin/bash
while read package
do
echo "Package $package"
mkdir -v $package
pushd $package
apt-get -d -q source $package
popd
done < ins.txt
Maybe some packages don't have a source, or your ins.txt file contains invalid packages.
But that question would sure have been better posted on Ask Ubuntu.

Having trouble installing OpenSSL Cocoapod

I'm trying to install the OpenSSL Cocoapod in Xcode 9.4 and I get the following:
[!] /bin/bash -c set -e VERSION="1.0.2h" SDKVERSION=xcrun --sdk
iphoneos --show-sdk-version 2> /dev/null
MIN_SDK_VERSION_FLAG="-miphoneos-version-min=7.0"
BASEPATH="${PWD}" CURRENTPATH="/tmp/openssl" ARCHS="i386 x86_64 armv7
armv7s arm64" DEVELOPER=xcode-select -print-path
mkdir -p "${CURRENTPATH}" mkdir -p "${CURRENTPATH}/bin"
cp "file.tgz" "${CURRENTPATH}/file.tgz" cd "${CURRENTPATH}" tar -xzf
file.tgz cd "openssl-${VERSION}"
for ARCH in ${ARCHS} do CONFIGURE_FOR="iphoneos-cross"
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ] ; then
PLATFORM="iPhoneSimulator"
if [ "${ARCH}" == "x86_64" ] ;
then
CONFIGURE_FOR="darwin64-x86_64-cc"
fi else
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
PLATFORM="iPhoneOS" fi
export
CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION}
${ARCH}" echo "Please stand by..."
export CC="${DEVELOPER}/usr/bin/gcc -arch ${ARCH}
${MIN_SDK_VERSION_FLAG}" mkdir -p
"${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-openssl-${VERSION}.log"
LIPO_LIBSSL="${LIPO_LIBSSL}
${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/libssl.a"
LIPO_LIBCRYPTO="${LIPO_LIBCRYPTO}
${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/libcrypto.a"
./Configure ${CONFIGURE_FOR}
--openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1 sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} !" "Makefile"
make >> "${LOG}" 2>&1 make all install_sw >> "${LOG}" 2>&1 make
clean >> "${LOG}" 2>&1 done
echo "Build library..." rm -rf "${BASEPATH}/lib/" mkdir -p
"${BASEPATH}/lib/" lipo -create ${LIPO_LIBSSL} -output
"${BASEPATH}/lib/libssl.a" lipo -create ${LIPO_LIBCRYPTO} -output
"${BASEPATH}/lib/libcrypto.a"
echo "Copying headers..." rm -rf "${BASEPATH}/opensslIncludes/" mkdir
-p "${BASEPATH}/opensslIncludes/" cp -RL "${CURRENTPATH}/openssl-${VERSION}/include/openssl"
"${BASEPATH}/opensslIncludes/"
cd "${BASEPATH}" echo "Building done."
echo "Cleaning up..." rm -rf "${CURRENTPATH}" echo "Done."
cp: file.tgz: No such file or directory
This is the command I'm using in the podfile:
pod 'OpenSSL', '~> 1.0'
I've tried installing the Xcode Command Line Tools but this did not fix the problem.
Anyone have any idea what the problem is?
First things first: If you can, try to switch to a different POD. That one is no longer maintained.
Workaround if you cannot switch:
curl https://www.openssl.org/source/openssl-<your-version>.tar.gz > file.tgz
cp file.tgz /tmp/openssl #create directory if needed
sed 's/cp \\"file.tgz\\" \\"${CURRENTPATH}\/file.tgz\\"//' `find ~/.cocoapods|grep "OpenSSL/<your-version>/OpenSSL.podspec.json"`
pod install
"< your version >" would be e.g. "1.0.2j" for the URL and "1.0.210" for the grep
I am seeing this issue also. Have not been able to resolve. Frustratingly this is happening on a Jenkins slave machine - whereas my own Mac has no issue with 'pod update' and seems to get OpenSSL without problem...
I since found out that the cocoapod-downloader had to be downgraded...for this to install...
https://github.com/FredericJacobs/OpenSSL-Pod/issues/49
I went around with several of the possible solutions, the one that worked for me was to downgrade cocoapods and the downloader. After OpenSSL is installed the pod install is done its fine to go back to the current ones. Exact steps:
sudo gem uninstall cocoapods-downloader
sudo gem install cocoapods-downloader -v 1.2.0
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.5.3
pod deintegrate
rm -rf /tmp/openssl
pod install
While I was trying to install a different cococapod, I got the same error. For me the solution was to downgrade cococapods downloader. This is the commands I used:
sudo gem uninstall cocoapods-downloader
sudo gem install cocoapods-downloader -v 1.2.0
Thnx
Patric's answer works for me. But to make the answer a little bit more clear here:
rm -rf /tmp/openssl; mkdir /tmp/openssl && cd /tmp/openssl;
curl https://www.openssl.org/source/openssl-1.0.2j.tar.gz > file.tgz
cd -;
sed -i 's/cp \\"file.tgz\\" \\"${CURRENTPATH}\/file.tgz\\"//' `find ~/.cocoapods|grep "OpenSSL/1.0.210/OpenSSL.podspec.json"`
pod install
Note:
The pod install spent about 10 minutes on my mac air.
Replace 1.0.2j and 1.0.210 with your proper version if needed.
If you want to try, downgrade the cocoapods and cocoapods-downloader is another solution, please refer here.
update:
just use
pod 'OpenSSL', :git => 'https://github.com/isee15/OpenSSL.git'
replace pod OpenSSL with OpenSSL-XM
or
replace "prepare_command" in find ~/.cocoapods|grep "OpenSSL/1.0.2j/OpenSSL.podspec.json"
with https://github.com/CocoaPods/Specs/blob/3b17051d7e0bbb5c97420a7a6d3aa9b1f6b601db/Specs/3/2/e/OpenSSL-XM/1.0.210.1/OpenSSL-XM.podspec.json

Unable to install parse.com command line tool on Mac OSX 10.10 Yosemite

Running the command
curl -s https://www.parse.com/downloads/cloud_code/installer.sh | sudo /bin/bash
does not install the tool
I was able to install it easily on my other computer running 10.9.2
STEP : 1
Make a copy of this
#!/bin/bash
TMP_FILE=/tmp/parse.tmp
if [ -e /tmp/parse.tmp ]; then
echo "Cleaning up from previous install failure"
rm -f /tmp/parse.tmp
fi
echo "Fetching latest version ..."
curl --progress-bar https://www.parse.com/downloads/cloud_code/parse -o /tmp/parse.tmp
if [ ! -d /usr/local/bin ]; then
echo "Making /usr/local/bin"
mkdir -p /usr/local/bin
fi
echo "Installing ..."
mv /tmp/parse.tmp /usr/local/bin/parse
chmod 755 /usr/local/bin/parse `
to a file named install.sh and run it in your terminal as bash install.sh. This will install you parse in your Terminal.
STEP :2
Download the Gist from this link and run the file named install.sh in your Terminal preceded by bash

Resources