Thursday, April 04, 2019

Building FFmpeg on Solaris 11.4 using solaris-userland

Well,as promised after my last entry about Building and Packaging FFmpeg on Solaris 11.4 I followed Chris Beal blog entry Building Opensource on Solaris 11.4 to create build information for FFmpeg using solaris-userland.

I thought converting the instructions to use with solaris-userland would be easy, but I was very wrong! The main problem was in the packaging parts complained when running make so worked need to be done to make sure no errors appeared
  1. Check Building Opensource on Solaris 11.4 for more details if required
  2. Packages requirements: developerstudio-126 developer/gcc/gcc-c-7 text/gnu-sed
  3. Swap http://pkg.oracle.com/solaris/release/ with a local repository if you wish
  4. Location of Solaris Studio /opt/developerstudio12.6
  5. 32-bit archive files are being created so need to make 64-bit archives (/usr/bin/ar Srv)
  6. pkglint does not like -rpath-link (BAD RUNPATH) so need to remove it
  7. WARNING userland.action001.3      32-bit runpath in 64-bit binary, '/scratch/solaris-userland/components/ffmpeg/build/prototype/i386/usr/lib/amd64/libswscale.so.5.3.100' includes 'libavresample'
    ERROR userland.action001.3        bad RUNPATH, 'usr/lib/amd64/libswscale.so.5.3.100' includes '-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample'
    gmake: *** [/scratch/solaris-userland/make-rules/ips.mk:500: /scratch/solaris-userland/components/ffmpeg/build/.linted-i386] Error 1
    
  8. remove an extra -Wl in configuration file

