Compiling "file" with spksrc for synology NAS


Read the disclaimer

This article describes how to compile "file" for synology devices, package it and install it.

You can get "file" sources at:
  • https://github.com/file/file
  • ftp://ftp.astron.com/pub/file/
The package described in this guide is will download the content from that repository.

The "file" command is "a file type guesser", that is, a command-line tool that tells you in words what kind of data a file contains.

The original spksrc already contains a file package, that only compiles the binaries :
https://github.com/SynoCommunity/spksrc/tree/master/cross/file
This package fills the gap and provides the command line utilities from the shell:
  • file
This guide is the same that
https://dayandnightcoding.blogspot.com/2020/04/compiling-cpulimit-with-spksrc-for.html
You can follow the different steps there.
I'll document only the steps referring specifically to "file".

Clone the repository and make setup

  • on the ubuntu host
  • start a terminal
  • choose a folder for the git clone root
  • git clone https://github.com/youpla/spksrc.git
  • cd spksrc/
  • make setup

Compile the "file" package for your architecture

in a terminal navigate to the file folder

example:
/home/userprofile/test-git/spksrc/spk/file

make arch-armada375

At the time writing this article I have a Ubuntu 18 with file 5.32.
The spksrc package is file 5.35
The cross compilation fails with this message:
Cannot use the installed version of file (5.32) to
cross-compile file 5.35
Please install file 5.35 locally first

From a console type : file --version
If the version displayed is not the one in the spksrc package, you can apply one of the following workaround.

Workaround 1

Install file 5.35 to your ubuntu system
  1. Uninstall the current package from the console : sudo apt remove file
  2. Download the sources : ftp://ftp.astron.com/pub/file/file-5.35.tar.gz
  3. Download and check the signature : ftp://ftp.astron.com/pub/file/file-5.35.tar.gz.asc
    (see below)
  4. Unpack the file-5.35.tar.gz archive
  5. Navigate to the unpack directory from the console
  6. Follow the installation documentation at : https://github.com/file/file
    1. run the configure script : ./configure
    2. run make : make
    3. run make install as sudo : sudo make install
  7. On ubuntu 18: I also had to correct the libraries.
    1. From a console navigate to : /usr/lib/x86_64-linux-gnu
    2. backup the existing libraries : 
      1. sudo mv libmagic.so* /root/
      2. sudo mv libmagic.la /root/
    3. copy the new ones : 
      1. sudo cp /usr/local/lib/libmagic.la .
      2. sudo cp /usr/local/lib/libmagic.so.1.0.0 .
      3. make the symbolic links : sudo ln -s libmagic.so.1.0.0 libmagic.so
      4. make the symbolic links : sudo ln -s libmagic.so.1.0.0 libmagic.so.1
You can now cross compile the package for your synology.
  1. From the console go back to: /home/userprofile/test-git/spksrc/spk/file
  2. Clean up the last build : make clean
  3. Build again : make arch-armada375

Workaround 2

You can alter the spksrc source you downloaded in order to compile the same version that is already installed on your computer.

  1. edit : /home/userprofile/test-git/spksrc/cross/file/Makefile
    1. change : PKG_VERS = 5.35 to the version on your computer
  2. edit : /home/userprofile/test-git/spksrc/cross/file/digests
    1. you can empty the file. Important : please read "check the checksum" section in this article.
  3. edit : /home/userprofile/test-git/spksrc/spk/file/Makefile
    1. SPK_VERS = 5.35 to the version on your computer

You can now cross compile the package for your synology.
  1. From the console go back to: /home/userprofile/test-git/spksrc/spk/file
  2. Clean up the last build : make clean
  3. Build again : make arch-armada375

Check the checksum

  • If you already run the cross compilation, the archive is in : /home/userprofile/test-git/spksrc/distrib/file-5.35.tar.gz
  • If you did not alter the source file, the checksum has already been performed by the cross compilation script.
  • If you emptied : /home/userprofile/test-git/spksrc/cross/file/digests
  • Then the script did NOT perform a checksum. You have no warranty that the file has not been altered during the transfer.
  • If you downloaded the archive yourself or altered the script you can check the signature following the documentation:
    • https://github.com/file/file
      • gpg --verify file-5.32.tar.gz.asc file-5.32.tar.gz
      • you'll get :
        • gpg: Signature made Sa 02 Sep 2017 11:08:32 CESTgpg:               
          using DSA key 71112AB16CB33B3A
      • gpg --keyserver hkp://keys.gnupg.net --recv-keys 71112AB16CB33B3A
  • You have now checked the file signature.

Install the package

Go to the file explorer and find the generated file.

example
/home/userprofile/test-git/spksrc/packages/file_armada375-6.1_5.35-1.spk

Testing

See :
https://dayandnightcoding.blogspot.com/2020/04/testing-package-compiled-with-spksrc.html

The package "file" has been tested for install and uninstall on my DS-115 with no noticed problem.


Comments

Popular posts from this blog

cuesplitflac : a mass flac splitting script for synology and ubuntu

Compiling cpulimit with spksrc for synology NAS