How can I get status of make command in OS X? - macos

I'm trying to compile tesseract-ocr on my Mac 10.9 but It gets stock at:
libtool: link: (cd ".libs" && rm -f "libtesseract.dylib" && ln -s "libtesseract.3.dylib" "libtesseract.dylib")
It really takes a long time and I don't know if it is doing anything useful so is there any way I can get status of it's progress or at leas see what it is doing?
here is the lisf of commands I run to get here:
svn checkout http://tesseract-ocr.googlecode.com/svn/trunk/ tesseract-ocr
cd tesseract-ocr
sh ./autogen.sh
./configure
make
By the way it takes my CPU activity very high that my MacBook fan is turned on. I'm also using iTerm as my shell.

Related

Can't find nix-env or nix-build on MacOS Catalina

I can't find nix-env, nix-build, nix-shell etc. on MacOS Catalina.
I installed with:
sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
and was able to run them yesterday. I restarted my computer and can no longer find them. find / -name nix-env | grep nix-env shows nothing.
I tried installing again with the same command (sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume) but this time it exists immediately with 0 status code.
I suspect I need to do something to mount a virtual drive.
You should follow Notes on the recommended approach.
It looks like the volume is not mounted (check /etc/fstab state with vifs as described in documentation).
Use the Disk Utility UI to remove the nix volume (sudo rm -rf /nix won't work).
Then run the script again and cross fingers your fingers this time: sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
While Nix (amongst others) installs with bash newer MacOS do use zsh instead of bash.
So you need to update your .zshrc to source this command from bash, too.
In your terminal start editing with:
sudo nano ~/.zshrc
and add:
source ~/.nix-profile/etc/profile.d/nix.sh
Reload and test with
source ~/.zshrc; nix --version

dtruss fails on ps on OS X 10.11

I was trying to see which syscall ps uses to get the command line of a process on OS X 10.11 (El Capitan), and ran into the following error:
# dtruss ps -p 43520 -o args
dtrace: failed to execute ps: dtrace cannot control executables signed with restricted entitlements
Googling resulted in the suggestion that making a copy of ps would allow me to bypass this, but that didn't work for me. Why can't I run dtruss on arbitrary binaries anymore, and is there any way for me to restore the old behavior?
The issue has to do with the code signature. If you make a copy and then re-sign it with your own identity (or, presumably, any non-Apple identity), then dtrace will attach to it just fine.
$ mkdir ~/temp
$ cp /bin/ps ~/temp/
$ codesign -f -s `whoami` ~/temp/ps
$ sudo dtruss ~/temp/ps -p 43520 -o args
cannot control executables signed with restricted entitlements
Security Integrity Protection ('rootless') is now preventing dtruss from operating here.
You can disable it by booting into Recovery mode, but it looks like dtrace has specifically been blocked regardless of the state of rootless, as can be seen in the source code if you search for "dtrace cannot control".
You can also see from the comments in Pcreate:
/*
* <rdar://problem/13969762>:
* If the process is signed with restricted entitlements, the libdtrace_dyld
* library will not be injected in the process. In this case we kill the
* process and report an error.
*/

How to add bash command completion for Docker on Mac OS X?

I am running docker and I want bash command completion for docker commands and parameters.
If you have already homebrew bash-completion installed just install the docker completion script into the bash_completion.d
curl -XGET https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker > $(brew --prefix)/etc/bash_completion.d/docker
Note: If you do not have homebrew bash-completion installed, follow these instructions to install it before you execute the line above.
Note: the completion depends on some functions defined in debian bash-completion. Therefore, just sourcing the docker completion script as described in completion/bash/docker may not work. If you try to complete docker run (by hitting TAB) you may get an error like __ltrim_colon_completions: command not found. This could mean that you have not installed the bash-completion scripts.
The official Docker for Mac page has a section on installing bash completion:
https://docs.docker.com/docker-for-mac/#bash
If you have Homebrew bash completion installed:
cd /usr/local/etc/bash_completion.d
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion
The completion scripts come with Docker Beta. I want them to stay up to date. So, on OS X...
Install homebrew's bash-completion
Symlink the files
find /Applications/Docker.app \
-type f -name "*.bash-completion" \
-exec ln -s "{}" "$(brew --prefix)/etc/bash_completion.d/" \;
The stumbling point for me was that once you brew install bash-competion, you have to add few lines in your .bash_profile to load it once you launch Terminal:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Source:
http://davidalger.com/development/bash-completion-on-os-x-with-brew/
Because I haven't found anywhere a step by step documentation, I've made a quick script to install homebrew, bash-completion and eventually the completion scripts for docker.
https://github.com/HypnoTheNomad/docker-bash-completion-macos-brew
The auto completion of docker needed not only for mac, its also needed for ubuntu / bash terminals.
In Ubuntu
curl -ksSL https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker |sudo tee /etc/bash_completion.d/docker
Completion will be available upon next login.
Since its top result in google I added answer here.
The official Docker site has a section for Command-line completion, and for Mac to:
https://docs.docker.com/compose/completion/#mac
Helped for me with Homebrew:
brew install bash-completion
After the installation, Brew displays the installation path. From documentation is correct for me:
/usr/local/etc/bash_completion.d/
Run the script:
sudo curl -L https://raw.githubusercontent.com/docker/compose/1.25.4/contrib/completion/bash/docker-compose -o /usr/local/etc/bash_completion.d/docker-compose
Open and add following in the end of your file ~/.bash_profile:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Restart terminal. It's all.
Guide to setup autocomplete for ZSH on Mac OSX
Follow these steps if you are using oh-my-zsh and autocomplete is not working:
Step 1:
Make the following three links:
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose
Step 2:
Either add autoload -Uz compinit; compinit to .zshrc
or run echo "autoload -Uz compinit; compinit" >> .zshrc in your shell
Just to be said:
if you use brew:
brew install docker
will do all what you need. It includes brew link docker which installs the completion into `brew --prefix`/etc/bash_completion.d/docker
same topic, same answer for docker-machine, docker-compose, etc. ...
else (perhaps you are using Docker Beta (new "more native" docker installation package without Virtualbox) you still have to add it manually, then follow Michael's answer plus have a look at the additional completion scripts for docker-machine, docker-compose and some shell-helper that are handled in the 'script' from CodeCorrupt

Difference in details between "make install" and "make altinstall"

Here is my case:
I am using Ubuntu 10.04 (Lucid Lynx). The system's default Python is v2.6.5, but I need Python v2.7. So I downloaded the source from python.org and tried to install it.
The first time I installed it, I ran:
cd Python2.7.4
./configure --prefix=/usr
make
su root
make install
This installs Python 2.7 to my system. It will create a link, "python", in /usr/bin linking to python2.7 also in /usr/bin. So when I type >python, the system will start Python 2.7.4 for me just like when I type >python2.7.
But when I install this way:
cd Python2.7.4
./configure --prefix=/usr
make
su root
make altinstall
The link "python" in /usr/bin still exists and links to python2.6 which is the default system version. Of course, I can remove it and create a new soft link linking to python2.7.
What is the difference between the command "make install" and "make altinstall", except for the link in /usr/bin?
Let's take a look at the generated Makefile!
First, the install target:
install: altinstall bininstall maninstall
It does everything altinstall does, along with bininstall and maninstall
Here's bininstall; it just creates the python and other symbolic links.
# Install the interpreter by creating a symlink chain:
# $(PYTHON) -> python2 -> python$(VERSION))
# Also create equivalent chains for other installed files
bininstall: altbininstall
-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
else true; \
fi
(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
-rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
... (More links created)
And here's maninstall, it just creates "unversioned" links to the Python manual pages.
# Install the unversioned manual pages
maninstall: altmaninstall
-rm -f $(DESTDIR)$(MANDIR)/man1/python2.1
(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python2.1)
-rm -f $(DESTDIR)$(MANDIR)/man1/python.1
(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python2.1 python.1)
TLDR: altinstall skips creating the python link and the manual pages links, install will hide the system binaries and manual pages.
Simply: The altinstall target will make sure the default Python on your machine is not touched, or to avoid overwriting the system Python.

OS X: equivalent of Linux's wget

How can I do an HTTP GET from a Un*x shell script on a stock OS X system? (installing third-party software is not an option, for this has to run on a lot of different systems which I don't have control on).
For example if I start the Mercurial server locally doing a hg serve:
... $ hg serve
And then, from a Linux that has the wget command I do a wget:
... $ wget http://127.0.0.1:8000
--2010-12-31 22:18:25-- http://127.0.0.1:8000/
Connecting to 127.0.0.1:8000... connected.
HTTP request sent, awaiting response... 200 Script output follows
Length: unspecified [text/html]
Saving to: `index.html
And on the terminal in which I launched the "hg serve" command, I can indeed see that an HTTP GET made its way:
127.0.0.1 - - [30/Dec/2010 22:18:17] "GET / HTTP/1.0" 200 -
So on Linux one way to do an HTTP GET from a shell script is to use wget (if that command is installed of course).
What other ways are there to do the equivalent of a wget? I'm looking, in particular, for something that would work on stock OS X installs.
The following native command will work:
curl http://127.0.0.1:8000 -o outfile
Note that curl does not follow redirects by default. To tell it to do so, add -L to the argument list.
brew install wget
Homebrew is a package manager for OSX analogous to yum, apt-get, choco, emerge, etc. Be aware that you will also need to install Xcode and the Command Line Tools. Virtually anyone who uses the command line in OSX will want to install these things anyway.
If you can't or don't want to use homebrew, you could also:
Install wget manually:
curl -# "http://ftp.gnu.org/gnu/wget/wget-1.17.1.tar.xz" -o "wget.tar.xz"
tar xf wget.tar.xz
cd wget-1.17.1
./configure --with-ssl=openssl -with-libssl-prefix=/usr/local/ssl && make -j8 && make install
Or, use a bash alias:
function _wget() { curl "${1}" -o $(basename "${1}") ; };
alias wget='_wget'
Curl has a mode that is almost equivalent to the default wget.
curl -O <url>
This works just like
wget <url>
And, if you like, you can add this to your .bashrc:
alias wget='curl -O'
It's not 100% compatible, but it works for the most common wget usage (IMO)
1) on your mac type
nano /usr/bin/wget
2) paste the following in
#!/bin/bash
curl -L $1 -o $2
3) close then make it executable
chmod 777 /usr/bin/wget
That's it.
Use curl;
curl http://127.0.0.1:8000 -o index.html
Here's the Mac OS X equivalent of Linux's wget.
For Linux, for instance Ubuntu on an AWS instance, use:
wget http://example.com/textfile.txt
On a Mac, i.e. for local development, use this:
curl http://example.com/textfile.txt -o textfile.txt
The -o parameter is required on a Mac for output into a file instead of on screen. Specify a different target name for renaming the downloaded file.
Use capital -O for renaming with wget. Lowercase -o will specify output file for transfer log.
Instead of going with equivalent, you can try "brew install wget" and use wget.
You need to have brew installed in your mac.
You can either build wget on the mac machine or use MacPorts to install it directly.
sudo port install wget
This would work like a charm, also you can update to the latest version as soon as it's available. Port is much more stable than brew, although has a lot less number of formula and ports.
You can install MacPorts from https://www.macports.org/install.php you can download the .pkg file and install it.
You could use curl instead. It is installed by default into /usr/bin.
wget Precompiled Mac Binary
For those looking for a quick wget install on Mac, check out Quentin Stafford-Fraser's precompiled binary here, which has been around for over a decade:
https://statusq.org/archives/2008/07/30/1954/
MD5 for 2008 wget.zip: 24a35d499704eecedd09e0dd52175582
MD5 for 2005 wget.zip: c7b48ec3ff929d9bd28ddb87e1a76ffb
No make/install/port/brew/curl junk. Just download, install, and run. Works with Mac OS X 10.3-10.12+.

Resources