Download the solaris-userland if you have not already done so and do local changes (see Chris Beal's blog entry for full details):
$ echo $PATH
/usr/bin:/usr/sbin:/opt/developerstudio12.6/bin:/usr/gnu/bin
$ git clone https://github.com/oracle/solaris-userland.git
$ cd solaris-userland
$ gsed -i 's/^CANONICAL_REPO.*$/CANONICAL_REPO \?= http:\/\/pkg.oracle.com\/solaris\/release/' make-rules/ips-buildinfo.mk
$ gsed -i 's/^INTERNAL_ARCHIVE_MIRROR/#INTERNAL_ARCHIVE_MIRROR/; s/^SPRO_VROOT.*$/SPRO_VROOT \?= \$(SPRO_ROOT)\/developerstudio12.6/' make-rules/shared-macros.mk
$ gmake setup
Now create a directory for ffpmeg and create a Makefile
$ mkdir components/ffmpeg
$ cd components/ffmpeg
$ cat Makefile
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END

#
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
#
BUILD_BITS=64
COMPILER=gcc
include ../../make-rules/shared-macros.mk

COMPONENT_NAME=         ffmpeg
COMPONENT_VERSION=      4.1.3
COMPONENT_SRC=          $(COMPONENT_NAME)-$(COMPONENT_VERSION)
IPS_COMPONENT_VERSION=  $(COMPONENT_VERSION)
BUILD_VERSION=          1

COMPONENT_PROJECT_URL=  https://www.ffmpeg.org/
#COMPONENT_BUGDB=       video/ffmpeg
#COMPONENT_ANITYA_ID=    1865

COMPONENT_ARCHIVE=      ffmpeg-$(COMPONENT_VERSION).tar.bz2
COMPONENT_ARCHIVE_URL=  https://ffmpeg.org/releases/ffmpeg-$(COMPONENT_VERSION).tar.bz2
COMPONENT_ARCHIVE_HASH=
COMPONENT_MAKE_JOBS=    1

BUILD_STYLE=    configure

# configure does not accept many of the options set in
# configure.mk (CC=, CXX=, --bindir, --libdir, --sbindir).
# For example "--sbindir" gives an error
CONFIGURE_DEFAULT_DIRS= no

# Need to add all config options by hand
CONFIGURE_OPTIONS += --enable-shared
CONFIGURE_OPTIONS += --strip=gstrip 
CONFIGURE_OPTIONS += --disable-x86asm
CONFIGURE_OPTIONS += --prefix=/usr
CONFIGURE_OPTIONS += --mandir=/usr/share/man
CONFIGURE_OPTIONS += --bindir=/usr/bin
CONFIGURE_OPTIONS += --libdir=/usr/lib/amd64

# edit configure before running: replace sed with gsed
# edit pkgconfig_generate.sh to remove rpath-link
COMPONENT_PRE_CONFIGURE_ACTION = ( \
        $(GSED) -i 's?(sed ?(gsed ?g; s? sed ? gsed ?g' \
                $(SOURCE_DIR)/configure && \
        $(GSED) -i 's?,-rpath,\\$${libdir}? ?; s? $$rpath ? ?' \
                $(SOURCE_DIR)/ffbuild/pkgconfig_generate.sh \
)

# Change: "ARFLAGS=rc" => "ARFLAGS=Src"
# Change: "LDFLAGS=  -Wl,--as-needed -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample" => "LDFLAGS=  -Wl,--as-needed"

COMPONENT_POST_CONFIGURE_ACTION = ( \
        $(GSED) -i 's?ARFLAGS=rc?ARFLAGS=Src?; s?-Wl,-rpath-link=.*? ?' \
                $(BUILD_DIR)/$(MACH64)/ffbuild/config.mak \
)

TEST_TARGET= $(NO_TESTS)
include $(WS_MAKE_RULES)/common.mk

# remove warnings that packages are missing 
IPS_PKG_NAME=         video/ffmpeg
REQUIRED_PACKAGES +=  text/gnu-sed
REQUIRED_PACKAGES += compress/bzip2
REQUIRED_PACKAGES += compress/xz
REQUIRED_PACKAGES += library/zlib
REQUIRED_PACKAGES += system/library/math
REQUIRED_PACKAGES += system/library
REQUIRED_PACKAGES += x11/library/libx11
REQUIRED_PACKAGES += x11/library/libxcb
REQUIRED_PACKAGES += x11/library/libxext
REQUIRED_PACKAGES += x11/library/libxv

$ gmake install
Now we need to create a sample-manifest which I will use as a starting point, but you will need to edit it to get it to work. I have included the differences. Full version is here
$ gmake sample-manifest
$ diff -u ./build/manifest-i386-generated.p5m ffmpeg.p5m
--- ./build/manifest-i386-generated.p5m 2019-04-04 16:31:23.351201366 +0100
+++ ffmpeg.p5m 2019-04-03 14:22:25.396211456 +0100
@@ -23,21 +23,25 @@  
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.  
#  
   
+<transform dir path=bin .* -> drop>  
+<transform dir path=usr .* -> drop>  
+<transform dir path=usr/bin .* -> drop>  
+<transform dir path=usr/include .* -> drop>  
+<transform dir path=usr/lib .* -> drop>  
+<transform dir path=usr/lib/amd64/pkgconfig .* -> drop>  
+<transform dir path=usr/share .* -> drop>  
+<transform dir path=usr/share/doc .* -> drop>  
 set name=pkg.fmri \  
-  value=pkg:/$(IPS_PKG_NAME)@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)  
-set name=pkg.summary value="XXX Summary XXX"  
-set name=com.oracle.info.description value="XXX Description XXX"  
-set name=com.oracle.info.tpno value=$(TPNO)  
+  value=pkg:/video/ffmpeg@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)  
+set name=pkg.summary value=ffmpeg  
+set name=com.oracle.info.description \  
+  value="A very fast video and audio converter"  
 set name=info.classification \  
-  value="org.opensolaris.category.2008:XXX Classification XXX"  
+  value="org.opensolaris.category.2008:System/Multimedia Libraries"  
 set name=info.source-url value=$(COMPONENT_ARCHIVE_URL)  
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)  
 set name=org.opensolaris.arc-caseid value=PSARC/YYYY/XXX  
 set name=org.opensolaris.consolidation value=$(CONSOLIDATION)  
-  
-license $(COPYRIGHT_FILE) license='$(COPYRIGHTS)'  
-  
-dir path=mangled  
 file path=usr/bin/ffmpeg  
 file path=usr/bin/ffprobe  
 dir path=usr/include/libavcodec  
@@ -256,3 +260,14 @@  
 file path=usr/share/ffmpeg/libvpx-360p.ffpreset  
 file path=usr/share/ffmpeg/libvpx-720p.ffpreset  
 file path=usr/share/ffmpeg/libvpx-720p50_60.ffpreset  
+license LICENSE.md license=LICENSE.md  
+depend type=require fmri=pkg:/compress/bzip2@1.0.6-11.4.0.0.1.14.0  
+depend type=require fmri=pkg:/compress/xz@5.2.3-11.4.0.0.1.14.0  
+depend type=require fmri=pkg:/library/zlib@1.2.11-11.4.0.0.1.14.0  
+depend type=require fmri=pkg:/system/library/math@11.4-11.4.0.0.1.4.0  
+depend type=require fmri=pkg:/system/library@11.4-11.4.7.0.1.4.0  
+depend type=require fmri=pkg:/x11/library/libx11@1.6.5-11.4.3.0.1.1.0  
+depend type=require fmri=pkg:/x11/library/libxcb@1.12-11.4.0.0.1.14.0  
+depend type=require fmri=pkg:/x11/library/libxext@1.3.3-11.4.0.0.1.14.0  
+depend type=require fmri=pkg:/x11/library/libxv@1.0.11-11.4.0.0.1.14.0  

