Flutter -ios - pod install gRPC-C++ sed ssl issue - ios

I have been running through this issue when I do pod install in my flutter project. (I'm going to answer this myself as I reached the solution after couple of hours - I hope it's helpful to anybody reading this in the future
Installing firebase_storage (5.0.1)
Installing flutter_local_notifications (0.0.1)
Installing flutter_plugin_android_lifecycle (0.0.1)
Installing fluttertoast (0.0.2)
Installing gRPC-C++ (1.28.2)
[!] /bin/bash -c
set -e
sed -E -i '' 's;#include <openssl/(.*)>;#if COCOAPODS==1\
#include <openssl_grpc/\1>\
#else\
#include <openssl/\1>\
#endif;g' $(find src/core -type f \( -path '*.h' -or -path '*.cc' \) -print | xargs grep -H -c '#include <openssl_grpc/' | grep 0$ | cut -d':' -f1)
find src/core/ third_party/upb/ -type f \( -name '*.h' -or -name '*.c' -or -name '*.cc' \) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "upb/(.*)";#if COCOAPODS==1\
#include "third_party/upb/upb/\1"\
#else\
#include "upb/\1"\
#endif;g'
find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm
find src/core/ src/cpp/ -type f \( -name '*.h' -or -name '*.c' -or -name '*.cc' \) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\
#include "src/core/ext/upb-generated/\1.upb.h"\
#else\
#include "\1.upb.h"\
#endif;g'
find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm
sed: can't read s;#include <openssl/(.*)>;#if COCOAPODS==1\
#include <openssl_grpc/\1>\
#else\
#include <openssl/\1>\
#endif;g: No such file or directory

In the ios folder run
brew unlink gnu-sed
then
Pod install

You need to remove the gnu-sed Path variable.
/usr/local/Cellar/gnu-sed/4.8/libexec/gsed

Related

Include man pages in ubuntu docker image?

https://github.com/tianon/docker-brew-ubuntu-core/issues/122
RUN apt-get -y update && \
dpkg -l | grep ^ii | cut -d' ' -f3 | xargs apt-get install -y --reinstall
I use the above command to install manpages in an ubuntu docker image.
But I got this error. Does anybody know how to fix the problem? Thanks.
...
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/w.procps because link group w is broken
Processing triggers for libc-bin (2.31-0ubuntu9) ...
E: Could not configure 'libc6:amd64'.
E: Could not perform immediate configuration on 'libgcc-s1:amd64'. Please see man 5 apt.conf under APT::Immediate-Configure for details. (2)
The command '/bin/sh -c apt-get -y update && dpkg -l | grep ^ii | cut -d' ' -f3 | xargs apt-get install -y --reinstall' returned a non-zero code: 123
The problem seems to be just with reinstalling the libgcc-s1:amd64 package. I found I could 'skip' that one and everything works okay.
Here is the modified RUN line that I use
RUN apt-get -y update && \
dpkg -l | grep ^ii | cut -d' ' -f3 | grep -v '^libgcc-s1:amd64$' | xargs apt-get install -y --reinstall

Dockerfile String interpolation dosent work

I have been trying to run Dockerfile with the below command.
RUN NODE_VERSION=$( \
curl -sL https://nodejs.org/dist/latest/ | \
tac | \
tac | \
grep -oPa -m 1 '(?<=node-v)(.*?)(?=-linux-x64\.tar\.xz)' | \
head -1 \
) \
&& echo $NODE_VERSION \
&& curl -SLO "https://nodejs.org/dist/latest/node-v$NODE_VERSION-linux-x64.tar.xz" -o "node-v$NODE_VERSION-linux-x64.tar.xz" \
&& curl -SLO "https://nodejs.org/dist/latest/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
However, for some reason, I see the echo $NODE_VERSION outputs the version details, but, the NODE_VERSION details are not available in the subsequent curl command. What could be going wrong?
It would seem that your output assigned to $NODE_VERSION contains a newline which will cause most of your commands to error out.
You would want to strip the newlines from the output. Something similar to the following:
NODE_VERSION=$( \
curl -sL https://nodejs.org/dist/latest/ | \
grep -oPa -m 1 '(?<=node-v)(.*?)(?=-linux-x64\.tar\.xz)' | \
head -1 | \
tr -d '\r\n' \
)
That should now get your output without any newlines. I removed the tac | tac as that seems redundant.

GNU Make: startup a Docker Container, make it execute commands, exit container, execute a script

I am creating a virtual machine (VM) for an embedded device that runs both C and Java code by compiling both to bytecode.
Now I am trying to automate compiling and flashing C applications (Java already works).
A big manual part is taking a .c file and getting it to a format the VM understands.
Currently, it works as follows:
Boot up a Docker Container while pointing it towards where the .c file is and giving myself bash
~$ docker run -i -v /home/git/bytecode_manipulation:/c_files -t lljvm_work /bin/bash
Use the configured lljvm-cc tool of the container to convert the .c file while producing a jasmin file (an intermediate for converting to bytecode)
docker_container$ lljvm-cc test_c_srv.c -o test_c_srv -g3
Exit the docker container and run a python script which converts the .j jasmin file to a .uj jasmin file, converts the .uj file to a .class file and puts it in a good folder
~$ ./script_j_to_uj.py test_c_srv.j test_srv.uj
I'd like to automate this in a Makefile.
Currently, I have a recipe in my makefile that generates .class files for the Java apps, then scoops up all .class files (from either C or Java apps). processes them somewhat further into .raw_ujc files and generates a list of then. Ideally, this would now also generate .class files for the C apps.
The recipe:
jre_filelist:
CLASSPATH=$(SELF)/default_runtime/real:$(SELF)/default_runtime/fake:$(SELF)/default_runtime/fake/uj \
javac $(SELF)/default_runtime/real/java/lang/*.java $(SELF)/default_runtime/UJSrv.java
find $(SELF)/ -iname "Exception.class" -type f > $(SELF)/files #First call is overwriting
find $(SELF)/ -iname "Runnable.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "String.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "StringBuilder.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "Thread.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "Throwable.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "UJSrv.class" -type f >> $(SELF)/files
$(info findstring C in $(LANG) is $(findstring C, $(LANG)))
ifeq ($(findstring C, $(LANG)),C) # include C runtime
CLASSPATH=$(SELF)/default_runtime/real:$(SELF)/default_runtime/fake:$(SELF)/default_runtime/fake/uj:$(SELF)/lljvm \
javac $(SELF)/lljvm/runtime/*.java
CLASSPATH=$(SELF)/default_runtime/real:$(SELF)/default_runtime/fake:$(SELF)/default_runtime/fake/uj:$(SELF)/lljvm \
javac $(SELF)/lljvm/lib/*.java
find $(SELF)/lljvm/runtime -iname "*.class" -type f >> $(SELF)/files
find $(SELF)/lljvm/lib -iname "*.class" -type f >> $(SELF)/files
$(foreach SRV, $(SRVS_C), \
find $(UJ_DIR)/services/c/ -iname "$(SRV).class" -type f | xargs realpath >> $(SELF)/files && \
) true
endif
$(foreach SRV, $(SRVS_JAVA), \
CLASSPATH=$(SELF)/default_runtime javac $(UJ_DIR)/services/java/$(SRV).java && \
find $(UJ_DIR)/services/java/ -iname "$(SRV).class" -type f | xargs realpath >> $(SELF)/files && \
) true
#while read -r file; do \
$(CMD) "$$file" >/dev/null; \
done < $(SELF)/files;
rm -f $(SELF)/files && rm -f ../filelist.txt
find $(SELF)/default_runtime/ -iname "*.raw_ujc" -type f > ../filelist.txt
ifeq ($(findstring C, $(LANG)),C) # include C runtime
find $(SELF)/lljvm/ -iname "*.raw_ujc" -type f >> ../filelist.txt
endif
$(foreach SRV, $(SRVS_C), \
find $(UJ_DIR)/services/c/ -iname "$(SRV).raw_ujc" -type f | xargs realpath >> ../filelist.txt && \
) true
$(foreach SRV, $(SRVS_JAVA), \
find $(UJ_DIR)/services/java/ -iname "$(SRV).raw_ujc" -type f | xargs realpath >> ../filelist.txt && \
) true
So doing these steps is a bit difficult and I was hoping for advice. Main thing is either booting a container or pre-starting a container and feeding it commands.
After tinkering around, I've this does what I want:
compile_c:
docker run -v $(UJ_DIR)/services/c/:/c_files -w /c_files -it lljvm_work \
/bin/bash -c '../usr/local/lib/lljvm/lljvm-cc $(SRV).c -l_c_support -o $(SRV) -g3'
sudo python script_j_to_uj.py $(UJ_DIR)/services/c/$(SRV).j $(UJ_DIR)/services/c/$(SRV).uj
rm -f $(UJ_DIR)/services/c/$(SRV)
In the recipe, it is used as follows:
jre_filelist:
CLASSPATH=$(SELF)/default_runtime/real:$(SELF)/default_runtime/fake:$(SELF)/default_runtime/fake/uj \
javac $(SELF)/default_runtime/real/java/lang/*.java $(SELF)/default_runtime/UJSrv.java
find $(SELF)/ -iname "Exception.class" -type f > $(SELF)/files #First call is overwriting
find $(SELF)/ -iname "Runnable.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "String.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "StringBuilder.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "Thread.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "Throwable.class" -type f >> $(SELF)/files
find $(SELF)/ -iname "UJSrv.class" -type f >> $(SELF)/files
$(info findstring C in $(LANG) is $(findstring C, $(LANG)))
ifeq ($(findstring C, $(LANG)),C) # include C runtime
CLASSPATH=$(SELF)/default_runtime/real:$(SELF)/default_runtime/fake:$(SELF)/default_runtime/fake/uj:$(SELF)/lljvm \
javac $(SELF)/lljvm/runtime/*.java
CLASSPATH=$(SELF)/default_runtime/real:$(SELF)/default_runtime/fake:$(SELF)/default_runtime/fake/uj:$(SELF)/lljvm \
javac $(SELF)/lljvm/lib/*.java
# find $(SELF)/default_runtime/real/java/lang/lljvm/util -iname "*.class" -type f >> $(SELF)/files
# find $(SELF)/default_runtime/real//java/lang/lljvm/tools -iname "*.class" -type f >> $(SELF)/files
# find $(SELF)/default_runtime/real//java/lang/lljvm/tools/info -iname "*.class" -type f >> $(SELF)/files
# find $(SELF)/default_runtime/real//java/lang/lljvm/tools/ld -iname "*.class" -type f >> $(SELF)/files
find $(SELF)/lljvm/runtime -iname "*.class" -type f >> $(SELF)/files
# find $(SELF)/default_runtime/real//java/lang/lljvm/io -iname "*.class" -type f >> $(SELF)/files
find $(SELF)/lljvm/lib -iname "*.class" -type f >> $(SELF)/files
$(foreach SRV, $(SRVS_C), \
make compile_c SRV=$(SRV) && \
find $(UJ_DIR)/services/c/ -iname "$(SRV).class" -type f | xargs realpath >> $(SELF)/files && \
) true
endif
$(foreach SRV, $(SRVS_JAVA), \
CLASSPATH=$(SELF)/default_runtime javac $(UJ_DIR)/services/java/$(SRV).java && \
find $(UJ_DIR)/services/java/ -iname "$(SRV).class" -type f | xargs realpath >> $(SELF)/files && \
) true
#while read -r file; do \
$(CMD) "$$file" >/dev/null; \
done < $(SELF)/files;
rm -f $(SELF)/files && rm -f ../filelist.txt
find $(SELF)/default_runtime/ -iname "*.raw_ujc" -type f > ../filelist.txt
ifeq ($(findstring C, $(LANG)),C) # include C runtime
find $(SELF)/lljvm/ -iname "*.raw_ujc" -type f >> ../filelist.txt
endif
$(foreach SRV, $(SRVS_C), \
find $(UJ_DIR)/services/c/ -iname "$(SRV).raw_ujc" -type f | xargs realpath >> ../filelist.txt && \
) true
$(foreach SRV, $(SRVS_JAVA), \
find $(UJ_DIR)/services/java/ -iname "$(SRV).raw_ujc" -type f | xargs realpath >> ../filelist.txt && \
) true

Where is the download(curl/wget) package in docker container

In the DockerFile, it has the sample codes:
RUN curl https://collectd.org/files/collectd-5.5.0.tar.gz | tar zxf - &&\
cd collectd* &&\
./configure &&\
grep -rl /proc/ . | xargs sed -i "s/\/proc\//\/host\/proc\//g" &&\
make all install
What the codes do is to download the software 'collectd' and unzip it, then to install it.
The 'collectd' installed sucessful, but where is the downloaded software store? Specifically, where is the collectd?
Thanks for help.

mkdir from grep and pipe

I have this little script that puts out some dir paths.
I want to mkdir all those paths.
for filename in $(git ls-files | grep .java | grep -v 'com/foo' | sed -e 's/\(.java[^/]*\).java/\1/' | uniq)
do
echo "$filename" | sed -e 's/com\/old\/old/com\/new/' | sed 's/\(.*\)\/.*/\1/'
done
So new dir are created... com/old/old = com/new
But I cannot get that mkdir to work... I tried..
path=$("$filename" | sed -e 's/com\/old\/old/com\/new/' | sed 's/\(.*\)\/.*/\1/')
mkdir -p "$path"
That is just messing with the file contents.
You should be able to do all the substitutions in one sed command, and it can also filter out com/foo. Then pipe the output to a while read loop.
git ls-files | grep .java |
sed -e '/com\/foo/d' -e 's/\(.java[^/]*\).java/\1/' -e 's/com\/old\/old/com\/new/' -e 's/\(.*\)\/.*/\1/' |
uniq | while read path; do
mkdir -p "$path"
done
Here's how to do your git mv:
git ls-files | grep .java |
sed -e '/com\/intuit/d' -e 's/\(.java[^/]*\).java/\1/' | uniq |
while read path; do
dir=$(echo "$path" | sed -e 's/com\/old\/old/com\/new/' -e 's/\(.*\)\/.*/\1/')
mkdir -p "$dir"
git mv "$path" "$dir"
done

Resources