Saturday, June 23, 2018

Linux Mint: Compile and install the Go compiler from source

Objective


Set up bootstrapping. Build the latest version of the Go compiler with C bridge mode support from it's sources.

Motivation


By coincidence, I stumbled over this interesting tutorial about the programming language Go.
Since i was always interested to play around with that language, I took the opportunity, to try it out. As I usually want to use the latest compiler-version, I thought, it would be a good idea, that I do not use the Go-Installer, but compile the sources by myself from scratch. Unfortunately, the latest Go compiler, cannot be compiled with C support, when there is not already a Go compiler installed in the system. Therefore I also had to install an older Go compiler for booststrapping first.

Prerequisites



Solution


I decided to do the whole build and temporary stuff within the "Downloads" folder in my home account.
The boostrap toolchain will reside in the sub-directory "gobootstrap" within the "Downloads" folder.

Setup the bootstrap toolchain


Open a terminal. Download and install the latest Go bootstrap toolchain.

$> mkdir -p Downloads/goboostrap
$> cd Downloads/gobootstrap
$> wget https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz

you'll see some output similar to this:

--2018-06-23 17:58:49-- https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz
Resolving dl.google.com (dl.google.com)... 216.58.207.46, 2a00:1450:4001:824::200e
Connecting to dl.google.com (dl.google.com)|216.58.207.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11009739 (10M) [application/octet-stream]
Saving to: ‘go1.4-bootstrap-20171003.tar.gz.1’

go1.4-bootstrap-20171003.tar.gz.1 100%[==========================================================================>] 10,50M 5,23MB/s in 2,0s

2018-06-23 17:58:51 (5,23 MB/s) - ‘go1.4-bootstrap-20171003.tar.gz.1’ saved [11009739/11009739]

Now you have to unpack the downloaded toolchain package:

$> tar -xvzf go1.4-bootstrap-20171003.tar.gz

The whole stuff is unpacked into a new sub-directory "go"

go/.gitattributes
go/.gitignore
[...]
go/src/cmd/5g/gg.h
go/src/cmd/5g/ggen.c
go/src/cmd/5g/gobj.c
go/src/cmd/5g/gsubr.c
[...]
go/test/varerr.go
go/test/varinit.go
go/test/zerodivide.go

Change directory into the "./go/src" and build the bootstrap toolchain.
Observe: This step requires you to have already a functional GCC compiler present on your system.
If not already done: To set-up the GCC 7.3.0 on your system see Install multiple versions of GCC on your system

$> CGO_ENABLED=0 ./make.bash

# Building C bootstrap tool.
cmd/dist

# Building compilers and Go bootstrap tool for host, linux/amd64.
lib9
[...]
# Building packages and commands for linux/amd64.
runtime
errors
sync/atomic
[...]
cmd/pprof
net/rpc
net/http/fcgi
net/rpc/jsonrpc

Finally, the toolchain build is finished.

Compile the Go compiler


Before you compile the compiler, step back to the "Downloads" folder and download the latest source of the go compiler.

$> cd ~/Downloads
$> wget https://dl.google.com/go/go1.10.3.src.tar.gz

--2018-06-23 18:29:13-- https://dl.google.com/go/go1.10.3.src.tar.gz
Resolving dl.google.com (dl.google.com)... 216.58.207.78, 2a00:1450:4001:825::200e
Connecting to dl.google.com (dl.google.com)|216.58.207.78|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18323736 (17M) [application/octet-stream]
Saving to: ‘go1.10.3.src.tar.gz’

go1.10.3.src.tar.gz 100%[==========================================================================>] 17,47M 5,94MB/s in 2,9s

2018-06-23 18:29:16 (5,94 MB/s) - ‘go1.10.3.src.tar.gz’ saved [18323736/18323736]

Now, unpack the sources, like it was already done, with the toolchain package.

$> tar -xvzf go1.10.3.src.tar.gz

go/
go/AUTHORS
go/CONTRIBUTING.md
[...]
go/src/runtime/closure_test.go
go/src/runtime/compiler.go
go/src/runtime/complex.go
[...]
go/test/varinit.go
go/test/writebarrier.go
go/test/zerodivide.go

Again, step into the "src" directory and build the compiler, using the bootstrap toolchain.
This step may take a while, depending on the performance of your computer.

$> cd go/src
$> GOROOT_BOOTSTRAP=~/Downloads/gobootstrap/go ./all.bash

Building Go cmd/dist using /home/cschmidt/Downloads/gobootstrap/go.
Building Go toolchain1 using /home/cschmidt/Downloads/gobootstrap/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.

##### Testing packages.
ok archive/tar 0.051s
ok archive/zip 1.164s
ok bufio 0.186s
ok bytes 0.686s
ok compress/bzip2 0.132s
[...]
ok cmd/vendor/golang.org/x/arch/x86/x86asm 0.213s
ok cmd/vet 3.946s
ok cmd/vet/internal/cfg 0.033s

##### GOMAXPROCS=2 runtime -cpu=1,2,4 -quick
ok runtime 14.067s

##### cmd/go terminal test
PASS
ok _/home/cschmidt/Downloads/go/src/cmd/go/testdata/testterminal18153 0.001s

##### Testing without libgcc.
ok crypto/x509 1.016s
ok net 0.031s
ok os/user 0.038s

[...]

##### API check
Go version is "go1.10.3", ignoring -next /home/cschmidt/Downloads/go/api/next.txt

ALL TESTS PASSED
---
Installed Go for linux/amd64 in /home/cschmidt/Downloads/go
Installed commands in /home/cschmidt/Downloads/go/bin
*** You need to add /home/cschmidt/Downloads/go/bin to your PATH.