$ rm ./build/manifest-i386-generated.p5m
$ gmake publish
...
/usr/bin/pkgsend -s file:/scratch/solaris-userland/i386/repo publish --fmri-in-manifest --no-catalog -d /scratch/solaris-userland/components/ffmpeg/build/prototype/i386/mangled -d /scratch/solaris-userland/components/ffmpeg/build/prototype/i386 -d /scratch/solaris-userland/components/ffmpeg/build -d /scratch/solaris-userland/components/ffmpeg -d ffmpeg-4.1.3 -d /scratch/solaris-userland/licenses -T \*.py /scratch/solaris-userland/components/ffmpeg/build/manifest-i386-ffmpeg.depend.res
pkg://nightly/video/ffmpeg@4.1.3,1:20190404T153252Z
PUBLISHED
/usr/bin/pkgfmt /scratch/solaris-userland/components/ffmpeg/build/manifest-i386-ffmpeg.published
/usr/bin/pkgrepo refresh -s file:/scratch/solaris-userland/i386/repo
Initiating repository refresh.
/usr/bin/touch /scratch/solaris-userland/components/ffmpeg/build/.published-i386
Now lets see if the pkg has been built:
$ pkg info -r -g file:/scratch/solaris-userland/i386/repo ffmpeg
          Name: video/ffmpeg
       Summary: ffmpeg
      Category: System/Multimedia Libraries
         State: Not installed
     Publisher: nightly
       Version: 4.1.3
        Branch: None
Packaging Date: April  4, 2019 at  3:32:52 PM
          Size: 258.58 MB
          FMRI: pkg://nightly/video/ffmpeg@4.1.3:20190404T153252Z
   Project URL: https://www.ffmpeg.org/
    Source URL: https://ffmpeg.org/releases/ffmpeg-4.1.3.tar.bz2

$ pkg list -afv -g file:/scratch/solaris-userland/i386/repo
FMRI                                                                         IFO
pkg://nightly/runtime/tcl-8@8.6.7-11.5.0.0.0.43.0:20190403T154835Z           ---
pkg://nightly/video/ffmpeg@4.1.3:20190404T153252Z                            ---
pkg://nightly/video/ffmpeg@4.1.3:20190404T150101Z                            ---
pkg://nightly/video/ffmpeg@4.1.3:20190403T154327Z                            ---
pkg://nightly/video/ffmpeg@4.1:20190403T134001Z                              ---
pkg://nightly/video/ffmpeg@4.1:20190403T133003Z                              ---

$ pkg install -n -v -g file:/scratch/solaris-userland/i386/repo ffmpeg@4.1.3
           Packages to install:         1
     Estimated space available: 237.87 GB
Estimated space to be consumed: 739.22 MB
       Create boot environment:        No
Create backup boot environment:        No
          Rebuild boot archive:        No

Changed packages:
nightly
  video/ffmpeg
    None -> 4.1.3

$ pkg install  -g file:/scratch/solaris-userland/i386/repo ffmpeg@4.1.3
           Packages to install:  1
       Create boot environment: No
Create backup boot environment: No

DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                                1/1       194/194    68.0/68.0      --

PHASE                                          ITEMS
Installing new actions                       230/230
Updating package state database                 Done 
Updating package cache                           0/0 
Updating image state                            Done 
Creating fast lookup database                   Done 
Reading search index                            Done 
Updating search index                            1/1 
Updating package cache                           5/5 

$ which ffmpeg
/usr/bin/ffmpeg
$ ffmpeg -version
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --enable-shared --strip=gstrip --disable-x86asm --prefix=/usr --mandir=/usr/share/man --bindir=/usr/bin --libdir=/usr/lib/amd64 --prefix=/usr
libavutil      56. 22.100 / 56. 22.100
libavcodec     58. 35.100 / 58. 35.100
libavformat    58. 20.100 / 58. 20.100
libavdevice    58.  5.100 / 58.  5.100
libavfilter     7. 40.101 /  7. 40.101
libswscale      5.  3.100 /  5.  3.100
libswresample   3.  3.100 /  3.  3.100

No comments: