zip warning: 'name not matched' inside bash loop for - bash

I'm trying to build a plugin which has the following base script inside its makefile:
$(ZIP_FILE):
git archive --format zip --prefix $(NAME)/ --output $(ZIP_FILE) HEAD
mkdir -p $(NAME)/resources/bin
ln -s `pwd`/addon.xml $(NAME)
zip -9 -r -g $(ZIP_FILE) $(NAME)/addon.xml
for arch in $(ARCHS); do \
ln -s `pwd`/resources/bin/$$arch $(NAME)/resources/bin/$$arch; \
zip -9 -r -g $(ZIP_FILE) $(NAME)/resources/bin/$$arch; \
done
Yet, I can't figure out why this error pops up every time:
zip warning: name not matched: plugin.video.pulsar/resources/bin/windows_x86
And repeats for each arch....??
P.S. this is what it looks like inside terminal:
git archive --format zip --prefix plugin.video.pulsar/ --output plugin.video.pulsar-0.4.6.zip HEAD
mkdir -p plugin.video.pulsar/resources/bin
ln -s `pwd`/addon.xml plugin.video.pulsar
zip -9 -r -g plugin.video.pulsar-0.4.6.zip plugin.video.pulsar/addon.xml
updating: plugin.video.pulsar/addon.xml (deflated 59%)
for arch in windows_x86 darwin_x64 linux_x86 linux_x64 linux_arm; do \
ln -s `pwd`/resources/bin/$arch plugin.video.pulsar/resources/bin/$arch; \
zip -9 -r -g plugin.video.pulsar-0.4.6.zip plugin.video.pulsar/resources/bin/$arch; \
done
zip warning: name not matched: plugin.video.pulsar/resources/bin/windows_x86
zip error: Nothing to do! (try: zip -9 -r -g plugin.video.pulsar-0.4.6.zip . -i plugin.video.pulsar/resources/bin/windows_x86)
zip warning: name not matched: plugin.video.pulsar/resources/bin/darwin_x64

It's because that file (plugin.video.pulsar/resources/bin/windows_x86) really does not exist.

Related

Need assistance in converting Makefile to Shell script

Need your help to convert code in Makefile to Shell script? Please help as I am new to both MakeFile and Shell Scripting.Thanks.
Sample Code:
include Configfile
.PHONY: config-arch asoc-tool clone-repo generate-irx api-login \
upload-file get-app run-scan show-scan-id get-asset-group create-app
config-arch:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
asoc-tool: config-arch
$(eval DIR := $(shell pwd))
curl -o client.zip $(APPSCAN_TOOL)
mkdir client ; mkdir tool
unzip -qq client.zip -d client
cd client ; ls | xargs -I {} sh -c "cp -r {}/* $(DIR)/tool"
rm -rf client
clone-repo:
git clone $(GIT_REPO)
# Generates the irx file for icp-cert-manager.
generate-irx:
$(eval DIR := $(shell pwd))
cd $(PROJECT_NAME); $(DIR)/tool/bin/appscan.sh prepare $(flag)
#!/bin/sh
# config-arch
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
# asoc-tool
curl -o client.zip $(APPSCAN_TOOL)
mkdir client ; mkdir tool
unzip -qq client.zip -d client
cd client ; ls | xargs -I {} sh -c "cp -r {}/* ./tool"
rm -rf client
# clone repo
git clone ${GIT_REPO} # you should overwrite ${GIT_REPO} to your git repo, maybe from Configfile
# generate-irx
cd $(PROJECT_NAME)
./tool/bin/appscan.sh prepare ${flag} # you should check your ${flag}, maybe from Configfile

Dockerfile - ARG SHA and Curl