As I didn't want to have the Go compiler installed in my "Downloads" folder I simply move it directly into my home-account.

$> cd ~/Downloads
$> mv go ~/

Let's try to call the Go compiler

$> go

The program 'go' is currently not installed. You can install it by typing:
sudo apt install golang-go

Ouwww! What went wrong? -- Nothing!

I forgot to extend the PATH variable of my environment as mentioned by the hint, given after compilation.

To do so, I add the following line to my "~/.bashrc".

$> echo 'PATH=$PATH:$HOME/go/bin # Add go compiler' >> ~/.bashrc

Observe: Double-check, you use single quotes instead of double quotes here, otherwise, the bash will already expand the "$PATH" variable here and append it's content to your "~/.bashrc".

Once, again:
$> go

Go is a tool for managing Go source code.

Usage:

go command [arguments]
[...]

Yeah, finally done.
Just to clean up the mess within the "Downloads" directory by just deleting everything, I do not need anymore.

References:

  1. Go - Environment Setup
  2. Installing Go from source

Wednesday, June 20, 2018

Linux Mint: Build your own debian package of cmake

Objective


I wanted to use the newest available version of CMake (version 3.12.0-rc1) on Linux Mint 18.3 Sylvia.

Motivation


My company started using CMake as a Meta-Build-System in combination with Visual Studio 2017 in a brand new software project. Because of this fact, I had the opportunity, to attend a Modern CMake seminar at Eclipseina GmbH, covering most features of Modern CMake.
As Visual Studio 2017 comes with a CMake-component of version 3.10.0 already, I wanted at least to be able to use the same version of CMake on my Linux Mint 18.3 at home.
Modern CMake requires at least CMake version 3.x.

Unfortunately, the repository of Linux Mint 18.3 only supports a Debian package installer for CMake 3.5.1. The homepage of CMake at cmake.org only offers an install script, without uninstaller. I don't want to pollute my system with early access versions of software packages that I cannot clearly uninstall later.
In contrary, I wanted to be able to install and uninstall any version of CMake. Therefore I needed to build my own Debian install package (*.deb) for CMake.

Prerequisites



Solution


Install CMake locally


Open a terminal. Download and install the CMake installer script:

$> mkdir Downloads
$> cd Downloads
$> wget https://cmake.org/files/v3.12/cmake-3.12.0-rc1-Linux-x86_64.sh

you'll see some output like this:

--2018-06-19 22:58:04-- https://cmake.org/files/v3.12/cmake-3.12.0-rc1-Linux-x86_64.sh
Resolving cmake.org (cmake.org)... 66.194.253.19
Connecting to cmake.org (cmake.org)|66.194.253.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30260259 (29M) [text/x-sh]
Saving to: ‘cmake-3.12.0-rc1-Linux-x86_64.sh.1’

cmake-3.12.0-rc1-Linux-x86_64.sh 100%[==========================================================>] 28,86M 6,02MB/s in 5,3s

2018-06-19 22:58:10 (5,41 MB/s) - ‘cmake-3.12.0-rc1-Linux-x86_64.sh.1’ saved [30260259/30260259]

Now, set the executable flag for the downloaded script and start the temporary local install as normal user

$> chmod u+x cmake-3.12.0-rc1-Linux-x86_64.sh
$> ./cmake-3.12.0-rc1-Linux-x86_64.sh

CMake Installer Version: 3.12.0-rc1, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /home/cschmidt/Downloads

If you want to stop extracting, please press .
CMake - Cross Platform Makefile Generator
Copyright 2000-2018 Kitware, Inc. and Contributors
All rights reserved.

[...]
Do you accept the license? [yN]:

Accept the license, by typing 'y'.

By default the CMake will be installed in:
"/home/cschmidt/Downloads/cmake-3.12.0-rc1-Linux-x86_64"
Do you want to include the subdirectory cmake-3.12.0-rc1-Linux-x86_64?
Saying no will install in: "/home/cschmidt/Downloads" [Yn]:

Accept the default path, by typing 'Y'.

Using target directory: /home/cschmidt/Downloads/cmake-3.12.0-rc1-Linux-x86_64
Extracting, please wait...

Unpacking finished successfully

To be able to use the locally installed CMake, you must add it's binary directory to your environment path:
(Of course, you must use the path from above that reflects your install directory and add a "/bin" path-component here)

$> PATH=$PATH:/home/cschmidt/Downloads/cmake-3.12.0-rc1-Linux-x86_64/bin

Download and extract the CMake source package


$> wget https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz

--2018-06-19 23:15:38-- https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz
Resolving cmake.org (cmake.org)... 66.194.253.19
Connecting to cmake.org (cmake.org)|66.194.253.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8089283 (7,7M) [application/x-gzip]
Saving to: ‘cmake-3.12.0-rc1.tar.gz.1’

cmake-3.12.0-rc1.tar.gz.1 100%[==========================================================>] 7,71M 3,46MB/s in 2,2s

2018-06-19 23:15:42 (3,46 MB/s) - ‘cmake-3.12.0-rc1.tar.gz.1’ saved [8089283/8089283]

Extract the source tar-gz package:

