import { resolve } from 'path' ; import { ToolingLog } from '@kbn/dev-utils' ; import { exec , Config , Build } from '../../lib' ; export async function runFpm ( config , log , build , type , architecture , pkgSpecificFlags ) { const linux = config . getPlatform ( 'linux' , architecture ) ; const version = config . getBuildVersion ( ) ; const resolveWithTrailingSlash = ( ... paths ) => `${ resolve ( ... paths ) }/` ; const fromBuild = ( ... paths ) => build . resolvePathForPlatform ( linux , ... paths ) ; const pickLicense = ( ) => { return type === 'rpm' ? 'Elastic License' : 'Elastic-License' ; } ; const envFolder = type === 'rpm' ? 'sysconfig' : 'default' ; const args = [ '--force' , '-t' , type , '--package' , config . resolveFromTarget ( `NAME-${ version }-ARCH.TYPE` ) , '-s' , 'dir' , '--name' , 'kibana' , '--description' , 'Explore and visualize your Elasticsearch data' , '--version' , version , '--url' , 'https://www.elastic.co' , '--vendor' , 'Elasticsearch, Inc.' , '--maintainer' , 'Kibana Team <info@elastic.co>' , '--license' , pickLicense ( ) , '--after-install' , resolve ( __dirname , 'package_scripts/post_install.sh' ) , '--before-install' , resolve ( __dirname , 'package_scripts/pre_install.sh' ) , '--before-remove' , resolve ( __dirname , 'package_scripts/pre_remove.sh' ) , '--after-remove' , resolve ( __dirname , 'package_scripts/post_remove.sh' ) , '--rpm-posttrans' , resolve ( __dirname , 'package_scripts/post_trans.sh' ) , '--rpm-digest' , 'sha256' , '--config-files' , `/etc/kibana/kibana.yml` , '--template-value' , `user=kibana` , '--template-value' , `group=kibana` , '--template-value' , `configDir=/etc/kibana` , '--template-value' , `pluginsDir=/usr/share/kibana/plugins` , '--template-value' , `dataDir=/var/lib/kibana` , '--template-value' , `logDir=/var/log/kibana` , '--template-value' , `pidDir=/run/kibana` , '--template-value' , `envFile=/etc/default/kibana` , '--exclude' , `usr/share/kibana/config` , '--exclude' , `usr/share/kibana/data` , '--exclude' , `usr/share/kibana/logs` , '--exclude' , 'run/kibana/.gitempty' , ... pkgSpecificFlags , `${ resolveWithTrailingSlash ( fromBuild ( '.' ) ) }=/usr/share/kibana/` , `${ config . resolveFromRepo ( 'build/os_packages/config/kibana.yml' ) }=/etc/kibana/kibana.yml` , `${ resolveWithTrailingSlash ( fromBuild ( 'config' ) ) }=/etc/kibana/` , `${ resolveWithTrailingSlash ( fromBuild ( 'data' ) ) }=/var/lib/kibana/` , `${ resolveWithTrailingSlash ( fromBuild ( 'logs' ) ) }=/var/log/kibana/` , `${ resolveWithTrailingSlash ( __dirname , 'service_templates/systemd/' ) }=/` , `${ resolveWithTrailingSlash ( __dirname , 'service_templates/env/kibana' ) }=/etc/${ envFolder }/kibana` , ] ; log . debug ( 'calling fpm with args:' , args ) ; await exec ( log , 'fpm' , args , { cwd : config . resolveFromRepo ( '.' ) , level : 'info' , } ) ; }