I am newbie to Docker. I can create a docker image for Java and Maven from https://github.com/carlossg/docker-maven/blob/master/jdk-13/Dockerfile . I can understand most of the commands there inside dockerfile, there are some that I could not find sufficient info on net. Can someone please help me ?
(1) What does below ARG SHA do. If I understand it right, SHA is immutable identifier that is associated with image, so I am downloading image with that identifier, I mean specific image with changes I want and stored with that SHA, is this right?
ARG SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0
(2) I know what RUN, echo does and how the variable works. But not sure what is happening below with curl command . No idea what below lines of code does for sure.
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn```
You have to read it like a shell script.
1.
SHA is SHA512 hash
function used in line 10 to
check if downloaded /tmp/apache-maven.tar.gz is what we expect. It
has nothing to do with Docker image ID, if you mean that. You can
reproduce the check locally on your system:
$ SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0
$ BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
$ curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz
$ echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c -
/tmp/apache-maven.tar.gz: OK
(Notice that $ here is a command line
prompt
used to indicate start of a new line, not a part of the
command).
curl here downloads
https://apache.osuosl.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
to /tmp/apache-maven.tar.gz.
2.
Again, read it like a shell script. && is used for chaining commands and \ is used to concatenate lines.
RUN mkdir -p /usr/share/maven /usr/share/maven/ref
Create /usr/share/maven and /usr/share/maven/ref directories.
curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz
Download temporary apache-maven tarball to /tmp/apache-maven.tar.gz.
echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c -
Check if the downloaded tarball has the correct checksum.
tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1
Extract /tmp/apache-maven.tar.gz to /usr/share/maven.
rm -f /tmp/apache-maven.tar.gz
Remove temporary tarball after extracting it.
ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
Create /usr/bin/mvn that points to /usr/share/maven/bin/mvn. This
is done because /usr/bin directory is typically in $PATH so that
mvn can be run without providing a full path to it.

Installing oracle 12c R2 on ubuntu 18.04

Installing Oracle 12c Release 2 on Ubuntu fails because it is not a supported distribution. How can I install it anyway?
Download the installation files and unzip them as usual.
Create the oracle, dba and oinstall users:
sudo groupadd oinstall
sudo groupadd dba
sudo useradd -g oinstall -G dba,oinstall -s /bin/bash -m -d /home/oracle oracle
Add the following parameters to /etc/sysctl.conf:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 3355443
kernel.shmmax = 17179869184
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048576
The above is for a 32GB machine. If you have a different amount then set:
shmmax = (memory in bytes / 2)
Now install a set of packages needed for the install to complete. Start by updating your packages:
sudo apt update
Then install the following:
sudo apt install libc6-i386 \
gcc-multilib g++-multilib libc6-dev-i386 libstdc++6:i386 \
alien autoconf automake autotools-dev elfutils rpm rpm-common \
build-essential debhelper expat gawk gsfonts-x11 html2text sysstat \
unixodbc unixodbc-dev doxygen ksh openssh-server pax perl-doc rlwrap \
lsb lsb-core zlibc \
lib32z1-dev lib32ncurses5 libaio1 libaio-dev \
libelf-dev libodbcinstq4-1 libpth-dev libpthread-stubs0-dev \
libpthread-workqueue0 libpthread-workqueue-dev \
libtiff5-dev libzthread-dev libqt4-opengl:i386 libodbcinstq4-1:i386 \
libglu1-mesa:i386 libxtst6:i386 libxtst6
sudo apt-get install -s cabextract
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install wimtools libwim-dev
sudo apt install -s libbz2-dev:i386
Create a number of soft links so that the installation can find the files it needs at the places it expects them to be:
sudo ln -s /usr/bin/basename /bin/basename
sudo ln -s bin/bash /usr/bin/bash
sudo ln -s /usr/bin/rpm /bin/rpm
sudo ln -s /usr/bin/awk /bin/awk
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /lib64/libstdc++.so.6
sudo ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib64/libgcc_s.so.1
sudo ln -s /usr/lib/i386-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
sudo ln -s /lib/lsb/init-functions /etc/init.d/functions
sudo ln -sf /bin/bash /bin/sh
Now start the Oracle installer running under account "oracle", usually as follows:
xhost +
sudo su - oracle
cd /path/to/unzipped/files/database
./runInstaller
Install the database but do not create a database during the installation!
After a while the installation will give an error on linking. Leave the error message on-screen, then open a terminal and edit the file $ORACLE_HOME/bin/orald. Find, at the start, the part reading:
if [ -z "$BASH_VERSION" -o -n "$ORALD_USE_GCC" ] ; then
exec gcc "$#"
exit 1
fi
and change the gcc line to read:
exec gcc -no-pie "$#"
(the -no-pie option starts with a single dash).
Then copy the following script into a file, for instance /tmp/fixora:
#!/bin/bash
# Change the path below to point to your installation
export ORACLE_HOME=/opt/oracle/12cr2
sudo ln -s $ORACLE_HOME/lib/libclntshcore.so.12.1 /usr/lib
sudo ln -s $ORACLE_HOME/lib/libclntsh.so.12.1 /usr/lib
cp $ORACLE_HOME/rdbms/lib/ins_rdbms.mk $ORACLE_HOME/rdbms/lib/ins_rdbms.bkp
cp $ORACLE_HOME/rdbms/lib/env_rdbms.mk $ORACLE_HOME/rdbms/lib/env_rdbms.bkp
sed -i 's/\$(ORAPWD_LINKLINE)/\$(ORAPWD_LINKLINE) -lnnz12/' $ORACLE_HOME/rdbms/lib/ins_rdbms.mk
sed -i 's/\$(HSOTS_LINKLINE)/\$(HSOTS_LINKLINE) -lagtsh/' $ORACLE_HOME/rdbms/lib/ins_rdbms.mk
sed -i 's/\$(EXTPROC_LINKLINE)/\$(EXTPROC_LINKLINE) -lagtsh/' $ORACLE_HOME/rdbms/lib/ins_rdbms.mk
sed -i 's/\$(OPT) \$(HSOTSMAI)/\$(OPT) -Wl,--no-as-needed \$(HSOTSMAI)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/\$(OPT) \$(HSDEPMAI)/\$(OPT) -Wl,--no-as-needed \$(HSDEPMAI)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/\$(OPT) \$(EXTPMAI)/\$(OPT) -Wl,--no-as-needed \$(EXTPMAI)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/^\(TNSLSNR_LINKLINE.*\$(TNSLSNR_OFILES)\) \(\$(LINKTTLIBS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/network/lib/env_network.mk
sed -i 's/\$(SPOBJS) \$(LLIBSERVER)/\$(SPOBJS) -Wl,--no-as-needed \$(LLIBSERVER)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/\$(S0MAIN) \$(SSKFEDED)/\$(S0MAIN) -Wl,--no-as-needed \$(SSKFEDED)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/\$(S0MAIN) \$(SSKFODED)/\$(S0MAIN) -Wl,--no-as-needed \$(SSKFODED)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/\$(S0MAIN) \$(SSKFNDGED)/\$(S0MAIN) -Wl,--no-as-needed \$(SSKFNDGED)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/\$(S0MAIN) \$(SSKFMUED)/\$(S0MAIN) -Wl,--no-as-needed \$(SSKFMUED)/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/^\(ORACLE_LINKLINE.*\$(ORACLE_LINKER)\) \($(PL_FLAGS)\)/\1 -Wl,--no-as-needed \2/g' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/\$LD \$LD_RUNTIME/$LD -Wl,--no-as-needed \$LD_RUNTIME/' $ORACLE_HOME/bin/genorasdksh
sed -i 's/\$(GETCRSHOME_OBJ1) \$(OCRLIBS_DEFAULT)/\$(GETCRSHOME_OBJ1) -Wl,--no-as-needed \$(OCRLIBS_DEFAULT)/' $ORACLE_HOME/srvm/lib/env_srvm.mk
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/rdbms/lib/env_rdbms.mk
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/crs/lib/env_has.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/odbc/lib/env_odbc.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/precomp/lib/env_precomp.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/srvm/lib/env_srvm.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/network/lib/env_network.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/ldap/lib/env_ldap.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/ord/im/lib/env_ordim.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/plsql/lib/env_plsql.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/ctx/lib/env_ctx.mk;
sed -i 's/LDDISABLENEWDTAGS=-Wl,--disable-new-dtags/LDDISABLENEWDTAGS=-Wl,--no-as-needed,--disable-new-dtags/' $ORACLE_HOME/sqlplus/lib/env_sqlplus.mk;
Change the ORACLE_HOME line in the script to point to your installation directory for Oracle. Make the script executable and run it as the oracle user:
chmod a+x /tmp/fixora
sudo su - oracle
/tmp/fixora
Now return to the installer and press the "retry" button on the error dialog. The installation should now finish without further issues.
The resulting installation does not work, however: creating a database will hang in the "startup mount" command, with an oracle BEQ process deadlocked inside localtime. To fix that do the following, again as the user oracle:
cd $ORACLE_HOME/lib/stubs
rm libc*
cd ../../bin
./relink all
After the relink creating a database should work; you can create one using:
dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname $DBNAME -sid $DBNAME -responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword REPLACE_WITH_PASSWORD \
-systemPassword REPLACE_WITH_PASSWORD \
-createAsContainerDatabase false \
-databaseType MULTIPURPOSE \
-automaticMemoryManagement false \
-totalMemory 2048 \
-storageType FS \
-datafileDestination "/opt/oracle/oradata/" \
-redoLogFileSize 500 \
-emConfiguration NONE \
-ignorePreReqs
Check that $ORACLE_HOME/bin/oradism belong to root and as setuid enabled:
-rwsr-x--- 1 root dba 95844 may 24 2018 $ORACLE_HOME/bin/oradism
I faced the linking issue in ubuntu 18.04.
One pop up opened showing some linking error. I kept the popup open and after performing the below steps I clicked retry.
I checked the install log file and found it is not able to find few libraries.
INFO:
/usr/bin/ld: cannot find /usr/lib64/libpthread_nonshared.a
Then I ran :
locate libpthread_nonshared
It showed my some directory where the same file was present. But oracle installer was looking for those files in /usr/lib64 folder.
So I created the soft links for those files using below command.
cd /usr/lib64; ln -s /usr/lib/....../* /usr/lib64/
Then clicked on retry button.

go get failing in Mac OS X while trying to do go install

On Mac OS X while trying to do do go get by executing the command below. It is failing with the below error:-
jabongs-MacBook-Pro-4:florest debraj$ go get ./...
go install github.com/jabong/florest/src/common/config: open /var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/go-build823644730/github.com/jabong/florest/src/common/config.a: no such file or directory
go install github.com/jabong/florest/src/common/utils/responseheaders: open /var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/go-build823644730/github.com/jabong/florest/src/common/utils/responseheaders.a: no such file or directory
go install github.com/jabong/florest/src/service: open /var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/go-build823644730/github.com/jabong/florest/src/service.a: no such file or directory
Below is the output using -x flag:-
jabongs-MacBook-Pro-4:florest debraj$ go get -x ./...
WORK=/var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/go-build665863426
mkdir -p $WORK/github.com/jabong/floRest/src/examples/_obj/
mkdir -p $WORK/github.com/jabong/floRest/src/
cd /Users/debraj/golang/src/github.com/jabong/floRest/src/examples
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/github.com/jabong/floRest/src/examples.a -trimpath $WORK -p github.com/jabong/floRest/src/examples -complete -buildid febe48d3c570d8539844891977fbdc206dc458b4 -D _/Users/debraj/golang/src/github.com/jabong/floRest/src/examples -I $WORK -I /Users/debraj/golang/pkg/darwin_amd64 -pack ./api_definition.go ./data_structures.go ./hello_world.go ./hello_world_health_checker.go ./hello_world_multipe_errors.go ./swagger.go
mkdir -p $WORK/github.com/jabong/floRest/src/service/_obj/
mkdir -p $WORK/github.com/jabong/florest/src/examples/_obj/
mkdir -p $WORK/github.com/jabong/florest/src/
cd /Users/debraj/golang/src/github.com/jabong/floRest/src/service
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/github.com/jabong/floRest/src/service.a -trimpath $WORK -p github.com/jabong/floRest/src/service -complete -buildid f55b565340e2d0d690f5de8bd424fffb8895a331 -D _/Users/debraj/golang/src/github.com/jabong/floRest/src/service -I $WORK -I /Users/debraj/golang/pkg/darwin_amd64 -pack ./api_interface.go ./business_logic_executor.go ./config_manager.go ./constants.go ./dynamic_config_manager.go ./health_checker.go ./http_response_creator.go ./init_manager.go ./monitor_helper.go ./service_register.go ./service_version_helper.go ./service_workflow_data.go ./uri_interpreter.go ./web_server.go
cd /Users/debraj/golang/src/github.com/jabong/florest/src/examples
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/github.com/jabong/florest/src/examples.a -trimpath $WORK -p github.com/jabong/florest/src/examples -complete -buildid febe48d3c570d8539844891977fbdc206dc458b4 -D _/Users/debraj/golang/src/github.com/jabong/florest/src/examples -I $WORK -I /Users/debraj/golang/pkg/darwin_amd64 -pack ./api_definition.go ./data_structures.go ./hello_world.go ./hello_world_health_checker.go ./hello_world_multipe_errors.go ./swagger.go
mkdir -p $WORK/github.com/jabong/florest/src/examples/cachestrategy/_obj/
mkdir -p $WORK/github.com/jabong/florest/src/examples/
cd /Users/debraj/golang/src/github.com/jabong/florest/src/examples/cachestrategy
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/github.com/jabong/florest/src/examples/cachestrategy.a -trimpath $WORK -p github.com/jabong/florest/src/examples/cachestrategy -complete -buildid c16efba4536c81f8b5b9f0090f909c0b3c71383c -D _/Users/debraj/golang/src/github.com/jabong/florest/src/examples/cachestrategy -I $WORK -I /Users/debraj/golang/pkg/darwin_amd64 -pack ./api_definition.go ./cache_strategy_user.go ./sample_db_adapter.go
mkdir -p $WORK/github.com/jabong/florest/src/service/_obj/
cd /Users/debraj/golang/src/github.com/jabong/florest/src/service
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/github.com/jabong/florest/src/service.a -trimpath $WORK -p github.com/jabong/florest/src/service -complete -buildid f55b565340e2d0d690f5de8bd424fffb8895a331 -D _/Users/debraj/golang/src/github.com/jabong/florest/src/service -I $WORK -I /Users/debraj/golang/pkg/darwin_amd64 -pack ./api_interface.go ./business_logic_executor.go ./config_manager.go ./constants.go ./dynamic_config_manager.go ./health_checker.go ./http_response_creator.go ./init_manager.go ./monitor_helper.go ./service_register.go ./service_version_helper.go ./service_workflow_data.go ./uri_interpreter.go ./web_server.go
mkdir -p /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/floRest/src/
mv $WORK/github.com/jabong/floRest/src/examples.a /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/floRest/src/examples.a
mkdir -p /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/
cp $WORK/github.com/jabong/florest/src/examples.a /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/examples.a
go install github.com/jabong/florest/src/examples: open /var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/go-build665863426/github.com/jabong/florest/src/examples.a: no such file or directory
mkdir -p /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/examples/
mv $WORK/github.com/jabong/florest/src/examples/cachestrategy.a /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/examples/cachestrategy.a
mv $WORK/github.com/jabong/floRest/src/service.a /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/floRest/src/service.a
mkdir -p $WORK/github.com/jabong/florest/_obj/
mkdir -p $WORK/github.com/jabong/florest/_obj/exe/
cd /Users/debraj/golang/src/github.com/jabong/florest
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/github.com/jabong/florest.a -trimpath $WORK -p main -complete -buildid fb73c44c8d0536fc3134f24ae052fdb67036f537 -D _/Users/debraj/golang/src/github.com/jabong/florest -I $WORK -I /Users/debraj/golang/pkg/darwin_amd64 -pack ./main.go
mkdir -p $WORK/github.com/jabong/florest/src/test/servicetest/_obj/
mkdir -p $WORK/github.com/jabong/florest/src/test/
cd /Users/debraj/golang/src/github.com/jabong/florest/src/test/servicetest
/usr/local/go/pkg/tool/darwin_amd64/compile -o $WORK/github.com/jabong/florest/src/test/servicetest.a -trimpath $WORK -p github.com/jabong/florest/src/test/servicetest -complete -buildid 9936e7e44a8331913a166a228aa8e088d0b05adf -D _/Users/debraj/golang/src/github.com/jabong/florest/src/test/servicetest -I $WORK -I /Users/debraj/golang/pkg/darwin_amd64 -pack ./config_initialize.go ./logger_initialize.go ./service_initialize.go ./service_test_helper.go ./test_web_server.go
cp $WORK/github.com/jabong/florest/src/service.a /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/service.a
go install github.com/jabong/florest/src/service: open /var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/go-build665863426/github.com/jabong/florest/src/service.a: no such file or directory
cd .
/usr/local/go/pkg/tool/darwin_amd64/link -o $WORK/github.com/jabong/florest/_obj/exe/a.out -L $WORK -L /Users/debraj/golang/pkg/darwin_amd64 -extld=clang -buildmode=exe -buildid=fb73c44c8d0536fc3134f24ae052fdb67036f537 $WORK/github.com/jabong/florest.a
mkdir -p /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/test/
mv $WORK/github.com/jabong/florest/src/test/servicetest.a /Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/test/servicetest.a
mkdir -p /Users/debraj/golang/bin/
mv $WORK/github.com/jabong/florest/_obj/exe/a.out /Users/debraj/golang/bin/florest
Can someone let me know why this error is coming? This is working perfectly fine on Ubuntu.
Version
MacOS X - 10.11.4
GoLang - 1.6.1
The issue was found after discussing in golang-nuts. Just quoting it below again:-
My guess is that's because Mac filesystem is case preserving but not
case-sensitive, meaning that in mac os "floRest" and "florest" is the
same file/directory while on linux those are 2 distinct files. (you
can configure mac filesystem to be case-sensitive as well, but that's
not the default).
As you can see in the logs:
mv $WORK/github.com/jabong/floRest/src/examples.a
/Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/floRest/src/examples.a
mkdir -p
/Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/
cp $WORK/github.com/jabong/florest/src/examples.a
/Users/debraj/golang/pkg/darwin_amd64/github.com/jabong/florest/src/examples.a
go install github.com/jabong/florest/src/examples: open
/var/folders/lp/3q9_2mn51hd9s4yj_jcf3jxm0000gp/T/go-build665863426/github.com/jabong/florest/src/examples.a:
no such file or directory
a file "floRest/src/examples.a" is moved and then there's an attempt
to copy "florest/src/examples.a", which is the same file on mac os,
and it's no longer there.
For cloning the repo I used:-
git clone https://github.com/jabong/florest/
So in mac my code checked out in a directory florest. But the actual repo name was https://github.com/jabong/floRest/ and in code it was referenced as floRest which was causing the issue.

Getting libcrypto ar error while compiling OpenSSL for Mac

I have been able to compile a specific version of OpenSSL for iOS devices, and I am now trying to compile for Mac OSX. However, when I run my bash script (provided below) I am getting the following error:
ar r ../../libcrypto.a o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
ar: ../../libcrypto.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: ../../libcrypto.a: Inappropriate file type or format
When I run lipo -info libcrypto.a I get the following result:
Architectures in the fat file: libcrypto.a are: i386 x86_64
This does not make any sense, as my bash script is only configuring OpenSSL for i386 (I was looping to do both, but removed x86_64 once I started getting these problems).
I have tried following the answers for similar SO questions here and here. However, those yielded the same results. Additionally, the Mac installation instructions on the OpenSSL Wiki were of no help either.
My scripts:
Build.sh
projectDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ARCHS=("i386")
FIPS_VERSION="2.0.12"
OPENSSL_VERSION="1.0.2g"
rm -rf openssl* fips*
if [ -d "out" ]; then
rm -rf out
fi
mkdir out
source ./Build-FIPS.sh
cd $projectDir
source ./Build-OpenSSL.sh
Build-OpenSSL.sh
set -e
function main() {
verifyopenssl
for ((i=0; i < ${#ARCHS[#]}; i++))
do
makeopenssl "${ARCHS[i]}"
done
}
function verifyopenssl() {
gpg --verify $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz.asc
tar -zxf $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz
cd openssl-$OPENSSL_VERSION
}
function makeopenssl() {
BUILD_ARCH=$1
SDK_NAME="macosx"
GCC=$(xcrun -sdk ${SDK_NAME} -find gcc)
SDK_PATH=$(xcrun -sdk ${SDK_NAME} --show-sdk-path)
MACHINE="darwin-i386-cc"
# BSD_ARCH="BSD-generic32"
CONFIG_ARGS="$MACHINE \
$BSD_ARCH \
--openssldir=$projectDir/out/openssl_${BUILD_ARCH} \
fips \
--with-fipsdir=${projectDir}/out/fips_${BUILD_ARCH} \
no-idea \
no-cast \
no-seed \
no-md2 \
no-sha0 \
no-whirlpool \
-DL_ENDIAN"
export CC="${GCC} -arch ${BUILD_ARCH}"
export CFLAGS="-isysroot ${SDK_PATH} -I ${projectDir}/out/fips_${BUILD_ARCH}/include"
export LDFLAGS="-arch $BUILD_ARCH"
./Configure ${CONFIG_ARGS}
make depend
make
# make install
# make clean && make dclean
}
main $#
Following #jww's answer, I found that changing the following line (around line 69) in the main Makefile (the one in the root folder) solved the ar linking problem that #jww mentioned:
AR= ar $(ARFLAGS) r to AR= libtool -o
Making this change did get me further along in the process. However, I began having other problems. Further "research" led me to the OpenSSL FAQ page which had a question talking about OpenSSL failing to build on Mac. It pointed me to the PROBLEMS file in the root directory of the OpenSSL source code. That file said that there is a MAC ld problem:
This is really a misfeature in ld, which seems to look for .dylib
libraries along the whole library path before it bothers looking for
.a libraries. This means that -L switches won't matter unless OpenSSL
is built with shared library support.
The workaround may be to change the following lines in apps/Makefile
and test/Makefile:
LIBCRYPTO=-L.. -lcrypto
LIBSSL=-L.. -lssl
to:
LIBCRYPTO=../libcrypto.a
LIBSSL=../libssl.a
With this information, I created a patch file for the root Makefile and the Makefile in the apps folder. I also found that I had to comment out the instructions in the main Makefile and the apps/Makefile to build the openssl binary / executable. This should only be necessary if you want to run make install.
The patch files exists at the same level as the Build.sh script. And after fiddling around with my Build-OpenSSL.sh script I was finally able to get it to build for both i386 and x86_64.
For future reference, I am including the complete contents of the two patch files, and the original two script files below.
Build.sh
#!/bin/bash
#
projectDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ARCHS=("i386" "x86_64")
FIPS_VERSION="2.0.12"
OPENSSL_VERSION="1.0.2g"
rm -rf openssl*
if [ -d "out" ]; then
rm -rf out
fi
mkdir out
source ./Build-FIPS.sh
source ./Build-OpenSSL.sh
Build-OpenSSL.sh
#!/bin/bash
#
set -e
function main() {
verifyopenssl
for ((i=0; i < ${#ARCHS[#]}; i++))
do
makeopenssl "${ARCHS[i]}"
done
}
function verifyopenssl() {
gpg --verify $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz.asc
tar -zxf $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz
cd openssl-$OPENSSL_VERSION
}
function makeopenssl() {
BUILD_ARCH=$1
SDK_NAME="macosx"
GCC=$(xcrun -sdk ${SDK_NAME} -find gcc)
SDK_PATH=$(xcrun -sdk ${SDK_NAME} --show-sdk-path)
if [[ $BUILD_ARCH = "i386" ]]; then
MACHINE="darwin-i386-cc"
NISTP=""
elif [[ $BUILD_ARCH = "x86_64" ]]; then
MACHINE="darwin64-x86_64-cc"
NISTP="enable-ec_nistp_64_gcc_128"
else
exit
fi
CONFIG_ARGS="$MACHINE \
$NISTP \
--openssldir=$projectDir/out/openssl_${BUILD_ARCH} \
fips \
--with-fipsdir=${projectDir}/out/fips_${BUILD_ARCH} \
no-idea \
no-cast \
no-seed \
no-md2 \
no-sha0 \
no-whirlpool \
-DL_ENDIAN"
./Configure ${CONFIG_ARGS}
patch Makefile < ../MainMake.patch
patch apps/Makefile < ../AppMake.patch
make depend
make build_libcrypto build_libssl
make install_sw
make clean && make dclean
patch -R Makefile < ../MainMake.patch
patch -R apps/Makefile < ../AppMake.patch
}
main $#
AppMake.patch
--- apps/Makefile 2016-03-01 06:36:53.000000000 -0700
+++ ../Makefile 2016-05-06 13:00:16.000000000 -0600
## -26,8 +26,8 ##
DLIBCRYPTO=../libcrypto.a
DLIBSSL=../libssl.a
-LIBCRYPTO=-L.. -lcrypto
-LIBSSL=-L.. -lssl
+LIBCRYPTO=../libcrypto.a
+LIBSSL=../libssl.a
PROGRAM= openssl
## -101,24 +101,24 ##
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
install:
- #[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
- #set -e; for i in $(EXE); \
- do \
- (echo installing $$i; \
- cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
- chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
- mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
- done;
- #set -e; for i in $(SCRIPTS); \
- do \
- (echo installing $$i; \
- cp $$i $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
- chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
- mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i ); \
- done
- #cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
- chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
- mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
+ # #[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
+ # #set -e; for i in $(EXE); \
+ # do \
+ # (echo installing $$i; \
+ # cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
+ # chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
+ # mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
+ # done;
+ # #set -e; for i in $(SCRIPTS); \
+ # do \
+ # (echo installing $$i; \
+ # cp $$i $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
+ # chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
+ # mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i ); \
+ # done
+ # #cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
+ # chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
+ # mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
tags:
ctags $(SRC)
MainMake.patch
--- Makefile 2016-05-06 13:06:11.000000000 -0600
+++ ../Makefile 2016-05-06 13:06:44.000000000 -0600
## -602,8 +602,8 ##
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
- cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
- chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
+ # cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
+ # chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
install_html_docs:
here="`pwd`"; \
ar r ../../libcrypto.a o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
ar: ../../libcrypto.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: ../../libcrypto.a: Inappropriate file type or format
ar, libtool and -arch is the reason the answer says "... supplying -arch x86_64 -arch i386 will result in a build failure because of the way OpenSSL's build system forms commands" at Build Multiarch OpenSSL on OS X.
You need to use Apple's libtool, and stop using ar. Apple's libtool knows about architectures, ar does not.
Another small wrinkle is the makefile does something like this, if I recall correctly. It makes it difficult to simply use Apple's libtool, and stop using ar:
$(AR) $(ARFLAGS) $# ...
In many makefiles you can simply make AR="libtool -o", but this case is different because the command comes out libtool -o r libcrypto.a or similar. I also seem to recall something like make AR="libtool" ARFLAGS="r -o $#" does not work well either.
I used to patch the makefile after config to do it.

Resources