$> tar -xvzf cmake-3.12.0-rc1.tar.gz
cmake-3.12.0-rc1/.clang-format
cmake-3.12.0-rc1/.clang-tidy
cmake-3.12.0-rc1/Auxiliary/
cmake-3.12.0-rc1/Auxiliary/bash-completion/
cmake-3.12.0-rc1/Auxiliary/bash-completion/cmake
cmake-3.12.0-rc1/Auxiliary/bash-completion/CMakeLists.txt
[...]
cmake-3.12.0-rc1/Utilities/Sphinx/static/cmake-favicon.ico
cmake-3.12.0-rc1/Utilities/Sphinx/static/cmake-logo-16.png
cmake-3.12.0-rc1/Utilities/Sphinx/static/cmake.css
cmake-3.12.0-rc1/Utilities/Sphinx/templates/
cmake-3.12.0-rc1/Utilities/Sphinx/templates/layout.html

Compile CMake from source using your temporary CMake installation


$> cd cmake-3.12.0-rc1
$> mkdir build
$> cd build/
$> cmake ..

CMake does some checks of your system and builds the binaries from source, which takes a while ...

-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
[...]
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cschmidt/Downloads/cmake-3.12.0-rc1/build
cschmidt@gimli:~/Downloads/cmake-3.12.0-rc1/build$ make
Scanning dependencies of target cmsys_c
[ 0%] Building C object Source/kwsys/CMakeFiles/cmsys_c.dir/ProcessUNIX.c.o
[ 0%] Building C object Source/kwsys/CMakeFiles/cmsys_c.dir/Base64.c.o
[...]
[ 1%] Building C object Source/kwsys/CMakeFiles/cmsys_c.dir/String.c.o
[ 1%] Linking C static library libcmsys_c.a
[...]
Scanning dependencies of target foo
[100%] Building CXX object Tests/FindPackageModeMakefileTest/CMakeFiles/foo.dir/foo.cpp.o
[100%] Linking CXX static library libfoo.a
[100%] Built target foo

Build the Debian package (*.deb)


If checkinstall is not installed on your machine, you can install it via:

$> sudo apt-get install checkinstall

On mine, it's already available, therefore...

Reading package lists... Done
Building dependency tree
Reading state information... Done
checkinstall is already the newest version (1.6.2-4ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Normally checkinstall needs to be run as root and does not only build the package, but also install the software.
To just build the package, without root privileges and without automatically installing it, we have to run checkinstall using fakeroot.

$> fakeroot checkinstall --install=no --fstrans=yes

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]: y

Confirm the question with 'y'.

Preparing package documentation...OK

*** No known documentation files were found. The new package
*** won't include a documentation directory.

*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values:

0 - Maintainer: [ cschmidt@gimli ]
1 - Summary: [ CMake Release Candidate (3.12.0-rc1) ]
2 - Name: [ build ]
3 - Version: [ 20180618 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ build ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ build ]
12 - Conflicts: [ ]
13 - Replaces: [ ]

Now you have the opportunity to change some meta-data, e.g. name and URL:

Enter a number to change any of them or press ENTER to continue: 0
Enter the maintainer's name and e-mail address:
>> cwschmidt

Enter a number to change any of them or press ENTER to continue: 9
Enter the alternate source location:
>> https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz

This package will be built according to these values:

0 - Maintainer: [ cwschmidt ]
1 - Summary: [ CMake Release Candidate (3.12.0-rc1) ]
2 - Name: [ build ]
3 - Version: [ 20180618 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ build ]
9 - Alternate source location: [ https://cmake.org/files/v3.12/cmake-3.12.0-rc1.tar.gz ]
10 - Requires: [ ]
11 - Provides: [ build ]
12 - Conflicts: [ ]
13 - Replaces: [ ]

Enter a number to change any of them or press ENTER to continue:

Finally, press Enter to continue

Installing with make install...

========================= Installation results ===========================
[ 1%] Built target cmsys_c
[ 2%] Built target cmsysTestsC
[ 4%] Built target cmsys
[...]
[100%] Built target pseudo_tidy
[100%] Built target pseudo_cppcheck
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/doc/cmake-3.12/Copyright.txt
-- Installing: /usr/local/share/cmake-3.12/Help
-- Installing: /usr/local/share/cmake-3.12/Help/prop_dir
-- Installing: /usr/local/share/cmake-3.12/Help/prop_dir/VS_GLOBAL_SECTION_PRE_section.rst
[...]
-- Installing: /usr/local/share/cmake-3.12/Modules
-- Installing: /usr/local/share/cmake-3.12/Modules/FindCurses.cmake
-- Installing: /usr/local/share/cmake-3.12/Modules/FindWget.cmake
-- Installing: /usr/local/share/cmake-3.12/Modules/FindAVIFile.cmake
[...]
-- Installing: /usr/local/bin/cmake
-- Installing: /usr/local/bin/ctest
-- Installing: /usr/local/bin/cpack
[...]
-- Installing: /usr/local/share/cmake-3.12/completions/cmake
-- Installing: /usr/local/share/cmake-3.12/completions/cpack
-- Installing: /usr/local/share/cmake-3.12/completions/ctest

======================== Installation successful ==========================

Some of the files created by the installation are inside the home directory: /home

You probably don't want them to be included in the package.
Do you want me to list them? [n]: y
Should I exclude them from the package? (Saying yes is a good idea) [n]: y

You were ask, to exclude the files that were placed in your home-directory.
To inspect the list, answer the first question with 'y'.
Answer the second question to exclude the files in the home-directory with 'y'.

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

NOTE: The package will not be installed

Erasing temporary files...OK

Writing backup package...OK
OK

Deleting temp dir...OK


**********************************************************************

Done. The new package has been saved to

/home/cschmidt/Downloads/cmake-3.12.0-rc1/build/build_20180618-1_amd64.deb
You can install it in your system anytime using:

dpkg -i build_20180618-1_amd64.deb

**********************************************************************

Finished. You can install the newly created package, by typing

$> sudo dpkg -i build_20180618-1_amd64.deb

or with your debian package manager with a double-click on the file "build_20180618-1_amd64.deb".

References:

  1. cmake.org
  2. How do I install the latest version of cmake from the command line?
  3. checkinstall source code inside home directory

Friday, July 28, 2017

Linux Mint: Mount your iPhone like an external drive to transfer photos and videos

Objective


I want to mount my "iPhone 5s" like any external disk-drive on my Linux Mint 18.2 "Sonya" to access my photos and videos. The "out-of-box" solution stopped working since my upgrade to iOS 10.3.

Motivation


Since iOS 8, I was used to install libimobiledevice with my package-manager (usually synaptic or "apt-get install libimobiledevice" from the Mint repository, to have access to my "iPhone 5s".
Until now, this was a very convenient way, to exchange photos and videos between my iPhone and a my Laptop with Linux Mint. Recently I updated my Linux installation to Linux Mint 18.2 "Sonya" and my iPhone to iOS 10.3.3. After that, I recognized that libimobiledevice didn't work reliable anymore.
First, I couldn't really find out, whether the newer version of Linux Mint or the newer version of iOS was in charge for the decline of service. After a while reading posts on the subject on the internet, I really suspect, that the main reason was the upgrade to iOS 10.2 and later 10.3. In iOS 10.2 I already, only sporadically, could connect my phone, but mostly just to see the "Documents" folder mounted, but not the "Photo" folder. Rarely the "Photo" folder appeared, too. If I was lucky and it was mounted, I wasn't asked whether I will trust the connection to the computer by my phone.
However, without the confirmation of this question (which didn't even appear) the "Photo" folder always was displayed as empty. Bummer!

Prerequisites


  • Linux Mint 18.2 Sonya
  • iPhone 5s with iOS 10.3.3

Solution: Compiling most of the sources yourself


On the internet, I found a manual, that promised to make the connection between an "iPhone" and Linux Mint work again [1]. This manual was written originally for users of Ubuntu in the first place. Still with Linux Mint, it did mostly work as described, but was kind of incomplete.

After you follow this description, the tools, to mount and unmount your phone, will be installed in the home account for the current user, just only one library usbmuxd must be installed as root in the system, otherwise mounting would not work.

Install necessary software for building the source packages


To check-out and compile the needed packages from source, you have to install some additional software first.

Therefore, open a bash-command-shell and install git to be able to check-out the source code repository to be compiled.

$> sudo apt-get install -y git

Then install the compiler suite via the meta-package build-essentials including gcc and such...

$> sudo apt-get install -y build-essential

In contrary to the original manual at [1], I had to install some additional build tools.

$> sudo apt-get install -y libtool m4 automake

I also needed the package libfuse-dev from the Mint repository, this seems maybe not to be necessary on Ubuntu.

$> sudo apt-get install -y libfuse-dev

Setup the shell environment to build the software


If you don't want to install the new commands directly into your system (which also would additionally need sudo for all "make install" commands, which is not recommended), you have to setup your shell environment.

As for this tutorial, all new commands to mount and unmount the file-system of your iPhone, will be installed in the sub-directory "${HOME}/usr/bin/".

Create the sub-directory to store the source files of the packages to be compiled:

$> mkdir -p "$HOME/usr/src"

Set all required environment variables to ensure to build the packages from source as desired:

$> export PKG_CONFIG_PATH="${HOME}/usr/lib/pkgconfig:${PKG_CONFIG_PATH}"
$> export CPATH="${HOME}/usr/include:${CPATH}"
$> export MANPATH="${HOME}/usr/share/man:${MANPATH}"
$> export PATH="${HOME}/usr/bin:${PATH}"
$> export LD_LIBRARY_PATH="${HOME}/usr/lib:${LD_LIBRARY_PATH}"

Make the path to your new tools permanent


It is recommended, to put the last two export statements into your .bashrc, to be loaded every time you open a new command shell, otherwise you must type

$> export PATH="${HOME}/usr/bin:${PATH}"
$> export LD_LIBRARY_PATH="${HOME}/usr/lib:${LD_LIBRARY_PATH}

in every newly opened command-shell to mount and unmount the file-system of your iPhone, because the first export is needed to find the new commands and the second is needed to load the correct run-time for the commands.

Clone all needed repositories from Github


$> cd ~/usr/src
$> for x in libplist libusbmuxd usbmuxd libimobiledevice ifuse; do git clone https://github.com/libimobiledevice/${x}.git;done

You should see something similar to the following output:

Cloning into 'libplist'...
remote: Counting objects: 3767, done.
remote: Total 3767 (delta 0), reused 0 (delta 0), pack-reused 3767
Receiving objects: 100% (3767/3767), 1.13 MiB | 727.00 KiB/s, done.
Resolving deltas: 100% (2304/2304), done.
Checking connectivity... done.
Cloning into 'libusbmuxd'...
remote: Counting objects: 382, done.
remote: Total 382 (delta 0), reused 0 (delta 0), pack-reused 382
Receiving objects: 100% (382/382), 123.94 KiB | 0 bytes/s, done.
Resolving deltas: 100% (209/209), done.
Checking connectivity... done.
Cloning into 'usbmuxd'...
remote: Counting objects: 1954, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 1954 (delta 0), reused 1 (delta 0), pack-reused 1949
Receiving objects: 100% (1954/1954), 604.44 KiB | 424.00 KiB/s, done.
Resolving deltas: 100% (1191/1191), done.
Checking connectivity... done.
Cloning into 'libimobiledevice'...
remote: Counting objects: 8095, done.
remote: Total 8095 (delta 0), reused 0 (delta 0), pack-reused 8095
Receiving objects: 100% (8095/8095), 2.47 MiB | 617.00 KiB/s, done.
Resolving deltas: 100% (5666/5666), done.
Checking connectivity... done.
Cloning into 'ifuse'...
remote: Counting objects: 499, done.
remote: Total 499 (delta 0), reused 0 (delta 0), pack-reused 499
Receiving objects: 100% (499/499), 92.37 KiB | 0 bytes/s, done.
Resolving deltas: 100% (242/242), done.
Checking connectivity... done.

Additionally to the original manual [1], I also had to compile libplist from source.

Build and install the packages in the following order


Build libplist


$> cd ~/usr/src/libplist
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Build libusbmuxd


$> cd ~/usr/src/libusbmuxd
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Build libimobiledevice


$> cd ~/usr/src/libimobiledevice
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Build usbmuxd


The package usbmuxd must be installed with administrative rights, because it needs write access to "/lib/udev/rules.d" and "/lib/systemd/system".

$> cd ~/usr/src/usbmuxd
$> ./autogen.sh --prefix="$HOME/usr"
$> make && sudo make install

Build ifuse


$> cd ~/usr/src/ifuse
$> ./autogen.sh --prefix="$HOME/usr"
$> make && make install

Test if everything works


It's assumed that you put the two exports into your ~/.bashrc as mentioned above.
Open a new bash command-shell.

Connect your iPhone


Create a mount point, where you want the content of your iPhone to appear.

$> mkdir -p ~/usr/mnt

Check which command executable will used, just in case you also have libimobiledevice additionally installed from the Mint repository, to avoid confusion.

$> type -p ifuse

/home/csch/usr/bin/ifuse

$> type -p idevicepair

/home/csch/usr/bin/idevicepair

Pair your iPhone with your computer


Now, grab your lightning-usb-cable and connect your iPhone to the computer.
Try to pair the iPhone with your computer.

$> idevicepair pair

ERROR: Could not validate with device 45ad6a77ae03f2d03f14a68fae178e45e70e7a04 because a passcode is set. Please enter the passcode on the device and retry.

Ooops, what's that? What happened? Again...

$> idevicepair pair

No, worry ... the ERROR just tell you that you forgot to confirm that you trust the connected computer on your phone, by entering your PIN on your phone and accept the trustworthy question.

cschmidt@pippin:~/usr/src/ifuse$ idevicepair pair
ERROR: Please accept the trust dialog on the screen of device 45ad6a77ae03f2d03f14a68fae178e45e70e7a04, then attempt to pair again.

After doing so, you finally can mount your iPhone (All good things come by in threes, therefore again)

$> idevicepair pair

SUCCESS: Paired with device 45ad6a77ae03f2d03f14a68fae178e45e70e7a04

Mount the file-system of your iPhone and check the content


Finally, mount the file-system of your phone.

$> ifuse ~/usr/mnt/
$> ls ~/usr/mnt/

AirFair com.apple.itunes.lock_sync iTunes_Control Photos Radio
Books DCIM MediaAnalysis PublicStaging Recordings
CloudAssets Downloads PhotoData Purchases Safari

Unmount and disconnect


To safely disconnect your iPhone, you have to unmount the file-system in ~/usr/mnt first with fusermount.

$> fusermount -u ~/usr/mnt

Now, you can plug-off your iPhone again.

References:

  1. gist: samrocketman/libimobiledevice_ifuse_Ubuntu.md
  2. Github repository https://github.com/libimobiledevice/
  3. type command reference


Sunday, December 4, 2016

Blogger: Host "SyntaxHighlighter" on GitHub-Pages

Objective


I would like to host my "SyntaxHighlighter" on Github-Pages to make it easy to format my source-code on my blog on Blogger. This is needed, because the original hosting service of Google-Drive is not working anymore..

Motivation


In a comment, a reader of my blog made me aware, that the syntax highlighting for source-code stopped working a while ago. So I investigated into the issue and found out that unfortunately Google stopped web-hosting of pages via Google-Drive.

Google deprecated web-hosting support in Google-Drive as of 31. August 2015 (Reference: https://gsuiteupdates.googleblog.com/2015/08/deprecating-web-hosting-support-in.html).
However, the web-hosting via Google-Drive stopped working only a year later as of 31. August 2016.

I did neither want to move on to Google Domains nor to the Google Cloud Platform,because both services are not free, so I decided to give Github-Pages a try.

Prerequisites



Setup your Hosting of SyntaxHighlighter on Github-Pages


Prepare your local repository


Follow the instructions in to get the sources for SyntaxHighlighter.

Create a directory for your new repository named e.g. syntaxhighlighter-pages/docs:
$> mkdir -p syntaxhighlighter-pages/docs
$> cd syntaxhighlighter-pages
$> git init

Initialized empty Git repository in /home/cschmidt/syntaxhighlighter-pages/.git/

Assuming your SyntaxHighlighter files are at the some location as your syntaxhighlighter-pages folder, copy all the source files your need to be hosted into your docs folder:

$> cd docs
$> cp -r ../../syntaxhighlighter_3.0.83/scripts .
$> cp -r ../../syntaxhighlighter_3.0.83/styles .
$> git add *
$> git commit -m "hosted syntaxhighlighter files"

[master (root-commit) 3556ca1] hosted syntaxhighlighter files
45 files changed, 5483 insertions(+)
create mode 100644 docs/scripts/shAutoloader.js
create mode 100644 docs/scripts/shBrushAS3.js
create mode 100644 docs/scripts/shBrushAppleScript.js
create mode 100644 docs/scripts/shBrushBash.js
...
create mode 100644 docs/styles/shThemeEmacs.css
create mode 100644 docs/styles/shThemeFadeToGrey.css
create mode 100755 docs/styles/shThemeMDUltra.css
create mode 100644 docs/styles/shThemeMidnight.css
create mode 100644 docs/styles/shThemeRDark.css

Finally push your local repository to your github:

$> cd ..
$> git remote add origin https://github.com/cwschmidt/syntaxhighlighter-pages.git
$> git push -u origin master

Counting objects: 50, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (50/50), 47.03 KiB | 0 bytes/s, done.
Total 50 (delta 24), reused 0 (delta 0)
remote: Resolving deltas: 100% (24/24), done.
To https://github.com/cwschmidt/syntaxhighlighter-pages_.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.


Prepare your github repository


Now log into your github account and create a new repository named "syntaxhighlighter-pages". Herefore click on the "+" on the upper-right corner of the Github webpage.



Fill in the name of the repository and make it "public" as shown below (didn't test, whether publiching pages also works with "private" ones):



Select the actual created repository and go to the settings tab shown below.
Scroll down until you reach the section "Github Pages". From the combo-box where "None" is selected right now, select "master branch /docs folder".



Click "Save" and after some seconds, your pages are successfully published:




Prepare your template to support code formatting


Go to your Blogger's blog online editor and choose "Template" from the menu at the left.




Click on "Edit HTML".

Within the code search for the closing head-tag

</b:template-skin>
    <b:include data='blog' name='google-analytics'/>
  </head>

  <body expr:class='&quot;loading&quot; + data:blog.mobileClass'>
  <b:section class='navbar' id='navbar' maxwidgets='1' name='Navbar' showaddelement='no'>

And copy the following code (only the links to the files you prepared for hosting) right before the end head-tag

<!-- Begin SyntaxHighlighter-->
    <link href='https://<username>.github.io/syntaxhighlighter-pages/styles/shCore.css' rel='stylesheet' type='text/css'/> 
    <link href='https://<username>.github.io/syntaxhighlighter-pages/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shCore.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCpp.js' type='text/javascript'/> 
    <!--script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCpp.js' type='text/javascript'/--> 
    <!--script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCSharp.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushCss.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/shBrushJava.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushJScript.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPhp.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPython.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushRuby.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushSql.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushVb.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushXml.js' type='text/javascript'/> 
    <script src='https://<username>.github.io/syntaxhighlighter-pages/scripts/shBrushPerl.js' type='text/javascript'/--> 
    <script type='text/javascript'>
    window.setTimeout(function() {
        SyntaxHighlighter.config.bloggerMode = true;
        SyntaxHighlighter.all();
    }, 20);
    </script>
<!-- End SyntaxHighlighter-->
</head>

Exchange the "<username>" within the URL with your own username on Github.


Test it


For Testing go back to my blog post Blogger: Setup "SyntaxHighlighter" for your blog - Test it

References:

  1. http://alexgorbatchev.com/SyntaxHighlighter/
  2. Github-Pages
  3. Blogger: Setup "SyntaxHighlighter" for your blog

Friday, August 12, 2016

MacOS X: Problem with accessing SMB-Shares on your Synology with "El Capitan"

Objective


I wanted to access my smb shares on my Synology from my MacBook Air that I recently updated to "El Capitan".

Motivation


As I my Synology DS209+II as my central data store where I never had problem so share files via the smb protocol with my MacBook Air as a client, I recently recognized that I can't establish a connection to the shares on my Synology after updating my MacBook Air to "El Capitan".


Prerequisites


  • DS209+II
  • MacBook Air (or any other Mac) with "El Capitan"

Solution


Explanation


Apparently Apple change it's security policy regarding smb-shares in "El Capitan". Those changes can lead to significant speed reduction with smb connection and even prevent you to mount a share at all. Ususally a login via the Finder menu "Go to server" is not successful whereas in the previous version of MacOS X "Mavericks" there where no problem and nothing has changed meanwhile on the server.

Solution


You can quickly fix the problem without downgrading to MacOS 10.11.4.

Open a Terminal an execute the following command:

sudo sh -c 'echo "[default]\nsigning_required=no" > /etc/nsmb.conf'

Now, restart your MacBook and you should be able to mount a shared drive from you Synology as ususal.

References:

  1. http://www.heise.de/mac-and-i/meldung/OS-X-10-11-5-Abhilfe-fuer-SMB-Probleme-3222725.html (German)

Sunday, April 17, 2016

Manage your local scripts via git on a shared directory of your NAS

Objective


I want to store all my scripts in a central place on my Synology NAS. I want to be able to easily add or alter any script on any computer within may local network. I want to be able to synchronize all my computer to have always the most recent version of any of my scripts installed. I don't want to use a public repository like GitHub or BitBucket for privacy reasons.

Motivation


At the moment, I use several computers to develop software. Those include a MacBookAir, a Linux workstation with several Virtual-Machines on it and a Laptop. On all those machines, virtual or physical I have a separate homeaccount with a bin folder where my scripts for daily work are located. I have a Synology NAS in my network where I backup all those scripts manually in a so called reference folder. I also synchronize my scripts manually, which is time consuming and kind a painful, because sometimes I even don't remember which of my local machines has the most recent version of a script stored at a certain point of time.

Prerequisites


  • Linux Mint 17.3 Rose
  • Synology DS209+II
  • git v1.9.1
  • nfs-shared directory on NAS

Solution


Create a new bare git repository


On my client machine (laptop with Linux Mint) I changed to the mounted directory (automount) from my NAS wher I want to create the bare git repository:

$> cd /mnt/DiskStation/data/home/cschmidt/

At the moment I have my reference directory containing all my scripts already in the bin folder there.

$> ls -la

drwxr-xr-x 3 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 3 cschmidt users 4096 Apr 16 22:54 ..
drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 bin

Now I create the bare git repository named bin.git

$> git init --bare bin.git

Initialized empty Git repository in /mnt/DiskStation/data/home/cschmidt/bin.git/

Create a non-bare git repository in the folder where the reference scripts are actually stored.


Now I change back to the folder where my scripts are currently stored

$> cd bin
$> ls -la

drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 4 cschmidt users 4096 Apr 17 2016 ..
-rwxrwxrwx 1 cschmidt users 82 Jul 20 2008 listfoldersize.sh
-rwxr-xr-x 1 cschmidt users 2193 Apr 16 18:20 mkscript.sh
-rwxr--r-- 1 cschmidt users 886 Sep 5 2015 renfiles.rb
-rwxrwxrwx 1 cschmidt users 671 Dez 3 2009 synapticsOnOff.sh
-rwxr--r-- 1 cschmidt users 1626 Jul 12 2015 wav2mp3.sh

Here I create a non-bare repository

$> git init

Initialized empty Git repository in /mnt/DiskStation/data/home/cschmidt/bin/.git/

Now I add all the scripts I already have, to the working copy and commit them all.

$> git add .
$> git status

On branch master

Initial commit

Changes to be committed:
(use "git rm --cached ..." to unstage)

new file: listfoldersize.sh
new file: mkscript.sh
new file: renfiles.rb
new file: synapticsOnOff.sh
new file: wav2mp3.sh

$> git commit -m "initial bunch of scripts"

[master (root-commit) 17879d2] initial bunch of scripts
5 files changed, 805 insertions(+)
create mode 100755 listfoldersize.sh
create mode 100755 mkscript.sh
create mode 100755 renfiles.rb
create mode 100755 synapticsOnOff.sh
create mode 100755 wav2mp3.sh

Push the commited scripts into the bare repository


So, now I tried to push the committed scripts into my bare host repository

$> git push

fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

git remote add

and then push using the remote name

git push

Ok, I admit ... I forgot to add the remote repository to push into, so do so now

$> git remote add origin /mnt/DiskStation/data/home/cschmidt/bin.git

and again

$> git push

oops ...


fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

Ok, I see I could name the repository every time I want to push something into or I'll add it as a upstream.
Let's do the latter ...

$> git push --set-upstream origin master

Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 32.23 KiB | 0 bytes/s, done.
Total 7 (delta 2), reused 0 (delta 0)
To /mnt/DiskStation/data/home/cschmidt/bin.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

Synchronize your script repository with your client


So, I want to have my recently commited scripts synchronized to my client

I go to my home account on my laptop and clone the remote repository into my bin.
(If you have already a bin folder in your home account, delete it first.)

$> cd ~
$> git clone /mnt/DiskStation/data/home/cschmidt/bin.git bin

Cloning into 'bin'...
done.

$> cd bin
$> ls -la

drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 4 cschmidt users 4096 Apr 17 2016 ..
-rwxrwxrwx 1 cschmidt users 82 Jul 20 2008 listfoldersize.sh
-rwxr-xr-x 1 cschmidt users 2193 Apr 16 18:20 mkscript.sh
-rwxr--r-- 1 cschmidt users 886 Sep 5 2015 renfiles.rb
-rwxrwxrwx 1 cschmidt users 671 Dez 3 2009 synapticsOnOff.sh
-rwxr--r-- 1 cschmidt users 1626 Jul 12 2015 wav2mp3.sh

Yeah, everything worked fine!

Friday, June 19, 2015

Blogger: Setup "SyntaxHighlighter" for your blog

Objective


Install "SyntaxHighlighter" on Google-Drive to make it easy to format your source-code on your blog on Blogger. This is needed, because the original hosting service of "SyntaxHighlighter" only supports "http" which Google does not like anymore for security reasons. Installing the needed files on Google-Drive will solve the problem and will serve the needed Javascript and CSS files via "https".

Motivation


This time I wanted to write a new blog article containing C++ code. I was not very keen of manually highlighting the code-snippets like I did in my first blog article about implementing a Java "synchronized" keyword in C++. Therefore I searched the web for a Syntax-Highlighter. I found many online solutions where you can copy&paste your code into a textarea to get html-code for your source-code that can be copied into your blogs source-text. Unfortunatelly this is not very practical nor flexible if you change or edit of your code while writing the blog article or even later. I needed a solution where you just copy&paste your raw-source-code into your blogs text. Ok, maybe you need to assign some specific style, but that's ok. In the end, I found "SyntaxHighlighter" a Javascript and CSS framework written by Alex Gorbatchev. I tried it in my Test-Blog and unfortunatelly noticed that the default hosting that Mr. Gorbatchev provided on his homepage is only "http" and not "https". Since a few weeks ago, links with only "http" do not work anymore with Blogger and Google-Chrome. Therefore I had to find an easy solution, to host the "SyntaxHighlighter" scripts myself via "https". I found out, that I very neat solution herefore is, to copy the needed files to your Google-Drive and make them publically accessible. This was the solution of my choice, because I already use the blogging service that Google provides.

Prerequisites



Solution


Get SyntaxHighlighter


Download SyntaxHighlighter from http://alexgorbatchev.com/SyntaxHighlighter/download/ and unzip it (in my case version 3.0.83):

$> unzip syntaxhighlighter_3.0.83.zip


Archive: syntaxhighlighter_3.0.83.zip
creating: syntaxhighlighter_3.0.83/
...
inflating: syntaxhighlighter_3.0.83/index.html
inflating: syntaxhighlighter_3.0.83/LGPL-LICENSE
inflating: syntaxhighlighter_3.0.83/MIT-LICENSE
creating: syntaxhighlighter_3.0.83/scripts/
inflating: syntaxhighlighter_3.0.83/scripts/shAutoloader.js
...
inflating: syntaxhighlighter_3.0.83/scripts/shBrushCpp.js
...
inflating: syntaxhighlighter_3.0.83/styles/shThemeRDark.css
creating: syntaxhighlighter_3.0.83/tests/
...

DEPRECATED SECTION : Setup your Hosting of SyntaxHighlighter on Google-Drive

The following section is deprecated. Due to the fact that Google deprecated web-hosting support in Google-Drive as of 31. August 2015 (Reference: https://gsuiteupdates.googleblog.com/2015/08/deprecating-web-hosting-support-in.html).
However, the web-hosting via Google-Drive stopped working only a year later as of 31. August 2016.

An alterative to host your javascript files is using github-pages.
So skip this section or jump directly to Blogger: Host "SyntaxHighlighter" on GitHub-Pages

Setup your Hosting of SyntaxHighlighter on Google-Drive


1. Create your folder

Log into your Google Drive account. Create a folder, by clicking "New" and then "Folder". Choose where you want to store your SyntaxHighlighter files. I named the root folder "Blog" and even created a subfolder named "SyntaxHighlighter" to create kind of a directory hierarchy in case I want also to host other packages in future.



Within the folder "SyntaxHighlighter" create 2 subfolders "scripts" and "styles".

2. Share your folder

Select the folder and then click the Share button.



Click on advanced and choose "change..."



then choose "On - Public on the web" in the next dialog



and click "Save".

3. Upload the necessary files from SyntaxHighlighter

Navigate back into your "Blog/SyntaxHighligter/scripts" folder and choose "File upload".



Now, navigate to the local folder where you unzipped the source of syntaxhighlighter_3.0.83.zip and go into the subfolder "scripts". Here you have to select at least "shCore.js" and minimum a "shBrushXX.js" file. The "shBrushXX.js" files specify which languages will be highlighted later on on your blog. I only have choosen "shBrushCpp.js" for the moment.

Navigate into "styles" folder and choose "File upload" again. Upload at least "shCore.css" and "shThemeDefault.css" from the "styles" folder of your local Hightlighter sources.

Prepare your template to support code formatting


Go to your Blogger's blog online editor and choose "Template" from the menu at the left.




Click on "Edit HTML".

Within the code search for the closing head-tag

</b:template-skin>
    <b:include data='blog' name='google-analytics'/>
  </head>

  <body expr:class='&quot;loading&quot; + data:blog.mobileClass'>
  <b:section class='navbar' id='navbar' maxwidgets='1' name='Navbar' showaddelement='no'>

And copy the following code (only the links to the files you prepared for hosting) right before the end head-tag

<!-- Begin SyntaxHighlighter-->
    <link href='https://googledrive.com/host/xxxxx/styles/shCore.css' rel='stylesheet' type='text/css'/> 
    <link href='https://googledrive.com/host/xxxxx/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shCore.js' type='text/javascript'/> 
 <script src='https://googledrive.com/host/xxxxx/scripts/shBrushCpp.js' type='text/javascript'/> 
    <!--script src='https://googledrive.com/host/xxxxx/scripts/shBrushCpp.js' type='text/javascript'/--> 
    <!--script src='https://googledrive.com/host/xxxxx/scripts/shBrushCSharp.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushCss.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushJava.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushJScript.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushPhp.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushPython.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushRuby.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushSql.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushVb.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushXml.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushPerl.js' type='text/javascript'/--> 
    <script type='text/javascript'>
    window.setTimeout(function() {
        SyntaxHighlighter.config.bloggerMode = true;
        SyntaxHighlighter.all();
    }, 20);
    </script>
<!-- End SyntaxHighlighter-->
</head>

The strange "xxxxx" is the placeholder for your very own share id. You can find your share-id, when you choose again the folder "SyntaxHighlighter" on your Google-Drive. Exchange all "xxxxx" in the code above by your share-id, e.g. "ZsTjl4Sjl0YmQ4SmNTh6WavThstZbGR0Mm1ydQAfm9oWlhkQlNRJSm9wQ3Z0Bxn0jvqYuNlU".



Test it


Let's put some source-code into a blog article to check if it shows up correctly. There are 2 possibilities how to do this:

Method 1:

<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
// 'Hello World!' program 
 
#include <iostream>
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
]]></script>

Result:



Method 2:

<pre class="brush: cpp">
// 'Hello World!' program 
 
#include &lt;iostream&gt;
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
</pre>

Result:

// 'Hello World!' program 
 
#include <iostream>
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
Great! It works! Have fun!

References:

  1. http://alexgorbatchev.com/SyntaxHighlighter/
  2. Embed Code Syntax Highlighting in Blog
  3. How to Host JavaScript or CSS Files on Google Drive