Synology DSM 3rd Party Apps Developer Guide

advertisement
SynologyDSM6.0DeveloperGuide
TableofContents
PackageDeveloperGuide
0
GettingStarted
1
SystemRequirements
CreatePackage
Preparation
1.1
2
2.1
InstallToolkit
2.1.1
PrepareBuildEnvironment
2.1.2
PrepareGPGKey
2.1.3
HelloWorldPackage
2.2
BuildStage
2.2.1
PackStage
2.2.2
SignPackage
2.2.3
EssentialRunTimeFiles
2.2.4
Summary
2.2.5
CompileOpenSourceProject:tmux
2.3
CompileOpenSourceProject:nmap
2.4
CompileKernelModules
2.5
Advanced
2.6
SynologyPackage
3
PackageStructure
3.1
INFO
3.2
NecessaryFields
3.2.1
OptionalFields
3.2.2
package.tgz
3.3
scripts
3.4
ScriptEnvironmentVariables
3.4.1
conf
3.5
WIZARD_UIFILES
3.6
IntegrateYourPackageintoDSM
4
ManageStorageforApplicationFiles
4.1
IntegrateYourPackageintoDSMWebGUI
4.2
Startup
4.2.1
Config
4.2.2
IntegrateHelpDocumentintoDSMHelp
4.2.3
IntegratewithDSMWebAuthentication
4.2.4
DSMBackwardCompatibility
4.3
ShowMessagestoUsers
4.4
CreatePHPApplication
4.5
RunScriptsWhentheSystemBoots
4.6
2
SynologyDSM6.0DeveloperGuide
LocaleSupport
4.7
InstallPackageRelatedPortsInformationintoDSM
4.8
LowerPrivilege
4.9
PackageUser&Group
4.9.1
Mechanism
4.9.2
PrivilegeSpecification
4.9.3
Categories
ResourceAcquisition
4.9.3.1
4.10
ResourceSpecification
4.10.1
Timing
4.10.2
ConfigUpdate
4.10.3
AvailableWorkers
4.10.4
/usr/locallinker
4.10.4.1
Apache2.2Config
4.10.4.2
DataShare
4.10.4.3
IndexDB
4.10.4.4
MariaDB
4.10.4.5
PHPINI
4.10.4.6
PortConfig
4.10.4.7
SyslogConfig
4.10.4.8
PublishSynologyPackages
5
GetStartedwithPublishing
5.1
SubmittingthePackageforApproval
5.2
RespondingtoUserIssues
5.3
AppendixA:PlatformandArchValueMappingTable
RevisionHistory
AppendixB:CompileApplicationsManually
6
6.1
7
DownloadDSMToolChain
7.1
Compile
7.2
CompileOpenSourceProjects
7.3
CompileKernelModules
7.4
3
SynologyDSM6.0DeveloperGuide
SynologyDSM6.0DeveloperGuide
THISDOCUMENTCONTAINSPROPRIETARYTECHNICALINFORMATIONWHICHISTHEPROPERTYOFSYNOLOGY
INCORPORATEDANDSHALLNOTBEREPRODUCED,COPIED,ORUSEDASTHEBASISFORDESIGN,
MANUFACTURING,ORSALEOFAPPARATUSWITHOUTWRITTENPERMISSIONOFSYNOLOGYINCORPORATED
Copyright
SynologyInc.®2016SynologyInc.Allrightsreserved.
Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmitted,inanyformorbyanymeans,mechanical,
electronic,photocopying,recording,orotherwise,withoutpriorwrittenpermissionofSynologyInc.,withthefollowingexceptions:
Anypersonisherebyauthorizedtostoredocumentationonasinglecomputerforpersonaluseonlyandtoprintcopiesofdocumentation
forpersonaluseprovidedthatthedocumentationcontainsSynology’scopyrightnotice.
TheSynologylogoisatrademarkofSynologyInc.
Nolicenses,expressorimplied,aregrantedwithrespecttoanyofthetechnologydescribedinthisdocument.Synologyretainsall
intellectualpropertyrightsassociatedwiththetechnologydescribedinthisdocument.Thisdocumentisintendedtoassistapplication
developerstodevelopapplicationsonlyforSynology-labeledcomputers.
Everyefforthasbeenmadetoensurethattheinformationinthisdocumentisaccurate.Synologyisnotresponsiblefortypographical
errors.
SynologyInc.3F-3,No.106,Chang-AnW.Rd.Taipei103,Taiwan
SynologyandtheSynologylogoaretrademarksofSynologyInc.,registeredintheUnitedStatesandothercountries.
MarvellisregisteredtrademarksofMarvellSemiconductor,Inc.oritssubsidiariesintheUnitedStatesandothercountries.
FreescaleisregisteredtrademarksofFreescale.IntelandAtomisregisteredtrademarksofIntel.
Semiconductor,Inc.oritssubsidiariesintheUnitedStatesandothercountries.
Otherproductsandcompanynamesmentionedhereinaretrademarksoftheirrespectiveholders.
EventhoughSynologyhasreviewedthisdocument,SYNOLOGYMAKESNOWARRANTYORREPRESENTATION,EITHER
EXPRESSORIMPLIED,WITHRESPECTTOTHISDOCUMENT,ITSQUALITY,ACCURACY,MERCHANTABILITY,OR
FITNESSFORAPARTICULARPURPOSE.ASARESULT,THISDOCUMENTISPROVIDED“ASIS,”ANDYOU,THE
READER,AREASSUMINGTHEENTIRERISKASTOITSQUALITYANDACCURACY.INNOEVENTWILLSYNOLOGY
BELIABLEFORDIRECT,INDIRECT,SPECIAL,INCIDENTAL,ORCONSEQUENTIALDAMAGESRESULTINGFROMANY
DEFECTORINACCURACYINTHISDOCUMENT,evenifadvisedofthepossibilityofsuchdamages.
THEWARRANTYANDREMEDIESSETFORTHABOVEAREEXCLUSIVEANDINLIEUOFALLOTHERS,ORALOR
WRITTEN,EXPRESSORIMPLIED.NoSynologydealer,agent,oremployeeisauthorizedtomakeanymodification,extension,or
additiontothiswarranty.
Somestatesdonotallowtheexclusionorlimitationofimpliedwarrantiesorliabilityforincidentalorconsequentialdamages,sothe
abovelimitationorexclusionmaynotapplytoyou.Thiswarrantygivesyouspecificlegalrights,andyoumayalsohaveotherrights
whichvaryfromstatetostate.
PackageDeveloperGuide
4
SynologyDSM6.0DeveloperGuide
GettingStarted
Synologyoffersthisdeveloperguidewithinstructionsonhowtodevelopandinstall3rd-partyapplicationsonSynologyNASproducts
oralineofnetworkattachedstoragedevicesdevelopedontheLinuxkernel.Withthisguide,youcanfamiliarizeyourselfwiththe
followingprocedures:
CompileprogramstorunonaSynologyNAS.
IntegrateapplicationswithSynologyDiskStationManager(DSM).
InstallapplicationfilestotherecommendedpathtokeepthemintactwhenDSMisupgraded.
IntegrateapplicationswiththeSynologywebauthenticationinterface.
Createapackagefileformanualorone-clickinstallationinSynologyPackageCenter.
ThisdocumentiswrittenforSynologyusersandsystemintegratorswhoareinterestedinaddingtheirapplicationstotheirSynology
NAS.ThosewhoreadthisdocumentareassumedtohavesomebasicunderstandingofLinuxprogramming.
GettingStarted
5
SynologyDSM6.0DeveloperGuide
SystemRequirements
InordertocompileprogramstorunontheSynologyNAS,thesystemmustmeetthefollowingrequirements.
64bitlinuxenvironment.
bash(>=4.1.5)
Python(>=2.7.3)
Requirerootpermission.(Ourtoolkitwilluse chrootcommand)
DSM6.0orlaterisrequiredonSynologyNAS.
SystemRequirements
6
SynologyDSM6.0DeveloperGuide
CreatePackage
Inthissection,wewillexplainhowtocreateaSynologyPackageusingPackageToolkit.
IfyouwanttobuildaSynologyPackagewithoutusingPackageToolkit,youmust:
Prepareacrosscompiletoolchain
Prepareabuildenvironment
Preparemetadata
Compilesourcecode
Createandsignthepackage
Creatingapackagemanuallycanbeverycomplexformostdevelopers,sowerecommendedusingthePackageToolkittomakethe
packagecreationprocesseasier.Tomakethepackagecreationprocessgosmoothly,youwillstillneedtowritesomescriptsdescribing
howyouwanttobuildandcreateyourpackages.
Inthefollowingsub-sections,thenecessaryscriptswillbestatedindetail.
Youcandownloadtheexamplesourcefromgithub:SynologyOpenSource
CreatePackage
7
SynologyDSM6.0DeveloperGuide
Preparation:
Inthissection,wewillguideyouthroughhowtosetupanenvironmentforbuildingaSynologyPackage.Detailedstepsinclude:
InstallToolkit
PrepareBuildEnvironment
PrepareGPGKey
Preparation
8
SynologyDSM6.0DeveloperGuide
InstallToolkit
Thistutorialconsistsoftwoparts:
Pre-builtenvironment
Front-endscripts
Requirements:
TomakethePackageToolkitworkproperly,youwillneedtomakesurethedevelopmentsystemmeetsthefollowingrequirements:
64bitlinuxenvironment.
Bash(>=4.1.5)
Python(>=2.7.3)
ToolkitInstallation:
Toinstallthetookit,simplyrefertothefollowingsteps.First,youneedtoclonethefront-endscriptsfromheretoyourtoolkitbase(we
willuse/toolkitastoolkitbaseinthisdocumentfromnowon).
mkdir-p/toolkit
gitclone{{book.externalLinks.pkgscripts}}.git
Pre-buildEnvironment:
Forfasterdevelopment,wehavepreparedseveralbuildenvironmentsthatdependondifferentarchitecturesforpackagedevelopers.
Youdon'thavetoworryaboutthenecessarybuilt-timelibraries(.aand.so)andheaderfiles(.hand.hpp)whenyouaredevelopingyour
package.Thisisbecausethebuildenvironmentsalreadycontainsomepre-builtprojectswhoseexecutablebinariesorsharedlibraries
arebuiltonDSM,forexample,zlib,libxml2,andsoon.
Frond-endScripts:
Wehavealsoprovidedfront-endscriptsinafoldernamed“pkgscripts”tomaketheenvironmentdeployment,packagecompilation,
andcreationofthefinalpackageSPKfileeasier.Inmostcases,youonlyneedtousethesethreescriptswhiledevelopingapackage:
EnvDeploy
PkgCreate.py
include/pkg_utils.sh
ThenextsectionwillguideyouthroughhowtoestablishabuildenvironmentandcreateaSynologyPackagebyusingPackageToolkit.
InstallToolkit
9
SynologyDSM6.0DeveloperGuide
PrepareBuildEnvironment
Youcandownloadandsetuppre-builtenvironmentsbyusingEnvDeploywiththefollowingcommands.Use -vtospecifyDSM
version, -ptospecifydesiredplatform,and -ttospecifythefilelocationwhenyoustoredthetoolkitlocallyonyourdevelopment
machine.If -pisnotgiven,allavailableplatformsforgivenversionswillbesetup.
cd/toolkit/pkgscripts-ng/
./EnvDeploy-v6.0-px64#forexample
Theworkingdirectorywilllooklikethefollowingfigure.Thechrootenvironmenttobuildyourownprojectswillbeds.${platform}${version}.Asmentionedbefore,thistoolkitcontainssomepre-builtlibrariesandheaderswhichcanbefoundundercrossgccsysroot.
Sysrootisdefaultsearchpathofcompiler.Ifgcccannotfindheaderorlibraryfrompathusergiven,gccwillsearch
sysroot/usr/{lib,include}.
AvailablePlatforms
Youcanuseoneofthefollowingcommandstoshowavailableplatforms.If -visnotgiven,availableplatformsforallversionswill
belisted.
./EnvDeploy-v6.0--list
./EnvDeploy-v6.0--infoplatform
UpdateEnvironment
UseEnvDeployagaintoupdateyourenvironments.Forexample,youcanupdatex64forDSM6.0byusingthefollowingcommand.
./EnvDeploy-v6.0-px64
RemoveEnvironment
Toremoveabuildenvironment,youneedtoapplychroottothebuildenvironment.Unmountthe/procfolderandexitchroot.After
that,removethebuildenvironmentfolder.Thefollowingcommandsillustratehowtoremoveabuildenvironmentwithversion6.0and
platformx64.
chroot/toolkit/build_env/ds.x64-6.0umount/proc
rm-rf/toolkit/build_env/ds.x64-6.0
PrepareBuildEnvironment
10
SynologyDSM6.0DeveloperGuide
PrepareGPGKey
Ifthebuildenvironmentis5.0orabove,thePackageToolkitwilluseagpgkeytosignthepackagewhencreatingthespkfile.
PleaserefertoPackageSignatureformoredetailsaboutpackagesignatures.
IfyouhaveyourownGPGkey(withoutapassphrase)already,youwillneedtoputtheprivatekeyin/root/.gnupgundereach
platform(/toolkit/build_env/ds.${platform}-6.0/root/.gnupg/).
GeneratetheGPGkey
Requirement:gpg,gpg-agent
gpg--gen-key
>Pleaseselectwhatkindofkeyyouwant:
(1)RSAandRSA(default)
>choosekeysizeandenteryourname,email
>enterapassphrase:justpressEnterwithouttypinganycharacter
WARNING:Pleasemakesurethatyoudonottypeanycharactersinthepassphrasefield,otherwisethebuildprocesswill
FAIL.
Aftercompletingthestepsabove,thekeywillbegeneratedunder~/.gnupg.Movethemwiththechrootenvironment.
cp~/.gnupg/*/toolkit/build_env/ds.${platform}-6.0/root/.gnupg/
Youcanalsousethefollowingcommandstoverifywhetherthekeywassuccessfullyimportedornot.
cd/toolkit/build_env/ds.${platform}-6.0/
chroot.
gpg-K
Theoutputmayproducethefollowingmessage.
/root/.gnupg/secring.gpg
-----------------------sec2048R/145E0AFD2015-12-21
uidSynologyInc.<synology_inc@synology.com>
ssb2048R/E0C20F112015-12-21
PrepareGPGKey
11
SynologyDSM6.0DeveloperGuide
HelloWorldPackage
Weusethefront-endscriptPkgCreate.pytohelpuscompilesourcecodeandpackaSynologyPackageoraSPKfile.
SPKisthefileformatusedbySynologyPackageCentertoproperlyinstallyourapplication.Formoredetailsaboutthestructural
formatofanSPKfile,youmayrefertoSynologyPackage.
Inthefollowingsections,wewillguideyouonhowtocreateasimpleutilityprogramthatcanprintoutsystemmemory,andpackit
intoanSPKfilebyusingPkgCreate.py.
Formorecomplicatedcases,youcanrefertothefollowingexamplesprovided:
CompileOpenSourceProject:tmux:IfyouareinterestedinportinganopensourceprojecttoDSMsystemusingtmuxorsetting
upanyadvancedconfigurations,youmayrefertothissection.
CompileOpenSourceProject:nmap:IfyouareinterestedinportinganopensourceprojecttoDSMsystemusingnmaporsetting
upanyadvancedconfigurations,youmayrefertothissection.
CompileKernelModule:IfyouareinterestedininstallingmorekernelmodulestoyourDSMsystem,youmayrefertothis
section.
CreatePackageWorkflow:
TherearetwostagesinthePkgCreate.pypackagecreationprocess,theBuildStageandthePackStage.
IntheBuildStage,PkgCreate.pywillcompileyourprojectandalldependentprojectsinthecorrectorder.InthePackStage,
PkgCreate.pywillpackyourprojectintoanSPKfile.
TocreateyourSPKfilewithPkgCreate.pyproperly,youwillneedtoprovideadditionalconfigurationfilesandbuildscriptstodescribe
howtobuildyourproject.Thesefilesareputinafoldernamed“SynoBuildConf”underyourproject.Thesefilesandtheirpurposeare
listedinbelow.
SynoBuildConf/depends:definesthedependencyofyourproject.Forfurtherdetails,pleaserefertoBuildStage
SynoBuildConf/build:specifiesPkgCreate.pyonhowtocompileyourproject.Forfurtherdetails,pleaserefertoBuildStage
SynoBuildConf/install:specifiesPkgCreate.pyonhowtopackyourSPKfile.Forfurtherdetails,pleaserefertoPackStage
SynoBuildConf/install-dev:similartoSynoBuildConf/install,butthiswillpackyourSPKfileinchrootenvironmentratherthan
generalDSMsystem.Forfurtherdetails,pleaserefertoCompileOpenSourceProject:nmap.
Formoredetailsabouttheseconfigurationfiles,pleaserefertoBuildStageandPackStage.Thefollowingfigureshowstheworkflow
ofthesetwostages.
HelloWorldPackage
12
SynologyDSM6.0DeveloperGuide
YoucanusethefollowingcommandstotellPkgCreate.pyhowtorunthroughbothstages.
cd/toolkit
pkgscripts/PkgCreate.py-x0-c${project}
The -coptiontellsPkgCreate.pytobuild,pack,andsignyourproject.The -x0optionismeanttotraverseandbuildalldependent
projectsinthecorrectorder.EachprojectisbuiltaccordingtotheirownSynoBuildConf/build.
Note:PkgCreate.pycompilessourcecodeandpacksyourpackageunderchrootenvironment.Therefore,youmustrunall
commandswithrootpermissionorwithsudo.
PkgCreate.pyhasmanyotheroptionstocontrolthebuildflow.Thefollowingsubsectionswillexploredeeperintothoseoptionsoryou
maydirectlyrefertotheAdvancedsectionformoredetails.
SourceCodeLayout:
InBuildStage,PkgCreate.pywilltrytolinkalltheprojectstothebuildenvironment.Asaresult,yourprojectsourcecodemustbeput
inafolder(wecallita“project”)under/toolkit/source.Thefollowingfigureshowsthewholeworkingdirectoryasanexample.
HelloWorldPackage
13
SynologyDSM6.0DeveloperGuide
toolkit/
├──build_env/
│└──ds.${platform}-${version}/
│└──/usr/syno/
│├──bin
│├──include
│└──lib
├──pkgscripts/
└──source/
└──minimalPkg/
├──minimalPkg.c
├──INFO.sh
├──Makefile
├──PACKAGE_ICON.PNG
├──PACKAGE_ICON_256.PNG
├──scripts/
│├──postinst
│├──postuninst
│├──postupgrade
│├──preinst
│├──preuninst
│├──preupgrade
│└──start-stop-status
└──SynoBuildConf/
├──build
├──depends
└──install
Note:YoumayorganizethesourcecodeinanystructureyoulikeaslongasSynoBuildConfiseditedcorrectly.Thefollowing
sectionswillexplainthisindetail.
Belowissomesamplecodethatwewilluseasanexample.
//Copyright(c)2000-2016SynologyInc.Allrightsreserved.
#include<sys/sysinfo.h>
#include<syslog.h>
#include<stdio.h>
intmain(intargc,char**argv){
structsysinfoinfo;
intret;
if(ret!=0){
syslog(LOG_SYSLOG,"Failedtogetinfo\n");
return-1;
}
syslog(LOG_SYSLOG,"[MinimalPkg]%ssamplepackage...",argv[1]);
syslog(LOG_SYSLOG,"[MinimalPkg]TotalRam:%u\n",(unsignedint)info.totalram);
syslog(LOG_SYSLOG,"[MinimalPkg]FreeRAM:%u\n",(unsignedint)info.freeram);
return0;
}
EnvironmentVariablesinBuildandInstallScript
Front-endscriptswillpasssomeenvironmentvariablestoSynoBuildConf/buildandSynoBuildConf/install.Youcanutilizethemto
buildandinstallyourprojects.Youcanalsofindmostofthemin/toolkit/build_env/ds.${platform}${version}/{env.mak,env32/64.mak}.Someoftheenvironmentvariablesarelistedinbelow.
CC:pathofgcccrosscompiler.
CXX:pathofg++crosscompiler.
LD:pathofcrosscompilerlinker.
HelloWorldPackage
14
SynologyDSM6.0DeveloperGuide
CFLAGS:globalcflagsincludes.
AR:pathofcrosscompilerar.
NM:pathofcrosscompilernm.
STRIP:pathofcrosscompilerstrip.
RANLIB:pathofcrosscompilerranlib.
OBJDUMP:pathofcrosscompilerobjdump.
LDFLAGS:globalldflagsincludes.
ConfigOpt:optionsforconfigure.
ARCH:processorarchitecture.
SYNO_PLATFORM:Synologyplatform.
DSM_SHLIB_MAJOR:majornumberofDSM(integer).
DSM_SHLIB_MINOR:minornumberofDSM(integer).
DSM_SHLIB_NUM:buildnumberofDSM(integer).
ToolChainSysRoot:crosscompilersysrootpath.
SysRootPrefix:crosscompilersysrootconcatwithprefix/usr.
SysRootInclude:crosscompilersysrootconcatwithinclude_dir/usr/include.
SysRootLib:crosscompilersysrootconcatwithlib_dir/usr/lib.
HelloWorldPackage
15
SynologyDSM6.0DeveloperGuide
BuildStage:
IntheBuildStage,PkgCreate.pywillcompiletheprojectanditsdependentprojects.Pleasenotethatinthisstage,PkgCreate.py
dependsontwobuildscripts(SynoBuildConf/buildandSynoBuildConf/depend)togetthenecessaryinformation.
PkgCreate.py${project}#buildproject
BuildStageWorkflow:
TheworkflowoftheBuildStageisasfollows.
1. BasedonyourSynoBuildConf/depend,PkgCreate.pywilllocatethetargetDSMversionfrom[default]section.
2. PkgCreate.pywillresolvetheprojectsyoudependon.
3. Yourprojectandthedependentprojectswhichareplacedunder/toolkit/sourcewillbehard-linkedto
/toolkit/build_env/ds.${platform}/source.
4. TheirSynoBuildConf/buildwillbeexecutedinorderaccordingtotheirdependencybasedoneachSynoBuildConf/depend.
5. Ifyourprojectisneededbyotherprojectforcrosscompiling,youmayaddSynoBuildConf/install-devscript.install-devscript
willinstallcrosscompiledproductintoplatformchroot.
Note:SynoBuildConf/buildisexecutedunderchrootenvironment/toolkit/build_env/ds.${platform}.
SynoBuildConf/depends
PkgCreate.pywillresolveyourdependencyaccordingtothisconfigurationfile.Youneedtospecifyyourprojectdependencyandthe
buildenvironmentofyourprojectinthisfile.Forexample:
BuildStage
16
SynologyDSM6.0DeveloperGuide
[BuildDependent]
#eachlinehereisadependentproject
[ReferenceOnly]
#eachlinehereisaprojectforreferenceonlybutnoneedtobebuilt
[default]
all="6.0"#toolkitenvironmentversionofspecificplatform.(allplatformuse6.0toolkitenvironment)
TherearethreefieldsinSynoBuildConf/depends.
BuildDependent:Describesotherprojectswhicharedependentonthisproject.Forfurtherdetailsaboutthisfield,pleasereferto
CompileOpenSourceProject:nmap.
ReferenceOnly:Describesotherprojectswhicharereferredbythisproject,withoutthebuildprocess.
default:Describesthetoolkitenvironment.Thissectionisanecessaryfield.ItindicateseachplatformtobuildagainstsomeDSM
versionandthekey"all"meansallplatformusethisversionbydefault.
YoucanuseProjDepends.pyfront-endscriptstoseewhetherthedependencyorderofyourprojectsiscorrect.Option -x0will
traversealldependentprojectsof${project}.
cd/toolkit/pkgscripts
./ProjDepends.py-x0${project}
Ifyourapplicationcontainsmorethanoneproject,putthemin/toolkit/sourceandeditSynoBuildConfaccordinglyforeachofthem.
Formoreadvancedusageofthisfile,youmayrefertoCompileOpenSourceProjectandAdvanced.
SynoBuildConf/build
SynoBuildConf/buildisashellscriptthattellsPkgCreate.pyhowtocompileyourproject.Thecurrentworkingdirectoryofthisshell
scriptislocatedin/source/${project}underchrootenvironment.
Allpre-builtbinaries,headers,andlibrariesareundercrosscompilersysrootinchrootenvironment.Sincesysrootisthedefaultsearch
pathofcrosscompiler,youdonotneedtoprovide -Ior -Lto CFLAGSor LDFLAGS.
Variables:
Allvariableyoucanusein SynoBuildConf/build:
CC:pathofgcccrosscompiler.
CXX:pathofg++crosscompiler.
LD:pathofcrosscompilerlinker.
CFLAGS:globalcflagsincludes.
AR:pathofcrosscompilerar.
NM:pathofcrosscompilernm.
STRIP:pathofcrosscompilerstrip.
RANLIB:pathofcrosscompilerranlib.
OBJDUMP:pathofcrosscompilerobjdump.
LDFLAGS:globalldflagsincludes.
ConfigOpt:optionsforconfigure.
ARCH:processorarchitecture.
SYNO_PLATFORM:Synologyplatform.
DSM_SHLIB_MAJOR:majornumberofDSM(integer).
DSM_SHLIB_MINOR:minornumberofDSM(integer).
DSM_SHLIB_NUM:buildnumberofDSM(integer).
ToolChainSysRoot:crosscompilersysrootpath.
BuildStage
17
SynologyDSM6.0DeveloperGuide
SysRootPrefix:crosscompilersysrootconcatwithprefix/usr.
SysRootInclude:crosscompilersysrootconcatwithinclude_dir/usr/include.
SysRootLib:crosscompilersysrootconcatwithlib_dir/usr/lib.
Theexamplebuildscriptsislike:
#SynoBuildConf/build
case${MakeClean}in
[Yy][Ee][Ss])
makedistclean
;;
esac
make${MAKE_FLAGS}
Theaboveexamplecallsthe makecommandandcompilesyourprojectaccordingtoyourMakefilelocatedin /source/${project}.
Synologytoolkitenvironmenthasincludedselectedprebuildprojects.Youcanenterthechrootandusefollowingcommandtocheckif
neededheaderorprojectisprovidedbytoolkit.
##innerchroot
dpkg-l#listalldpkgprojects.
dpkg-L{projectdev}#listprojectinstallfiles
dpkg-S{header/librarypattern}#searchheader/librarypattern.
Forexample,theprojectneeds zlib.hand libz.sointhebuildstage.Usefollowingcommandtocheckifzlibanditscomponent
areinstalledinchroot.
chroot/tookit/build_env/ds.x64-6.0/
##innerchroot
>>dpkg-l|grepzlib
iizlib-1.x-x64-dev6.0-7274allSynologybuild-timelibrary
>>dpkg-Lzlib-1.x-x64-dev
/.
/usr
/usr/local
/usr/local/x86_64-pc-linux-gnu
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/libz.so
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/libz.a
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/pkgconfig
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/pkgconfig/zlib.pc
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/libz.so.1
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/libz.so.1.2.8
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/include
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/include/zconf.h
/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/include/zlib.h
>>dpkg-Szlib.so
zlib-1.x-x64-dev:/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/libz.so
zlib-1.x-x64-dev:/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/libz.so.1.2.8
zlib-1.x-x64-dev:/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/libz.so.1
Allfilehasbeeninstalledintosysroot,crossgcccanfindzlib.handlibz.sodirectly.
Someopensourcerequiretouseotherprojects'crosscompiledproductwhilebuildingtheirown.Forexample, pythonneeds
libffiand zlibwhileconfigure,weneedtoprovidethosetwoprojectbeforebuild python.Youcaninstallthecrosscompiled
productintothedestinationyouwantinbuildscript.PleaserefertoCompileOpenSourceProject:nmapformoreinformation.
BuildStage
18
SynologyDSM6.0DeveloperGuide
Makefile
ThefollowingexampleshowsaMakefile.Mostofthecontentcontainstypicalmakefilerules.Notethatwhenwritingyourproject
Makefile,youcanutilizepre-definedvariablesin/env.mak.
#Copyright(c)2000-2016SynologyInc.Allrightsreserved.
##YoucanuseCCCFALGSLDLDFLAGSCXXCXXFLAGSARRANLIBREADELFSTRIPafterincludeenv.mak
include/env.mak
EXEC=minimalPkg_2
OBJS=minimalPkg.o
all:$(EXEC)
$(EXEC):$(OBJS)
$(CC)$(CFLAGS)$<-o$@$(LDFLAGS)
install:$(EXEC)
mkdir-p$(DESTDIR)/usr/bin/
install$<$(DESTDIR)/usr/bin/
clean:
rm-rf*.o$(EXEC)
Formoredetaileddescriptionsaboutmakefile,pleaserefertohere.
Forafulllistofenvironmentvariablesthatareprovidedby/env.mak,pleaserefertoCreatePackage.
BuildStage
19
SynologyDSM6.0DeveloperGuide
PackStage:
InthePackStage,PkgCreate.pypacksallthenecessaryfilesaccordingtoyourmetadataandcreatesafinalSynologyPackageinthe
result_spkfolder.IfyouwantPkgCreate.pytoenterthePackStagewithouttheBuildStage,simplyrunPkgCreate.pywiththe -i
option.
Forexample,thefollowingcommandwillexecute${project}/SynoBuildConf/installwithoutsigningandputtingthefinalpackage
SPKfile(ifany)to/toolkit/result_spk.
cd/toolkit
pkgscripts/PkgCreate.py-i--no-sign${project}
PackStageWorkFlow:
TheworkflowofthePackStageisasfollows.
1. PkgCreate.pywillexecutethebuildscriptSynoBuildConf/install.
i. CreateINFOfilebyusingINFO.sh.
ii. Movenecessaryfilestoatemporaryfolder,/tmp/_install,forinstance,andcreatepackagetgz.
iii. Movenecessarymetadataandresourcestothetemporaryfolder,/tmp/_pkg,forinstance,andcreatethefinalSynology
Package.
2. PkgCreate.pywillsignthenewlycreatedSynologyPackagefilewithagpgkeywhichisplacedunder/root/.
ThefollowingfigureshowstheworkflowofthePackStage.
SynoBuildConf/install
PackStage
20
SynologyDSM6.0DeveloperGuide
Thisfilemustbewritteninbashandindicatesthefront-endscriptonhowtopackyourproject.Thecurrentworkingdirectoryis
/source/${project}underchrootenvironment.Ifthisisthetopprojectofyourpackage,thisfilewilldefinehowtocreatethefinal
packageSPKfile,includingdirectorystructureandtheINFOfileinyourSPK.(PleaserefertoINFOchapter)
DefineSynoBuildConf/installforinstallationmetadata,resourcefilesandpackingyourpackage.
#!/bin/bash
#Copyright(C)2000-2016SynologyInc.Allrightsreserved.
###UsePKG_DIRasworkingdirectory.
PKG_DIR=/tmp/_test_spk
rm-rf$PKG_DIR
mkdir-p$PKG_DIR
###getspkpackingfunctions
source/pkgscripts/include/pkg_util.sh
create_package_tgz(){
localfirewere_version=
localpackage_tgz_dir=/tmp/_package_tgz
localbinary_dir=$package_tgz_dir/usr/bin
###cleardestinationdirectory
rm-r$package_tgz_dir&&mkdir-p$package_tgz_dir
###installneededfileintoPKG_DIR
mkdir-p$binary_dir
cp-avminimalPkg$binary_dir
makeinstallDESTDIR="$package_tgz_dir"
###createpackage.tgz$1:source_dir$2:dest_dir
pkg_make_package$package_tgz_dir"${PKG_DIR}"
}
create_spk(){
localscripts_dir=$PKG_DIR/scripts
###CopyPackageCenterscriptstoPKG_DIR
mkdir-p$scripts_dir
cp-avscripts/*$scripts_dir
###Copypackageicon
cp-avPACKAGE_ICON*.PNG$PKG_DIR
###GenerateINFOfile
./INFO.sh>INFO
cpINFO$PKG_DIR/INFO
###Createthefinalspk.
#pkg_make_spk<sourcepath><destpath><spkfilename>
#Pleaseputtheresultspkinto/image/packages
#spknamefunctions:pkg_get_spk_namepkg_get_spk_unified_namepkg_get_spk_family_name
mkdir-p/image/packages
pkg_make_spk${PKG_DIR}"/image/packages"$(pkg_get_spk_family_name)
}
main(){
create_package_tgz
create_spk
}
main"$@"
Wewillbrieflyexplainthescriptsabove.
Inthebeginning,thescriptwillcallthePrepareDirsfunctionwhichwillpreparethenecessaryfolderfortheproject.
PackStage
21
SynologyDSM6.0DeveloperGuide
Aftercreatingthefolder,thescriptcalledSetupPackageFileswillmovethenecessaryresourcefilesto$INST_DIRand$PKG_DIR.
Inthisstep,wehavecalledtheINFO.shfiletocreatetheINFOfile.AlthoughyoumayputthecodesthatwillgeneratetheINFOfilein
theSynoBuildConf/installscript,wehighlyrecommendthatyoucreatetheINFOseperately.Generally,wenameitINFO.sh.Youcan
seehowtowriteINFO.shinthefollowingsubsections.
INFO
scripts
binary
Aftermovingtheresourcefiletotheproperlocation,wewillcalltheMakePackagefunctiontocreatethepackageforus.Wehave
included/sourcedahelperscriptcalledpkg_util.shwhichislocatedin/pkgscripts/include.ThisscriptcreatesthefinalpackageSPKfile
inthecorrectformat.Thepkg_make_packageandpkg_make_spk,whicharedefinedin*pkg_util.sh,createtheSynologyPackage.
Youcanseehowtousethishelperfunctionbelow.
pkg_make_package$1$2:Create$2/packages.tgzfromfilesin$1.
pkg_make_spk$1$2:Create$2/spkfromfilesin$1.
INFO.sh
Asmentionedearlier,INFO.shisjustanoptionalscript.YoucancreatetheINFOfilebyhandormovethecodeto
SynoBuildConf/install.However,westronglyrecommendthatyouutilizeINFO.shsothatyoucancreatetheINFOfileseparately
fromSynoBuildConf/install.
#!/bin/bash
#Copyright(c)2000-2016SynologyInc.Allrightsreserved.
source/pkgscripts/include/pkg_util.sh
package="minimalPkg"
version="1.0.0000"
displayname="MinimalPackage"
maintainer="SynologyInc."
arch="$(pkg_get_unified_platform)"
description="thisisaminimalpackage"
["$(caller)"!="0NULL"]&&return0
pkg_dump_info
Note:Theabovecodeisjustanexampletoshowsomeimportantvariablesforpkg_dump_info.Ifyouwanttoknowmore
detailsabouttheINFOfileandeachofthefields,pleaserefertoINFO.
SimilartoSynoBuildConf/install,wemustfirstincludepkg_util.sh.Afterthat,wecansetupthepropervariablesandcallthe
pkg_dump_infotocreatetheINFOfilecorrectly.
Asyoumayhavenoticed,weusedanotherhelperfunctioncalledpkg_get_platformtosetthearchvariable.Thisvariableindicatesthe
currentplatformwearebuilding.
Thefollowingstatementsindicatehowtousethehelperfunctions.
pkg_get_spk_platform:Returnplatformfor“arch”inINFO.
pkg_dump_info:DumpINFOaccordingtogivenvariables.
AftercreatingtheINFO.shfile,remembertoaddexecutablebitinINFO.sh.
chmod+xINFO.sh
PackStage
22
SynologyDSM6.0DeveloperGuide
SignPackage
InDSM5.1andonward,thePackageCenterhasabuilt-incodesignmechanismtoensurethepackage'spublisherintegrity.Thetoolkit
basedonDSM5.0andonwardhastheCodeSign.phpscripttosignthepackagewithGnuPGkeys.IfyoudonothaveaGPGkey,you
willneedtogenerateone.PleaserefertoPrepareGPGKeyformoreinformation.
IfyouwantPkgCreate.pytosignthepackageautomatically,youcanusethePkgCreate.pywithoutthe --no-signoption.For
example,thefollowingcommandindicatesPkgCreate.pytobuildandinstallyourprojectwithoutasignature.
PkgCreate.py-i${project}
Inaddition,ifyouwanttosignthepackageonyourown,youcanusethefollowingcommandtosignyourpackagemanually.
chroot/toolkit/build_env/ds.${platform}-${version}
php/pkgscripts-ng/CodeSign.php[option]--sign=package-path
Options:
--keydir=keyringsdirectory(defaultis/root/.gnupg)
--keyfpr=key'sfingerprint(defaultis"".Underthiscircumstances,wewillusingthefirstkeyinthekeydirectorytosignthepackag
Examples:
php/pkgscripts-ng/CodeSign.php--sign=phpBB-3.0.12-0031.spk
php/pkgscripts-ng/CodeSign.php--keydir=/root/.gpg--keyfpr=C1BF63CD--sign=phpBB-3.0.12-0031.spk
SignPackage
23
SynologyDSM6.0DeveloperGuide
EssentialRunTimeFiles
Scripts:
The“scripts”foldercontainsshellscriptswhichareexecutedduringtheinstallation,uninstallation,upgrading,starting,andstoppingof
packages.Therearesevenscriptfilesstoredinthe“scripts”folder:
postinst
postuninst
postupgrade
preinst
preuninst
preupgrade
start-stop-status
Note:Evenifyoudonotprovideanyofthesescriptfiles,thepackagewillbecreatedwithoutanyerrors.However,whenyoutry
toinstallyourpackageonyourDSMsystem,PackageCenterwillnotbeabletoinstallyourpackage.
Forsimplicity,thescriptswilllooklikethefollowingexample.
#!/bin/sh
exit0
Moredetailsaboutthesescriptswillbeexplainedinthescriptssection.
Icon:
YoucanaddanicontoyourpackagesothatwhenPackageCentershowstheinformationofyourpackage,itwillusetheiconyouhave
providedinsteadofthedefaultone.
Toaddanicontoyourpackage,puttheimageyourwantintoyourprojectsourcefolder,thenslightlymodifyyour
SynoBuildConf/installscript.ThefollowingisanexampleofamodifiedSynoBuildConf/installfromthepreviousexample.Forfurther
detailsregardingpackageicons,pleaserefertothePackageStructuresection.
Theonlydifferencefromthepreviousexampleisthatwecopiedourimagefilesintothe$PKG_DIRandrenameditto
PACKAGE_ICON.PNGandPACKAGE_ICON_256.PNG.insidetheSetupPackageFilesfunction.
Note:RemembertorenameyourimagetoPACKAGE_ICON.PNGandPACKAGE_ICON_256.PNGinallCAPS;otherwise,
PackageCenterwillnotrendertheiconproperly.
EssentialRunTimeFiles
24
SynologyDSM6.0DeveloperGuide
#!/bin/bash
#Copyright(C)2000-2016SynologyInc.Allrightsreserved.
###UsePKG_DIRasworkingdirectory.
PKG_DIR=/tmp/_test_spk
rm-rf$PKG_DIR
mkdir-p$PKG_DIR
###getspkpackingfunctions
source/pkgscripts/include/pkg_util.sh
create_package_tgz(){
localfirewere_version=
localpackage_tgz_dir=/tmp/_package_tgz
localbinary_dir=$package_tgz_dir/usr/bin
###cleardestinationdirectory
rm-r$package_tgz_dir&&mkdir-p$package_tgz_dir
###installneededfileintoPKG_DIR
mkdir-p$binary_dir
cp-avminimalPkg$binary_dir
makeinstallDESTDIR="$package_tgz_dir"
###createpackage.tgz$1:source_dir$2:dest_dir
pkg_make_package$package_tgz_dir"${PKG_DIR}"
}
create_spk(){
localscripts_dir=$PKG_DIR/scripts
###CopyPackageCenterscriptstoPKG_DIR
mkdir-p$scripts_dir
cp-avscripts/*$scripts_dir
###Copypackageicon
cp-avPACKAGE_ICON*.PNG$PKG_DIR
###GenerateINFOfile
./INFO.sh>INFO
cpINFO$PKG_DIR/INFO
###Createthefinalspk.
#pkg_make_spk<sourcepath><destpath><spkfilename>
#Pleaseputtheresultspkinto/image/packages
#spknamefunctions:pkg_get_spk_namepkg_get_spk_unified_namepkg_get_spk_family_name
mkdir-p/image/packages
pkg_make_spk${PKG_DIR}"/image/packages"$(pkg_get_spk_family_name)
}
main(){
create_package_tgz
create_spk
}
main"$@"
EssentialRunTimeFiles
25
SynologyDSM6.0DeveloperGuide
Summary
Inprevioussections,welearnedhowtousePackageTooltocompileandpackyourproject.Wewilllistsomeimportantnoteshere.
SourceCodeLayout:
toolkit/
├──pkgscripts-ng/
├──build_env/
│└──ds.${platform}-${version}
│└──/usr/syno
│├──lib
│├──bin
│└──include
├──result_spk/
│└──${package}-${version}/
│└──*.spk
└──source/
└──${project}/
├──sourcecode,Makefile...
├──INFO.sh
├──PACKAGE_ICON.PNG
├──PACKAGE_ICON_256.PNG
├──scripts/
│├──postinst
│├──postuninst
│├──postupgrade
│├──preinst
│├──preuninst
│├──preupgrade
│└──start-stop-status
└──SynoBuildConf/
├──build
├──depends
└──install
ThenecessaryfilesrequiredbyPkgCreate.pyarelistedbelow.
INFO
SynoBuildConf/build
SynoBuildConf/install
SynoBuildConf/depends
scripts/postinst
scripts/postuninst
scripts/postupgrade
scripts/preinst
scripts/preuninst
scripts/preupgrade
scripts/start-stop-status
Walk-ThroughofCreatePackage
1. InstallPackageToolkit
2. ListAvailableEnvironments
3. CreateBuildingEnvironmentusingEnvDeploy
4. CreateGPGkey
5. CreateSynoBuildConf/buildSynoBuildConf/installSynoBuildConf/depends
Summary
26
SynologyDSM6.0DeveloperGuide
6. Createscriptsfolderandscripts
7. BuildpackagewithPkgCreate.py
CommandWalk-Through
#InstallPackageToolkit
mkdir-p/toolkit
cd/toolkit
gitclonehttps://github.com/SynologyOpenSource/pkgscripts-ng
#MakeBuildEnvironment
./pkgscripts-ng/EnvDeploy-v6.0--list
./pkgscripts-ng/EnvDeploy-v6.0--infoplatform
./pkgscripts-ng/EnvDeploy-v6.0-p6281#forexample
#PrepareGPGkey
gpg--gen-key
>Pleaseselectwhatkindofkeyyouwant:
(1)RSAandRSA(default)
>choosekeysizeandenteryourname,email
>enterapassphrase:justpressEnterwithouttypinganycharacter
cp~/.gnupg/*/toolkit/build_env/ds.6281-6.0/root/.gnupg/
#PrepareProjectfolder
mkdir-p./source/${project}
#addsourcecode,Makefile,SynoBuildConfandscripts
...
#CompileandBuildSynologyPackage
./pkgscripts-ng/PkgCreate.py-x0-c${project}
Summary
27
SynologyDSM6.0DeveloperGuide
CompileOpenSourceProject
ThischapterwillshowyouhowtobuildanopensourceprojectforyourDSMsystemusingPackageToolkit.Ifyouwishtocompilethe
opensourceprojectmanually,pleaserefertoAppendixB:CompileOpenSourceProjectManually.
AsmentionedinCreatePackage,youhavetocreateSynoBuildConf/build,SynoBuildConf/install,andSynoBuildConf/dependsbefore
usingPackageToolkit.
Unlikethepreviousexample,compilinganapplicationonmostopensourceprojectsmayrequireexecutingthefollowingthreesteps:
1.
configure
2.
make
3.
makeinstall
Theconfigurescriptconsistsofmanylineswhichareusedtochecksomedetailsaboutthemachinewherethesoftwareisgoingtobe
installed.Thisscriptwillalsocheckalotofdependenciesonyoursystem.Whenyouruntheconfigurescript,youwillseealotof
outputonthescreen,eachbeingsomesortofquestionwitharespectiveyes/noasareply.Ifanyofthemajorrequirementsaremissing
onyoursystem,theconfigurescriptwillexitandyouwillnotbeabletoproceedwiththeinstallationuntilyoumeettherequired
conditions.Inmostcases,compileapplicationsonsomeparticulartargetmachineswillrequireyoutomodifytheconfigurescript
manuallytoprovidethecorrectvalues.
Whenrunningtheconfigurescripttoconfiguresoftwarepackagesforcross-compiling,youwillneedtospecifythe CC, LD,
RANLIB, CFLAGS, LDFLAGS, host, target,and build.
Inthischapter,wewilluseplatform6281asourexample.
Preparation:
Firstdownloadthetmuxsourcecodefromtheofficialgithubsiteoryoucandownloadtmuxfromthislink.
Note:Thearchivefileyou'vedownloadedfromtheabovelinksisdifferentfromtheofficialtmuxsourcecode.Wehaveadded
thenecessarybuildscripts.
ProjectLayout:
tmux/
├──tmuxrelatedsourcecode
├──INFO.sh
├──scripts/
└──SynoBuildConf/
├──build
├──depends
└──install
SynoBuildConf/depends:
Thefollowingisthedependsfileforthisexample.Thereisnothingspecialaboutthedependsfile.
[default]
all="6.0"
SynoBuildConf/build:
CompileOpenSourceProject:tmux
28
SynologyDSM6.0DeveloperGuide
Thebuildscriptisslightlydifferentfromthepreviousone.Hereyouwillhavetopassthefollowingenvironmentvariablestoconfigure:
CC
AR
CFLAGS
LDFLAGS
Inaddition,sincetmuxisdependentonncurses,youwillneedtouse pkg-configtoresolvethenecessaryheaderfilesandlibrariesfor
tmux.
ThefollowingisanexampleofSynoBuildConf/build:
#!/bin/sh
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
include/env.mak
case${MakeClean}in
[Yy][Ee][Ss])
makedistclean
;;
esac
NCURSES_INCS="`pkg-configncurses--cflags`"
NCURSES_LIBS="`pkg-configncurses--libs`"
CFLAGS+="${CFLAGS}${NCURSES_INCS}"
LDFLAGS+="${LDFLAGS}${NCURSES_LIBS}"
envCC="${CC}"AR=${AR}CFLAGS="${CFLAGS}"LDFLAGS="${LDFLAGS}"\
./configure${ConfigOpt}
make${MAKE_FLAGS}
SynoBuildConf/install
Insteadofcopyingthebinarytothedestinationfolder,mostbigprojectswilluse makeinstalltoinstallthebinariesandlibraries.
YoucanpasstheDESTDIRenvironmentvariabletospecifywhereyouwanttoinstallthebinariesandlibraries.
CompileOpenSourceProject:tmux
29
SynologyDSM6.0DeveloperGuide
#!/bin/bash
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
PKG_NAME="tmux"
INST_DIR="/tmp/_${PKG_NAME}"
PKG_DIR="/tmp/_${PKG_NAME}_pkg"
PKG_DEST="/image/packages"
PrepareDirs(){
fordirin$INST_DIR$PKG_DIR;do
rm-rf"$dir"
done
fordirin$INST_DIR$PKG_DIR$PKG_DEST;do
mkdir-p"$dir"
done
}
SetupPackageFiles(){
DESTDIR="${INST_DIR}"makeinstall
./INFO.sh>INFO
cpINFO"${PKG_DIR}"
cp-rscripts/"${PKG_DIR}"
}
MakePackage(){
source/pkgscripts/include/pkg_util.sh
pkg_make_package$INST_DIR$PKG_DIR
pkg_make_spk$PKG_DIR$PKG_DEST
}
main(){
PrepareDirs
SetupPackageFiles
MakePackage
}
main"$@"
INFO.sh
Asmentionedbefore,wewilluseINFO.shtogeneratetheINFOfile.
#!/bin/sh
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
./pkgscripts/include/pkg_util.sh
package="tmux"
version="1.9-a"
displayname="tmux"
arch="$(pkg_get_platform)"
maintainer="SynologyInc."
description="ThispackagewillinstalltmuxinyourDSMsystem."
["$(caller)"!="0NULL"]&&return0
pkg_dump_info
Note:RemembertosettheexecutablebitofINFO.shfile.
BuildandCreatePackage:
Runthefollowingcommandstocompilethesourcecodeandbuildthepackage.
/toolkit/pkgscripts-ng/PkgCreate.py-p6281-ctmux
CompileOpenSourceProject:tmux
30
SynologyDSM6.0DeveloperGuide
Afterthebuildprocess,youcanchecktheresultin /toolkit/result_spk.
VerifytheResult
Ifthebuildingprocesswassuccessful,youwillseethatthe.spkfilehasbeenplacedunderresult_spkfolder.Totestthespkfile,You
canusemanualinstallinPackageCentertoinstallyourpackage.
Warning:RemembertoimportyourkeystotheDSMsystemorselectAnypublisherinPackageCenter->Settings->General>TrustLevel.Otherwise,theinstallationwillfail.
YoucanthentrytoconnecttotheDSMusingsshandtypethefollowingcommandtofullyscanyourDSMmachine.
cd/var/packages/"${PKG_NAME}"/target/usr/local/bin
./tmux
CompileOpenSourceProject:tmux
31
SynologyDSM6.0DeveloperGuide
CompileOpenSourceProject:nmap
ThischapterwillshowyouhowtobuildanopensourceprojectforyourDSMsystemusingPackageToolkit.
Theopensourceprojectthatwearegoingtobuildinthisexampleisnmap,anetworkscanningprogram.Wewilluse6281asourbuild
environmentplatform.
Ifyouwishtocompileanopensourceprojectmanually,pleaserefertoAppendixB:CompileOpenSourceProjectManually.
AswehavementionedinHelloWorldPackage,youhavetocreatetheSynoBuildConf/build,SynoBuildConf/install,and
SynoBuildConf/dependsbeforeusingPackageToolkit.
Unlikethepreviousexample,compilinganapplicationonmostopensourceprojectsmayrequireexecutingthefollowingthreesteps:
1.
configure
2.
make
3.
makeinstall
Theconfigurescriptconsistsofmanylineswhichareusedtochecksomedetailsaboutthemachinewherethesoftwareisgoingtobe
installed.Thisscriptwillalsocheckalotofdependenciesonyoursystem.Whenyouruntheconfigurescript,youwillseealotof
outputonthescreen,eachbeingsomesortofquestionwitharespectiveyes/noasareply.Ifanyofthemajorrequirementsaremissing
onyoursystem,theconfigurescriptwillexitandyouwillnotbeabletoproceedwiththeinstallationuntilyoumeettherequired
conditions.Inmostcases,compileapplicationsonsomeparticulartargetmachineswillrequireyoutomodifytheconfigurescript
manuallytoprovidethecorrectvalues.
Whenrunningtheconfigurescripttoconfiguresoftwarepackagesforcross-compiling,youwillneedtospecifythe CC, LD,
RANLIB, CFLAGS, LDFLAGS, host, target,and build.
Preparation:
First,youwillneedtodownloadthenmapsourcecodefromtheofficialgithubsite.Youwillalsoneedtodownloadthelibpcapsource
codesincenmapdependsonlibpcap.Thelibpcapsourcecodecanbefoundhere.
Thefollowingcommandswilldownloadthesourcecodeforlibpacpandnmap.
wgethttps://nmap.org/dist/nmap-7.01.tar.bz2
tarxvfnmap-7.01.tar.bz2-C/toolkit/source
mv/toolkit/source/nmap-7.01/toolkit/source/nmap
wgethttp://www.tcpdump.org/release/libpcap-1.6.2.tar.gz
tarxvflibpcap-1.6.2.tar.gz-C/toolkit/source
mv/toolkit/source/libpcap-1.6.2/toolkit/source/libpcap
#Orusinggittodownloadsourcecode
cd/toolkit/source
gitclonehttps://github.com/nmap/nmap
gitclonehttps://github.com/the-tcpdump-group/libpcap
cdlibpcap
gitcheckoutorigin/libpcap-1.6
Pleaseremembertoupgradethelibpacptoversion1.6orthebuildpackageprocesswillfail.
ProjectLayout:
Afteryoudownloadthesourcecode,yourtoolkitlayoutshouldlooklikethefollowingfigure.
CompileOpenSourceProject:nmap
32
SynologyDSM6.0DeveloperGuide
toolkit/
├──build_env/
│└──ds.${platform}-${version}/
│└──/usr/syno/
│├──bin
│├──include
│└──lib
├──pkgscripts-ng/
└──source/
├──nmap/
│├──nmaprelatedsourcecode
│├──INFO.sh
│├──Makefile
│├──Synoscripts/#nmaphasit'sownscriptsfolder
│└──SynoBuildConf/
│├──build
│├──depends
│└──install
└──libpcap/
├──libpcaprelatedsourcecode
├──Makefile
└──SynoBuildConf/
├──build
├──depends
├──install-dev
└──install
Thefile,install-dev,isaspecialfilewhichwewillbecoveredinthefollowingsection.
SynoBuildConf/depends:
TheSynoBuildConf/dependsfornmapisslightlydifferentfromthepreviousexample.Sincenmapdependsonlibpcap,wehavetoadd
thevaluetotheBuildDependentfield,sothatthePkgCreate.pycanresolvethedependencyandcompiletheprojectinthecorrectorder.
Thedependsfilefornmapisasfollows.
[BuildDependent]
libpcap
[default]
all="6.0"
However,theSynoBuildConf/dependsforlibpcapisthesameastheHelloWorldExample.
[BuildDependent]
[default]
all="6.0"
SynoBuildConf/build:
TheSynoBuildConf/buildscriptisalsodifferentfromthepreviousone.
Hereyouwillhavetopassseveralenvironmentvariablestoconfigure,sothatnmapcanbecompiledproperly
CC
CXX
LD
AR
STRIP
RANLIB
CompileOpenSourceProject:nmap
33
SynologyDSM6.0DeveloperGuide
NM
CFLAGS
CXXFLAGS
LDFLAGS
Sincenmapwillbecompiledwithmanyfeaturesbydefault,wewillneedtodisablesomeofthemtomakeitclean.Thefollowinglist
containsthefeaturesthatwillbedisabled:
ndiff
zenmap
nping
ncat
nmap-update
liblua
Note:Ifyouareinterestedinsomeoftheabovefeaturesandyouwanttoenablethem,justchangethe --without-${feature}
into --with-${feature}.
ThefollowingistheSynoBuildConf/buildfornmap
#!/bin/sh
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
include/env.mak
PKG_NAME=nmap
INST_DIR=/tmp/_${PKG_NAME}
case${MakeClean}in
[Yy][Ee][Ss])
makedistclean
;;
esac
envCC="${CC}"CXX="${CXX}"LD="${LD}"AR=${AR}STRIP=${STRIP}RANLIB=${RANLIB}NM=${NM}\
CFLAGS="${CFLAGS}"CXXFLAGS="$CXXFLAGS$CFLAGS"\
LDFLAGS="${LDFLAGS}-lnl-lnl-genl-ldbus-1"\
./configure${ConfigOpt}\
--prefix=${INST_DIR}\
--without-ndiff\
--without-zenmap\
--without-nping\
--without-ncat\
--without-nmap-update\
--without-liblua\
--with-libpcap=/usr/local
make${MAKE_FLAGS}
Inthisexample, --with-libpcapisassignedwithvalue /usr/local.Weneedtoinstalllibpcap'scrosscompiledproductinto
"/usr/local"sothatnmap'sconfigurecanretrievelibpcapcorrectly.
ThefollowingistheSynoBuildConf/buildforlibpcap.
CompileOpenSourceProject:nmap
34
SynologyDSM6.0DeveloperGuide
#!/bin/bash
#Copyright(c)2000-2012SynologyInc.Allrightsreserved.
case${MakeClean}in
[Yy][Ee][Ss])
makedistclean
;;
esac
case${CleanOnly}in
[Yy][Ee][Ss])
return
;;
esac
#prefixwith/usr/local,allfileswillbeinstalledinto/usr/local
envCC="${CC}"CXX="${CXX}"LD="${LD}"AR=${AR}STRIP=${STRIP}RANLIB=${RANLIB}NM=${NM}\
CFLAGS="${CFLAGS}-Os"CXXFLAGS="${CXXFLAGS}"LDFLAGS="${LDFLAGS}"\
./configure${ConfigOpt}\
--with-pcap=linux--prefix=/usr/local
make${MAKE_FLAGS}
makeinstall
Theabovescriptwillinstalllibpcaprelatedfilesinto /usr/local/inchrootenvironment.Afterinstallinglibpcap,nmapcanfind
libpcap'scrosscompiledproductsin /usr/local.
Synologytoolkitprovides libpcapinchroot.
>dpkg-l|greplibpcap
iilibpcap-x64-dev6.0-7274allSynologybuild-timelibrary
nmapcanusechroot'slibpcapbyusing ${SysRootPrefix}variable.
--with-libpcap=${SysRootPrefix}
SynoBuildConf/install
Insteadofcopyingthebinarytothedestinationfolder,mostbigprojectswilluse makeinstalltoinstallthebinariesandlibraries.
Sincewehaveusedthe --prefixflagwhenconfiguringthenmapproject,wecanjustexecutemakeinstallanditwillinstallthe
nmaprelatedfilestothefolderspecifiedby --prefix.
CompileOpenSourceProject:nmap
35
SynologyDSM6.0DeveloperGuide
#!/bin/bash
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
PKG_NAME="nmap"
INST_DIR="/tmp/_${PKG_NAME}"
PKG_DIR="/tmp/_${PKG_NAME}_pkg"
PKG_DEST="/image/packages"
PrepareDirs(){
fordirin$INST_DIR$PKG_DIR;do
rm-rf"$dir"
done
fordirin$INST_DIR$PKG_DIR$PKG_DEST;do
mkdir-p"$dir"
done
}
SetupPackageFiles(){
makeinstall
./INFO.sh>INFO
cpINFO"${PKG_DIR}"
cp-rscripts/"${PKG_DIR}"
}
MakePackage(){
source/pkgscripts/include/pkg_util.sh
pkg_make_package$INST_DIR$PKG_DIR
pkg_make_spk$PKG_DIR$PKG_DEST
}
main(){
PrepareDirs
SetupPackageFiles
MakePackage
}
main"$@"
INFO.sh
Asmentionedbefore,wewilluseINFO.shtogeneratetheINFOfile.
#!/bin/sh
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
./pkgscripts/include/pkg_util.sh
package="nmap"
version="7.01"
displayname="nmap"
arch="$(pkg_get_platform)"
maintainer="SynologyInc."
description="ThispackagewillinstallnmapinyourDSMsystem."
["$(caller)"!="0NULL"]&&return0
pkg_dump_info
Note:RemembertosettheexecutablebitofINFO.shfile.
BuildandCreatePackage:
Lastly,runthefollowingcommandstocompilethesourcecodeandbuildthepackage.
/toolkit/pkgscripts-ng/PkgCreate.py-p6281-x0-cnmap
CompileOpenSourceProject:nmap
36
SynologyDSM6.0DeveloperGuide
Afterthebuildprocess,youcanchecktheresultin /toolkit/result_spk.
VerifytheResult
Ifthepackingprocesswassuccessful,youwillseeanspkfileplacedintheresult_spkfolder.Totestthespkfile,youcanusemanual
installinDSMPackageCentertoinstallyourpackage.
Warning:RemembertoimportyourkeystotheDSMsystemorselectAnypublisherinPackageCenter->Settings->General>TrustLevel.Otherwise,theinstallationwillfail.
YoucanthentrytoconnecttotheDSMusingsshandtypethefollowingcommandtofullyscanyourDSMmachine.
cd/var/packages/nmap/target/usr/local/bin
./nmap-v-Alocalhost
CompileOpenSourceProject:nmap
37
SynologyDSM6.0DeveloperGuide
CompileKernelModules
ThischapterwillshowyouhowtobuildlinuxkernelmodulesforyourDSMsystemusingPackageToolkit.Ifyouwishtocompilethe
kernelmoduleswithoutusingPackageToolkit,pleaserefertoAppendixB:CompileKernelModulesManually.
Asmentionedbefore,youhavetocreatetheSynoBuildConf/build,SynoBuildConf/install,andSynoBuildConf/dependsbeforeusing
PackageToolkit.
Inthischapter,wewilluseplatform6281asourexample.
Preparation:
First,youwillneedtodownloadtheGPLsourcecodeofyourplatform.Youcandownloadthesourcecodefromthislink.
AfterdownloadingtheSynologyGPLkernelsourcecode,movethefiletoyourtoolkitfolder.
SynoBuildConf/depends:
Thereisnothingspecialaboutthedependsfile.Thefollowingisthedependsfileforthe6281platform.
[default]
all="6.0"
SynoBuildConf/build:
Beforecompilingthekernelmodules,youwillneedtosetuptheconfigfilefirst.
Inthekernelsourcecode,thereareconfigurationfilesfordifferentplatforms.Theconfigurationfilesarelistedbelow:
CPU
ConfigurationFile
Arch
Linux
Marvell6281
Marvell6282
synoconfigs/88f6281
ARM
2.6.32
MarvellArmada370
synoconfigs/armada370
ARM
3.2.40
MarvellArmada375
synoconfigs/armada375
ARM
3.2.40
MarvellArmadaXP
synoconfigs/armadaxp
ARM
3.2.40
Annapurnalabs,AlpineAL212/AL314/AL514
synoconfigs/alpine(DS715,DS1515,DS2015xs)
synoconfigs/alpine4k(DS215+,DS416)
ARM
3.2.40
Mindspeed,Comcerto,C2000
synoconfigs/comcerto2k
ARM
3.2.40
Freescale8533
synoconfigs/ppc8533
PowerPC
2.6.32
FreescaleQorIQ(P1022)
synoconfigs/ppcQorIQ
PowerPC
2.6.32
IntelAtomD525,D510,D410,D425
synoconfigs/x86_64
x86
3.2.40
IntelAtomD2700
synoconfigs/cedarview
x86
3.2.40
IntelSoCCE5335
synoconfigs/evansport
x86
3.2.40
IntelCorei3
synoconfigs/bromolow
x86
3.2.40
CompileKernelModules
38
SynologyDSM6.0DeveloperGuide
Pleasecopytheproperconfigurationfileto .config,andrun makeoldconfigand makemenuconfigtoselectyourkernelmodules.
Accordingtotheplatformsyouwouldliketocompile,youwillhavetosettheproper ARCHand CROSS_COMPILEintoenvironment
variables.
Thefollowingisasamplescriptthatwillcompilethelinuxkernelmodulesforthe6281platform.
#!/bin/bash
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
#SynoBuildConf/build
case${MakeClean}in
[Yy][Ee][Ss])
[-fMakefile]&&makedistclean
;;
esac
case${CleanOnly}in
[Yy][Ee][Ss])
return
;;
esac
#prepareconfigfiles
cp-fsynoconfigs/88f6281.config
makeARCH=${ARCH}CC=${CC}oldconfig
#startcompilekernelmodules
echo"=====BuildSynologyLinuxkernel2.6Modules====="
makeARCH=${ARCH}CC=${CC}LD="${LD}"${MAKE_FLAGS}modules
#createtable
./scripts/syno_gen_usbmodem_table.shcreate-table
SynoBuildConf/install
Unlikethepreviousexample,thisexamplewillnotpackthewholekernelmoduleintoonesinglespkfile.Instead,itwillinstallthe
kernelmodulesin/images/modulesunderthechrootenvironment.Asaresult,theinstallationscriptbelowisslightlydifferentfromthe
previousexample.
#!/bin/bash
#Copyright(c)2000-2015SynologyInc.Allrightsreserved.
#SynoBuildConf/install
MODULES_DIR="${ImageDir}/modules"
PrepareDirs(){
[-d"${MODULES_DIR}"]||mkdir-p${MODULES_DIR}
rm-f${ImageDir}/modules/*
}
InstallModules(){
makeARCH=${ARCH}CC=${CC}LD="${LD}"INSTALL_MOD_PATH=$MODULES_DIRmodules_install
}
main(){
PrepareDirs
InstallModules
}
main"$@"
CompileKernelModules:
CompileKernelModules
39
SynologyDSM6.0DeveloperGuide
Lastly,runthefollowingcommandstocompileandinstallthekernelmodulestothedestinationfolder.
/toolkit/pkgscripts-ng/PkgCreate.py-p6281-clinux-2.6.32
Afterthebuildprocess,youcanchecktheresultin /toolkit/ds.6281-6.0/image/modules.
VerifytheResult:
YoucancopythekernelmoduleyouneedforyourDSMsystemandrunthefollowingcommandtoinstallthemodule.
insmod${module_name}
Usethefollowingcommandtoverifythatyourmodulehasbeeninstalledproperly.
lsmod|grep${module_name}
CompileKernelModules
40
SynologyDSM6.0DeveloperGuide
Advanced
ThissectionillustratesadvancedtypesofusageforthePackageToolkit.
PkgCreate.pyCommandOptionList
ThefollowingtablelistssomeofthePkgCreate.pycommands.
Option
Name
(default)
OptionPurpose
Runbuildstageonlywhichincludelinkandcompilesourcecode.It'sthesameas-Uoption.
-p
Specifytheplatformyouwanttopackyourproject.
-x
Builddependentprojectlevel.
-c
Runbothbuildstageandpackstagewhichincludelinksourcecode,compilesourcecode,packpackageand
signthefinalspk.
-U
Runbuildstageonlywhichincludeslinkandcompilesourcecode.
-l
Runbuildstageonly,butwillonlylinkyoursourcecode.
-L
Runbuildstageonly,butwillcompileyoursourcecodeonly.
-I
Runpackstageonly,whichwillpackandsignyourspk.
--no-sign
TellsPkgCreat.pynottosignyourspkfile.forexample,PkgCreat.py-I--no-sign${project}
-z
Runallplatformsconcurrently.
-J
Compileyourprojectwith-Jmakecommandoptions.
-S
Disablesilentmake.
Thefollowingtableshowstherelationshipbetweencommandoptionsindifferentstages.Youcanchoosetheproperoptionsbasedon
yourneeds.Option -cisenoughformostcases.
Stage
Action
(default)
-l
-L
-U
-I--no-sign
-I
-c
BuildStage
LinkSourcecode
Yes
Yes
No
Yes
No
No
Yes
BuildStage
CompileSourcecode
Yes
No
Yes
Yes
No
No
Yes
PackStage
PackPackage
No
No
No
No
Yes
Yes
Yes
PackStage
SignPackage
No
No
No
No
No
Yes
Yes
Platform-SpecificDependency
Platform-specificdependencymeansyoucanhaveseveraldependentprojectsfordifferentplatformsbyappending":${platform}"to
thefollowingsections:BuildDependentandReferenceOnly.Thefollowingexampleshows816xandaramda370projectsthatareon
libbar-1.0.
Advanced
41
SynologyDSM6.0DeveloperGuide
#SynoBuildConf/depends
[BuildDependent]
libfoo-1.0
[BuildDependent:816x,armada370]
libfoo-1.0
libbar-1.0
[default]
all="6.0"
CollecttheSPKFileinYourOwnWay
Bydefault,PkgCreate.pywillmovetheSPKfileto/toolkit/result_spkaccordingto/toolkit/build_env/ds.${platform}${version}/source/${project}/INFO.Youcanhaveyourowncollectoperationbyaddingahook,SynoBuildConf/collect.
SynoBuildConf/collectcanbeanyexecutableshellscript(soremembertochmod+x)andPkgCreate.pywillpassthefollowing
environmentvariablestoit:
SPK_SRC_DIR:SourcefolderoftargetSPKfile.
SPK_DST_DIR:DefaultdestinationfoldertoputSPKfile.
SPK_VERSION:Versionofpackage(accordingtoINFO).
ThecurrentworkingdirectoryofSynoBuildConf/collectis/source/${project}willbeunderchrootenvironment.
Advanced
42
SynologyDSM6.0DeveloperGuide
PackageIntroduction
Inpackage,youdefinessomescriptsandmetadatatocontroltheinstallation,un-installation,upgrading,startingandstoppingprocesses
aswellashowtocommunicatewithSynologyPackageCenterinDSM.SynologyPackageCenterprovidesuserinterfacetotheend
userandautomatestheprocessesandconfiguringpackagestomaketheenduserinstall,un-install,upgrade,startandstopyourpackage
easily.
SynologyPackage
43
SynologyDSM6.0DeveloperGuide
PackageStructure
ASynologypackageisaSPKfileintarformat,containingmetadataandfilesasinthefollowing:
File/FolderName
Description
File/FolderType
DSM
Requirement
INFO
Thisfilecontainstheinformationdisplayedin
PackageCenterortocontroltheflowof
installation.(PleaserefertoINFOsectionformore
information)
File
2.0-0731
Folder(Contains
install_uifile,
upgrade_uifile,
uninstall_uifile,
...)
3.2-1922
.tgzFile
2.0-0731
Folder(Contains
preinst,postinst,
preuninst,
postunist,
preupgrade,
postupgrade,
start-stop-status)
2.0-0731
Folder(contains
PKG_DEPS,
PKG_CONX,...)
4.2-3160
File
3.2-1922
.pngfile
3.2-1922
.pngfile
4.2-3160~
4.3-3810
.pngfile
5.0-4400
WIZARD_UIFILES
Optional.Thisfoldercontainsfileswhere
descriptionsofUIcomponentsareshownduring
theinstallation,un-installation,andupgrading
process.
(PleaserefertoWIZARD_UIFILESsectionfor
moreinformation)
package.tgz
Thisisacompressedfile,containingallthefiles
thatarerequired,suchasexecutablebinary,library,
orUIfiles.
(Pleaserefertopackage.tgzsectionformore
information)
scripts
Thisfoldercontainsshellscriptswhichare
executedduringtheinstallation,uninstalling,
upgrading,starting,andstoppingprocesses.
(Pleaseseethescriptssectionformoreinformation)
Optional.Thisfoldercontainsconfigurations.
conf
LICENSE
PACKAGE_ICON.PNG
Note:
1.InDSM4.2~DSM5.2,ifyouwanttoconfigure
fileswithinit,thesupport_conf_folderkeyinthe
INFOfilemustbesetto"yes".
2.InDSM6.0,youdon'tneedtodefinethe
support_conf_folderkeyintheINFOfile.
(Pleaserefertoconfsectionformoreinformation)
Optional.Thisfileisshownintheinstallation
process,andmustbelessthan1MB.
72x72.pngimageisshowninPackageCenter
120x120.pngimageisshowninPackageCenter.
PACKAGE_ICON_120.PNG
(Deprecated)
Note:ItisnotcompatiblewithallDSMversions
becausetheiconwillnotbeinstalledinDSM4.1or
older.IfyourpackagecanbeinstalledinDSM4.1
orolder,pleaserefertothenextsectiontodefine
package_icon_120intheINFOfileinsteadof
takingPACKAGE_ICON_120.PNG.
256x256.pngimageisshowninPackageCenter.
PACKAGE_ICON_256.PNG
PackageStructure
Note:ItisnotcompatiblewithallDSMversions
becausetheiconwillnotbeinstalledinDSM4.3or
older.IfyourpackagecanbeinstalledinDSM4.3
orolder,pleaserefernextsectiontodefine
package_icon_256inINFOfiletoinsteadoftaking
PACKAGE_ICON_256.PNG.
44
SynologyDSM6.0DeveloperGuide
Note:
Allwordsarecasesensitive.
YoucanusePkgCreate.pyandpkg_make_spktohelpyoucreatethepackage.Formoredetails,pleasereferto
BuildandCreatePackage
PackStage:SynoBuildConf/install
PackageStructure
45
SynologyDSM6.0DeveloperGuide
INFO
The“INFO”fileisusedtodescribetheinformationofthepackage.PackageCenterwillsearchforinformationonhowtocontrolthe
installation,un-installation,upgrading,startingandstoppingprocessesandlistingsinPackageCenter.Forexample,ifyouwouldlike
thepackagetobedependentonsomeservices,youcandefinethekeyasinstall_dep_services.Ifyouwouldliketorestartsome
servicesaftertheinstallationprocess,youcandefinethekeyasinstuninst_restart_services.PackageCenterwillputthe“INFO”file
to/var/packages/[packageidentify]/INFOafterthepackageisinstalled.
INFOFieldFormat:
EachpieceofinformationintheINFOfileisdefinedbykey/valuepairsseparatedbyanequalssign
e.g.key="value".
Note:Allwordsinkeyandvaluearecasesensitive.
INFOFieldList:
TherearemanyfieldsinanINFOfile.Wecandividethemintotwogroups:
Necessaryfields:NecessaryFields
Optionalfields:OptionalFields
ThefollowingaresomeCodeWordsfortheINFOfieldlist:
apache-sys=apachedaemonlisteningonDSMports(e.g.5000or5001)
apache-web=apachedaemonlisteningonWebStationports(e.g.80or443).
mdns=MulticastDNSServiceDiscovery
db=MySQLandPostgreSQL
applenetwork=AppleNetwork
nfs=NFS
ssh=SSH,SecureShell
pgsql=PostgreSQL
TheversionofDSMrequirementmeanskey/valuepairsinINFOworkscorrectlyintheminimumversionofDSM.
WritingINFOFile:
InsteadofwritingtheINFOfilebyyourself,wehaveprovidedusefulhelperfunctionsinPackageToolkitthatwillhelpyoucreatethe
INFOfile.PleaserefertoPackStage:INFO.sh.
INFO
46
SynologyDSM6.0DeveloperGuide
FieldName:package
Description:Packageidentity.Nomorethanoneversionofapackagecanexistatthesametimeintheenduser'sDSM;therefore,
theidentificationisuniquetoidentifyyourpackage.Besides,PackageCenterwillcreatea/var/packages/[packageidentity]folder
toputpackagefiles.
Note:Thisvalueofthekeycannotcontainanyofthesespecialcharacters:,/,>,<,|or=.
Value:String
DefaultValue:(Empty)
Example:
package="DownloadStation"
DSMRequirement:2.0-0731
FieldName:displayname
Description:PackageCentershowsthenameofthepackage.
Note:Ifdisplaynamekeyisempty,PackageCenterwilldisplaythevalueofpackagekey.
Value:String
DefaultValue:Thevalueofpackagekey
Example:None
DSMRequirement:2.3-1118
FieldName:version
Description:Packageversion.Enduserscanidentifythepackageversion.
Note:
1. Eachversiondelimiterisonlyallowedtobe.-or_.
2. Eachversionnumberwhichisdelimitedbydelimiterisonlyallowedtobenumber
Value:String
DefaultValue:(Empty)
Example:
version="3.6-3263"
DSMRequirement:2.0-0731
FieldName:firmware
Description:EarliestversionofDSMfirmwarethatisrequiredtorunthepackage.
Value:X.Y-ZDSMmajornumber,DSMminornumber,DSMbuildnumber
DefaultValue:(Empty)
Example:None
DSMRequirement:2.3-1118
NecessaryFields
47
SynologyDSM6.0DeveloperGuide
FieldName:description
Description:PackageCentershowsashortdescriptionofthepackage.
Value:String
DefaultValue:(Empty)
Example:
description="DownloadStationisaweb-baseddownloadapplicationwhichallowsyoutodownloadfilesfromtheInternetthroughBT
DSMRequirement:2.3-1118
DSMRequirement:4.2-3160
FieldName:arch
Description:ListtheCPUarchitectureswhichcanbeusedtoinstallthepackage.
Value:(archvaluesareseparatedwithaspace.PleasereferAppendixA:PlatformandArchValueMappingTabletomore
information)
DefaultValue:noarch
Note:
1. "noarch"meansthepackagecanbeinstalledandworkinanyplatform.Forexample,thepackageiswritteninPHPorshell
script.
2. Pleasenotpackallbinaryfileswithdifferentplatformstoonepackagespkfile.
Example:
arch="noarch"
or
arch="x86ppc853x".
DSMRequirement:2.0-0731
FieldName:maintainer
Description:PackageCentershowsthedeveloperofthepackage.
Value:String
DefaultValue:(Empty)
Example:
maintainer="SynologyInc."
DSMRequirement:2.0-0731
FieldName:package_icon
Description:72x72pngimagedataisencodedbyBase64.
NecessaryFields
48
SynologyDSM6.0DeveloperGuide
Note:
1. ThisvaluewillbereplacedwhenaPACKAGE_ICON.PNGfileisstoredinthe[packagename].spk.
2. IfthevalueisnotdefinedandnoPACKAGE_ICON.PNGfileisinthe[packagename].spk,thepackageiconwill
bethedefaultone.
Value:Base64-encodedvalue
DefaultValue:adefaulticon
Example:None
DSMRequirement:3.2-1922
FieldName:package_icon_256
Description:256x256pngimagedataisencodedbyBase64.
Note:
1. ThisvaluewillbereplacedwhenaPACKAGE_ICON_256.PNGfileisstoredinthe[packagename].spk.
2. IfthevalueisnotdefinedandnoPACKAGE_ICON_256.PNGfileisinthe[packagename].spk,a72x72iconwill
bethedefault,andtheresultswilllookmorepixelatedandblurryinDSM.
Value:Base64-encodedvalue
DefaultValue:adefaulticon
Example:None
DSMRequirement:5.0-4458
NecessaryFields
49
SynologyDSM6.0DeveloperGuide
FieldName:displayname_[DSMlanguage]
Description:PackageCentershowsthenameintheDSMlanguagesetbytheend-user.DSMsupportsthefollowinglanguages:
enu(English)
cht(TraditionalChinese)
chs(SimplifiedChinese)
krn(Korean)
ger(German)
fre(French)
ita(Italian)
spn(Spanish)
jpn(Japanese)
dan(Danish)
nor(Norwegian)
sve(Swedish)
nld(Dutch)
rus(Russian)
plk(Polish)
ptb(BrazilianPortuguese)
ptg(EuropeanPortuguese)
hun(Hungarian)
trk(Turkish)
csy(Czech)
Value:String
DefaultValue:packagename
Example:
displayname_enu="HelloWorld"
displayname_cht=""
DSMRequirement:2.3-1118
FieldName:description_[DSMlanguage]
Description:PackageCentershowsashortdescriptionintheDSMlanguagesetbytheend-user.
DSMsupportsthefollowinglanguages:
enu(English)
cht(TraditionalChinese)
chs(SimplifiedChinese)
krn(Korean)
ger(German)
fre(French)
ita(Italian)
spn(Spanish)
jpn(Japanese)
dan(Danish)
nor(Norwegian)
sve(Swedish)
nld(Dutch)
rus(Russian)
OptionalFields
50
SynologyDSM6.0DeveloperGuide
plk(Polish)
ptb(BrazilianPortuguese)
ptg(EuropeanPortuguese)
hun(Hungarian)
trk(Turkish)
csy(Czech)
Value:String
DefaultValue:description
Example:
description_enu="HelloWorld"
description_cht=""
DSMRequirement:2.3-1118
FieldName:maintainer_url
Description:Ifapackagehasadeveloperwebpage,PackageCenterwillshowalinktolettheuseropenit.
Value:String
DefaultValue:(Empty)
Example:
maintainer_url="http://www.synology.com"
DSMRequirement:4.2-3160
FieldName:distributor
Description:PackageCentershowsthepublisherofthepackage.
Value:String
DefaultValue:(Empty)
Example:
distributor="SynologyInc."
DSMRequirement:4.2-3160
FieldName:distributor_url
Description:Ifapackageisinstalledandhasadistributerwebpage,PackageCenterwillshowalinktolettheuseropenit.
Value:String
DefaultValue:(Empty)
Example:
distributor_url="http://www.synology.com/enu/apps/3rd-party_application_integration.php"
DSMRequirement:4.2-3160
FieldName:support_url
Description:PackageCentershowsasupportlinktoallowuserstoseektechnicalsupportwhenneeded.
OptionalFields
51
SynologyDSM6.0DeveloperGuide
Value:String
DefaultValue:(Empty)
Example:
support_url="https://myds.synology.com/support/support_form.php".
FieldName:support_center
Description:Ifsetto“yes,”PackageCenterdisplaysalinktomaketheenduserlaunchSynologySupportCenterApplication
whenyourpackageisinstalled.
Note:Ifsetto“yes,”thereport_urllinkwon’tshowinPackageCenter.
Value:"yes"/"no"
DefaultValue:"no"
Example:None
DSMRequirement:5.0-4458
FieldName:model
Description:Listofmodelsonwhichpackagescanbeinstalledinspesificmodels.ItisorganizedbySynologystring,architecture
andmodelname.
Value:(modelsareseparatedwithaspace,e.g.synology_88f6281_209,synology_cedarview_rs812rp+,synology_x86_411+II,
synology_bromolow_3612xs,synology_cedarview_rs812rp+,…)
DefaultValue:(Empty)
Example:
model="synology_bromolow_3612xssynology_cedarview_rs812rp+".
DSMRequirement:4.0-2219
FieldName:exclude_arch
Description:ListtheCPUarchitectureswherethepackagecan'tbeusedtoinstallthepackage.
Note:Becarefultousethisexclude_archfield.Ifthepackagehasdifferentexclude_archvalueinthedifferentversions,
theendusercaninstallthepackageinthespecificversionwithoutsomearchvaluesofexclude_arch.
Value:(archvaluesareseparatedwithaspace.PleasereferAppendixA:PlatformandArchValueMappingTabletomore
information)
DefaultValue:(Empty)
Example:None
DSMRequirement:6.0
Example:
exclude_arch="bromolowcedarview".
FieldName:checksum
Description:ContainsMD5stringtoverifythepackage.tgz.
Value:String
DefaultValue:(Empty)
OptionalFields
52
SynologyDSM6.0DeveloperGuide
Example:None
DSMRequirement:3.2-1922
FieldName:adminport
Description:ApackagelistenstoaspecificporttodisplayitsownUI.Ifthepackageisdefinedbyaport,alinkwillbeopened
whenthepackageisstarted.
Note:adminprotocol,adminportandadminurlkeysarecombinedtoadminprotocol://ip:adminport/adminurllink
Value:0~65536
DefaultValue:80
Example:
adminport="9002"
DSMRequirement:2.0-0731
FieldName:adminurl
Description:Ifapackageisinstalledandhasawebpage,alinkwillbeopenedwhenthepackageisstarted.
Note:adminprotocol,adminportandadminurlkeysarecombinedtoadminprotocol://ip:adminport/adminurllink
Value:String
DefaultValue:(Empty)
Example:
adminurl="web"
DSMRequirement:2.3-1118
FieldName:adminprotocol
Description:ApackageusesaspecificprotocoltodisplayitsownUI.Ifapackageisinstalledandhasawebpage,aprotocolwill
beopenedwhenthepackageisstarted.
Note:adminprotocol,adminportandadminurlkeysarecombinedtoadminprotocol://ip:adminport/adminurllink
Value:http/https
(Separatedwithaspace)
DefaultValue:http
Example:
adminprotocol="http"
DSMRequirement:3.2-1922
FieldName:dsmuidir
Description:DSMUIfoldernameinpackage.tgz.TheUIfolderofthepackagein/var/packges/[packge
name]/target/[dsmuidir]willbeautomaticallylinkedtotheDSMUIfolderin/usr/syno/synoman/webman/3rdparty/[package
name]toshowyourpackage'sshortcutinDSMafterthepackageisstarted.Toremovethelink,afterthepackageisstopped.
OptionalFields
53
SynologyDSM6.0DeveloperGuide
Note:
1. Thiskeycannotcontain:or/.
2. PleasereferIntegrateYourpackageintoDSMformoreinformation.
Value:String
DefaultValue:(Empty)
Example:None
DSMRequirement:3.2-1922
FieldName:dsmappname
Description:ThevalueofeachindividualapplicationwillbeequaltotheuniquepropertynameinDSM’sconfigfilesoastobe
integratedintoSynologyDiskStation.
Note:PleasereferConfiginIntegrateYourpackageintoDSMchapterformoreinformation.
Value:(Separatedwithaspace)
DefaultValue:(Empty)
Example:
dsmappname="SYNO.SDS.PhotoStationSYNO.SDS.PersonalPhotoStation"
DSMRequirement:3.2-1922
FieldName:checkport
Description:CheckifthereisanyconflictbetweentheadminportandtheportswhicharereservedorarelisteningonDSM
exceptweb-serviceports(e.g.80,443)andDSMports(e.g.5000,5001).
Value:"yes"/"no"
DefaultValue:"yes"
Example:None
DSMRequirement:3.2-1922
FieldName:startable
Description:Whennoprograminthepackageprovidestheend-userwiththeoptionstoenableordisableitsfunction.Thiskeyis
setto"no"andtheend-usercannotstartorstopthepackageinPackageCenter.
Note:If“startable”issetto“no”,start-stop-statusscriptwhichrunsinbootuporshotdownisstillrequired.
Value:"yes"/"no"
DefaultValue:"yes"
Example:None
DSMRequirement:3.2-1922
FieldName:precheckstartstop
Description:Ifsetto"yes",letstart-stop-statuswithprestartorprestopargumentrunbeforestartorstopthepackage.Pleaserefer
tostart-stop-statusinscriptsformoreinformation.
Value:"yes"/"no"
DefaultValue:"yes"
Example:None
DSMRequirement:6.0
OptionalFields
54
SynologyDSM6.0DeveloperGuide
FieldName:helpurl
Description:Ifapackageisinstalledandhasa"help"webpage,PackageCenterwilldisplayahyperlinktotheuser.
Value:String
DefaultValue:(Empty)
Example:
helpurl="https://www.synology.com/en-global/knowledgebase"
DSMRequirement:3.2-1922
FieldName:beta
Description:Ifthispackageisconsideredthebetaversion,thebetainformationwillbeshowninPackageCenter.
Value:"yes"/"no"
DefaultValue:"no"
Example:None
DSMRequirement:6.0
FieldName:report_url
Description:Ifapackageisabetaversionandhasa"report"webpage,PackageCenterwilldisplayahyperlink.Ifthispackageis
consideredthebetaversion,thebetainformationwillbealsobeshowninPackageCenter.
Value:String
DefaultValue:(Empty)
Example:None
DSMRequirement:3.2-1922
FieldName:install_reboot
Description:RebootDiskStationafterinstallingorupgradingthepackage.
Value:"yes"/"no"
DefaultValue:"no"
Example:None
DSMRequirement:3.2-1922
FieldName:install_dep_packages
Description:Beforeapackageisinstalledorupgraded,thesepackagesmustbeinstalledfirst.Inaddition,theorderofstartingor
stoppingpackagesisalsodependentonit.Theformatconsistsofapackagename.Ifmorethanonedependentpackagesare
required,thepackagenameofthepackage(s)willbeseparatedwithacolon,e.g.install_dep_packages="packageA".Ifa
specificversionrangeisrequired,packagenamewillbefollowedbyoneofthespecialcharacters=,<,>,>=,<=andpackage
versionwhichiscomposedbynumberandperiods,e.g.install_dep_packages="packageA>2.2.2:packageB".
Note:>=and<=operatoronlysupportedinDSM4.2ornewer.Don’tuse<=and>=ifapackagecanbeinstalledinDSM
4.1orolderbecauseitcannotbecomparedcorrectly.Instead,thepackageversionshouldbesetlowerorhigher.
Value:Packagenames
Note:Eachpackagenameisseparatedwithacolon.
DefaultValue:(Empty)
Example:
OptionalFields
55
SynologyDSM6.0DeveloperGuide
install_dep_packages="packageA"
or
install_dep_packages="packageA>2.2.2:packageB"
DSMRequirement:3.2-1922
FieldName:install_conflict_packages
Description:Beforeyourpackageisinstalledorupgraded,theseconflictpackagescannotbeinstalled.Theformatconsistsofa
packagename,e.g.install_conflict_packages="packageA".Ifmorethanoneconflictpackagesarerequiredwiththeformat,the
nameofthepackage(s)willbeseparatedwithacolon,e.g.install_conflict_packages="packageA:packageB".Ifaspecific
versionrangeisrequired,packagenamewillbefollowedbyoneofthespecialcharacters=,<,>,>=,<=andpackageversion
whichiscomposedbynumberandperiods,e.g.install_conflict_packages="packageA>2.2.2:packageB".
Note:>=and<=operatoronlysupportedinDSM4.2ornewer.Donotuse<=and>=ifapackagecanbeinstalledinDSM
4.1becauseitcan’tbecomparedcorrectly.Instead,thepackageversionshouldbesetlowerorhigher.
Value:Packagenames
Note:Eachpackagenameisseparatedwithacolon.
DefaultValue:(Empty)
Example:
install_conflict_packages="packageA:packageB"
or
install_conflict_packages="packageA>2.2.2:packageB"
DSMRequirement:4.1-2851
FieldName:instuninst_restart_services
Description:Reloadservicesafterinstalling,upgradinganduninstallingthepackage.
Note:
1. Iftheserviceisnotenabledorstartedbytheend-user,serviceswon'tbereloaded
2. Iftheinstall_rebootissetto“yes”,thisvalueisignoredintheinstallationprocess.
Value:
DSM4.3orolder:apache-sys,apache-web,mdns,samba,db,applenetwork,cron,nfs,firewall
DSM5.0~DSM5.2:apache-sys,apache-web,mdns,samba,applenetwork,cron,nfs,firewall
DSM6.0:nginx,mdns,samba,applenetwork,cron,nfs,firewall
Note:Eachserviceisseparatedwithaspace.
DefaultValue:(Empty)
Example:
instuninst_restart_services="apache-sysapache-web"
DSMRequirement:3.2-1922
FieldName:startstop_restart_services
Description:Reloadservicesafterstartingandstoppingthepackage.
Note:
1. Iftheserviceisnotenabledorstartedbytheend-user,serviceswon'tbereloaded.
2. Ifstartableissetto“no”,thevalueisignored.
OptionalFields
56
SynologyDSM6.0DeveloperGuide
Value:
DSM4.3orolder:apache-sys,apache-web,mdns,samba,db,applenetwork,cron,nfs,firewall
DSM5.0~DSM5.2:apache-sys,apache-web,mdns,samba,applenetwork,cron,nfs,firewall
DSM6.0:nginx,mdns,samba,applenetwork,cron,nfs,firewall
Note:Eachserviceisseparatedwithaspace.
DefaultValue:(Empty)
Example:
startstop_restart_services="apache-sysapache-web"
DSMRequirement:3.2-1922
FieldName:install_dep_services
Description:Beforethepackageisinstalledorupgraded,theseservicesmustbestartedorenabledbytheend-user.
Value:
DSM4.2orolder:apache-web,mysql,php_disable_safe_exec_dir
DSM4.3:apache-web,mysql,php_disable_safe_exec_dir,ssh
DSM5.0~DSM5.2:apache-web,php_disable_safe_exec_dir,ssh,pgsql
DSM6.0:ssh,pgsql
Note:Eachserviceisseparatedwithaspace.
DefaultValue:(Empty)
Example:
install_dep_services="apache-webssh"
DSMRequirement:3.2-1922
FieldName:start_dep_services
Description:Beforethepackageisstarted,theseservicesmustbestartedorenabledbytheend-user.Ifstartableissetto“no”,this
valueisignored.
Value:
DSM4.2orolder:apache-web,mysql,php_disable_safe_exec_dir
DSM4.3:apache-web,mysql,php_disable_safe_exec_dir,ssh
DSM5.0~DSM5.2:apache-web,php_disable_safe_exec_dir,ssh,pgsql
DSM6.0:ssh,pgsql
Note:Eachserviceisseparatedwithaspace.
DefaultValue:(Empty)
Example:
install_dep_services="apache-webssh"
DSMRequirement:3.2-1922
FieldName:extractsize
Description:Thisvalueindicatestheminimalspacetoinstallapackage.Itwillbeusedtoprompttheuserifthereisenoughfree
spacetoinstallit.
OptionalFields
57
SynologyDSM6.0DeveloperGuide
Note:
1. InDSM5.2ororder,thesizebasedonbyteunit.
2. InDSM6.0ornewer,thesizebasedonkilobyteunit.
Value:Sizeunit
DefaultValue:ThebytesizeofSPKfileofpackage
Example:
extractsize="253796"
DSMRequirement:4.0-2166
FieldName:support_conf_folder
Description:InDSM5.2ororder,ifyouwanttousesomespecialconfigurationfileswithina"conf"folder,thisvaluemustbeset
to"yes".Moredetailsaregiveninthe"conf"section.Howerver,inDSM6.0ornewer,youdon'tneedtodefineitanymore.
Note:DeprecatedinDSM6.0
Value:"yes"/"no"
DefaultValue:"no"
Example:
support_conf_folder="yes"
DSMRequirement:4.2-3160~5.2
FieldName:install_type
Description:Ifsetto“system”,yourpackagewillbeinstalledintherootfilesystem,/usr/local/packages/@appstore/,evenif
thereisnovolume.
Note:Becarefulwhensettingthis,asitmayresultintheDiskStationcrashingifyourpackagerunsoutofthespaceinthe
rootfilesystem.
Value:"system"
DefaultValue:(Empty)
Example:
install_type="system"
DSMRequirement:5.0-4458
FieldName:silent_install
Description:Ifsetto“yes”,yourpackageisallowedtobeinstalledwithoutthepackagewizardinthebackground.Thisallows
CMS(CentralManagementSystem)todistributepackageinstallationtootherNASconnected.
Value:"yes"/"no"
DefaultValue:"no"
Example:
silent_install="yes"
DSMRequirement:5.0-4458
OptionalFields
58
SynologyDSM6.0DeveloperGuide
FieldName:silent_upgrade
Description:Ifsetto“yes”,yourpackageisallowedtobeupgradedwithoutthepackagewizardinthebackground.Enduser
cannotmodifyanyinformationforupgrading.ThisallowsnotonlyyourpackagetobeupgradedautomaticallybutalsoforCMS
(CentralManagementSystem)todistributepackageupgradestootherNASconnected.
Value:"yes"/"no"
DefaultValue:"no"
Example:
silent_upgrade="yes"
DSMRequirement:5.0-4458
FieldName:silent_uninstall
Description:Ifsetto“yes”,yourpackageisallowedtobeuninstalledwithoutthepackagewizardinthebackground.Thisallows
CMS(CentralManagementSystem)todistributepackageuninstallationtootherNASconnected.
Value:"yes"/"no"
DefaultValue:"no"
Example:
silent_uninstall="yes"
DSMRequirement:5.0-4458
FieldName:auto_upgrade_from
Description:Itissettoaversionofyourpackage.Ifyourpackageissettosilent_upgrade="yes"andthevalueisset,Package
Centeronlyupgradesyourpackageautomaticallyfromtheinstalledpackagewiththeversionorthenewerversion.However,ifthe
enduserinstallaolderversionthanit,PackageCenterwon'tupgradeitautomaticallyandtheusermustupgradeitbythemself.
Value:(apackageversion)
DefaultValue:(Emptystring)
Example:
auto_upgrade_from="2.0"
DSMRequirement:5.2-5565
FieldName:offline_install
Description:Ifsetto"yes",afterthepackageispublishedinsynologyserver,itwon'tbeshowninthepackagelistofPackage
CenterfromSynologyserver.However,theusercaninstallthepackagemanually.
Value:"yes"/"no"
DefaultValue:"no"
Example:
offline_install="yes"
DSMRequirement:DSM6.0
FieldName:thirdparty
OptionalFields
59
SynologyDSM6.0DeveloperGuide
Description:Ifsetto“yes”,yourpackageisathird-partypackageandisn'tdevelopedbySynology.InPackageCenter,third-pary
pacakgeswillbeshowninanotherpart.
Note:It'snotusedinDSM5.0ornewer.
Value:"yes"/"no"
DefaultValue:"no"
Example:
thirdparty="yes"
DSMRequirement:4.0~4.3
OptionalFields
60
SynologyDSM6.0DeveloperGuide
package.tgz
Thepackage.tgzisacompressedfilecontainingallthefilesyouwouldneedwhenbuildingupyourapplications.Forexample,
executablefiles
libraries
UIfiles
configurationfiles
Youcanusepkg_make_packagefunctiontocreatethepackage.tgz.Formoredetailsabouthowtocreatethepackage.tgz,pleaserefer
to
PackStage:SynoBuildConf/install.
Afteryouinstallyourpackage,PackageCenterwillextractpackage.tgzto@appstorefolder(/volume?/@appstore/withtheassigned
volumeor/usr/local/packages/@appstore/).Inaddition,PackageCenterwillalsocreateasoftlinkin/var/packages/[package
identity]/targetandpointtotheassignedfolder.
Note:
1. InDSM5.2orolder,package.tgzmustbetgzformat.
2. InDSM6.0ornewer,package.tgzcanbetgzorxzformat,butthefilenamemustbepackage.tgz.
package.tgz
61
SynologyDSM6.0DeveloperGuide
scripts
Thisfoldercontainsshellscriptswhichwillbeexecutedduringtheinstallation,un-installation,upgrading,starting,andstoppingof
packages.PackageCenterwillputthescriptsto/var/packages/[packageidentify]/scripts/afterthepackageisinstalled.Thereare
sevenbasicscriptfilesstoredinthescriptsfolder.
1. preinst:Thisscriptisrunbeforethepackagefilesaretransferredto@appstore.Youcancheckiftheinstallationrequirements
meettheDSMorpackageversion,orifsomeservicesareenabledinthisscript.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser(e.g.
echo"Hello!!">$SYNOPKG_TEMP_LOGFILE).YoucanalsowritemessagesintheSYNOPKG_TEMP_LOGFILEfileforzero
returnedvalueswhichrepresentthattheprocesswassuccessful.
2. postinst:Thisscriptisrunafterthepackagefilesaretransferredto@appstore.Youcanchangethefilepermissionandownership
inthisscript.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser(e.g.
echo"Hello!!">$SYNOPKG_TEMP_LOGFILE).YoucanalsowritemessagesintheSYNOPKG_TEMP_LOGFILEfileforzero
returnedvalueswhichrepresentthattheprocesswassuccessful.
3. preuninst:Thisscriptisrunbeforethepackageisremoved.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser(e.g.
echo"Hello!!">$SYNOPKG_TEMP_LOGFILE).YoucanalsowritemessagesintheSYNOPKG_TEMP_LOGFILEfileforzero
returnedvalueswhichrepresentthattheprocesswassuccessful.
4. postuninst:Thisscriptisrunafterthepackageisremovedfromthesystem.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser(e.g.
echo"Hello!!">$SYNOPKG_TEMP_LOGFILE).YoucanalsowritemessagesintheSYNOPKG_TEMP_LOGFILEfileforzero
returnedvalueswhichrepresentthattheprocesswassuccessful.
5. preupgrade:PackageCenterwillcallthisscriptbeforeuninstallingtheoldversionofyourpackage.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser(e.g.
echo"Hello!!">$SYNOPKG_TEMP_LOGFILE).YoucanalsowritemessagesintheSYNOPKG_TEMP_LOGFILEfileforzero
returnedvalueswhichrepresentthattheprocesswassuccessful.
6. postupgrade:PackageCenterwillcallthisscriptafterinstallingthenewversionofyourpackage.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser(e.g.
echo"Hello!!">$SYNOPKG_TEMP_LOGFILE).YoucanalsowritemessagesintheSYNOPKG_TEMP_LOGFILEfileforzero
returnedvalueswhichrepresentthattheprocesswassuccessful.
7. start-stop-status:Thisscriptisusedtostartandstopapackage,detectrunningstatus,andgeneratethelogfile.Parametersused
bythescriptarelistedinbelow:
i. start:Whentheuserclicks"Run"torunthepackageortheNASisturnedon,thePackageCenterwillcallthisscriptwiththe
"start"parameter.Areturnedvaluewillthenbeacquired.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser
(e.g. echo"Startfailed">$SYNOPKG_TEMP_LOGFILE).Youcanalsowritemessagesinthe
SYNOPKG_TEMP_LOGFILEfileforzeroreturnedvalueswhichrepresentthattheprocesswassuccessful.
ii. stop:Whentheuserclicks"Stop"tostoprunningthepackageortheNASisturnedoff,thePackageCenterwillcallthis
scriptwiththe"stop"parameter.Areturnedvaluewillthenbeacquired.
Fornon-zeroreturnedvalues,youcancompileerrormessagesintheSYNOPKG_TEMP_LOGFILEfiletoprompttheuser
(e.g. echo"Stopfailed">$SYNOPKG_TEMP_LOGFILE).YoucanalsowritemessagesintheSYNOPKG_TEMP_LOGFILE
fileforzeroreturnedvalueswhichrepresentthattheprocesswassuccessful.
iii. status:WhenPackageCenterisopenedtocheckpackagestatus,itwillsendarequesttoaskthestatusofthepackageusing
thisparameter.Thefollowingexitstatuscodesshouldbereturned:
scripts
62
SynologyDSM6.0DeveloperGuide
0:packageisrunning.
1:programofpackageisdeadand/var/runpidfileexists.
2:programofpackageisdeadand/var/locklockfileexists
3:packageisnotrunning
4:packagestatusisunknown
150:packageisbrokenandshouldbereinstalled.Pleasenote,brokenstatus(150)isonlysupportedbyDSM4.2andlater.
iv. log:WhenalogpageisopenedinPackageCenter,PackageCenterwillsendarequesttoaskthelogofthepackageusingthis
parameter.WhenthelogfilenameissenttoSTDOUT,thecontentofthelogfilewillbedisplayed.
v. prestart:IfprecheckstartstopinINFOissetto"yes",itisrunforcheckingifit'sallowedtotheendusertostartyour
packageinsomesituationsornot.Forzeroreturnedvalue,theendusercanstartyourpackage.Fornon-zeroreturnedvalues,
theenduserisn'tallowedtostartyourpackageandyoucancompileerrormessagesintheSYNOPKG_TEMP_LOGFILE
filetoprompttheuser(e.g. echo"Startfailed">$SYNOPKG_TEMP_LOGFILE)
Note:
i. ItonlyworksinDSM6.0ornewer.
ii. Itwon'trunafterstartingapackageatbootingup.
vi. prestop:IfprecheckstartstopinINFOissetto"yes",itisrunforcheckingifit'sallowedtotheendusertostopyour
packageinsomesituationsornot.Forzeroreturnedvalue,theendusercanstopyourpackage.Fornon-zeroreturnedvalues,
theenduserisn'tallowedtostopyourpackageandyoucancompileerrormessagesintheSYNOPKG_TEMP_LOGFILE
filetoprompttheuser(e.g. echo"Stopfailed">$SYNOPKG_TEMP_LOGFILE)
Note:
i. ItonlyworksinDSM6.0ornewer.
ii. Itwon'trunbeforestoppingapackageatshuttingdown.
Toinstallapackage:
preinst
postinst
start-stop-statuswithprestartargumentifenduserchoosestostartitimmediately
start-stop-statuswithstartargumentifenduserchoosestostartitimmediately
Toupgradeapackage:
start-stop-statuswithprestopargumentifithasbeenstarted
start-stop-statuswithstopargumentifithasbeenstarted
preupgrade
preuninst
postuninst
preinst
postinst
postupgrade
start-stop-statuswithprestartargumentifitwasstartedbeforebeingupgraded
start-stop-statuswithstartargumentifitwasstartedbeforebeingupgraded
Touninstallapackage:
start-stop-statuswithprestopargumentifithasbeenstarted
start-stop-statuswithstopargumentifithasbeenstarted
preuninst
postuninst
Tostartapackage:
scripts
63
SynologyDSM6.0DeveloperGuide
start-stop-statuswithprestartargument
start-stop-statuswithstartargument
Tostopapackage:
start-stop-statuswithprestopargument
start-stop-statuswithstopargument
Note:start-stop-statuswithprestartorprestopargumentisonlysupportedinDSM6.0ornewer.
scripts
64
SynologyDSM6.0DeveloperGuide
ScriptEnvironmentVariables
SeveralvariablesareexportedbyPackageCenterandcanbeusedinthescripts.Descriptionsofthevariablesaregivenasbelow:
SYNOPKG_PKGNAME:PackageidentifywhichisdefinedinINFO.
SYNOPKG_PKGVER:PackageversionwhichisdefinedinINFO.
SYNOPKG_PKGDEST:Targetdirectorywherethepackageisstored.
SYNOPKG_PKGDEST_VOL:Targetvolumewherethepackageisstored.
Note:It'sonlyavailableinDSM4.2orabove.
SYNOPKG_PKGPORT:adminportportwhichisdefinedinINFO.Thisportwillbeoccupiedbythispackagewithits
managementinterface.
SYNOPKG_PKGINST_TEMP_DIR:Thetemporarydirectorywherethepackageareextractedwheninstallingorupgradingit.
SYNOPKG_TEMP_LOGFILE:Atemporaryfilepathforascripttologinformationorerrormessages.
SYNOPKG_TEMP_UPGRADE_FOLDER:Thetemporarydirectorywhenthepackageisupgrading.Youcanmovethefiles
fromthepreviousversionofthepackagetoitinpreupgradescriptandmovethembackinpostupgrade.
Note:It'sonlyavailableinDSM6.0orabove.
SYNOPKG_DSM_LANGUAGE:Enduser'sDSMlanguage.
SYNOPKG_DSM_VERSION_MAJOR:Enduser’smajornumberofDSMversionwhichisformattedas[DSMmajornumber].
[DSMminornumber]-[DSMbuildnumber].
SYNOPKG_DSM_VERSION_MINOR:Enduser’sminornumberofDSMversionwhichisformattedas[DSMmajornumber].
[DSMminornumber]-[DSMbuildnumber].
SYNOPKG_DSM_VERSION_BUILD:Enduser’sDSMbuildnumberofDSMversionwhichisformattedas[DSMmajor
number].[DSMminornumber]-[DSMbuildnumber].
SYNOPKG_DSM_ARCH:Enduser’sDSMCPUarchitecture.PleasereferAppendixA:PlatformandArchValueMappingTable
tomoreinformation
SYNOPKG_PKG_STATUS:Packagestatuspresentedbythesevalues:INSTALL,UPGRADE,UNINSTALL,START,STOPor
empty.
1. INSTALLwillbesetasthestatusvalueinthepreinstandpostinstscriptswhilethepackageisinstalling.Iftheuserchooses
to“startafterinstallation”atthelaststepoftheinstallationwizard,thevaluewillbesettoINSTALLinthestart-stop-status
scriptwhenthepackageisstarted.
2. UPGRADEwillbesetasthestatusvalueinthepreupgrade,preuninst,postunist,preinst,postinstandpostupgrade
scriptssequentiallywhilethepackageisupgrading.Ifthepackagehasalreadystartedbeforeupgrade,thevaluewillbesetto
UPGRADEinthestart-stop-statusscriptwhenthepackageisstartedorstopped.
3. UNINSTALLwillbesetasthestatusvalueinthepreuninstandpostunistscriptswhilethepackageisun-installing.Ifthe
packagehasalreadystartedbeforeun-installation,thevaluewillbesettoUNINSTALLinthestart-stop-statusscriptwhen
thepackageisstopped.
4. IftheuserstartsorstopsapackageinthePackageCenter,STARTorSTOPwillbesetasthestatusvalueinthestart-stopstatusscript.
5. WhentheNASisbootinguporshuttingdown,itsstatusvaluewillbeempty.
Note:SYNOPKG_PKG_STATUSisonlyavailableforthestart-stop-statusscriptinDSM4.0orabove.
SYNOPKG_OLD_PKGVER:ExistingpackageversionwhichisdefinedinINFO(onlyinpreupgradescript).
SYNOPKG_TEMP_SPKFILE:ThelocationofpackagespkfileistemporarilystoredinDSwhenthepackageis
installing/upgrading.
Note:It'sonlyavailableinDSM4.2orabove.
SYNOPKG_USERNAME:Theusernamewhoinstalls,upgrades,uninstalls,startsorstopsthepackage.Ifthevalueisempty,the
actionistriggeredbyDSM,notbytheenduser.
Note:It'sonlyavailableinDSM5.2orabove.
SYNOPKG_PKG_PROGRESS_PATH:Atemporaryfilepathforascripttoshowingtheprogressininstallingandupgradinga
package.
ScriptEnvironmentVariables
65
SynologyDSM6.0DeveloperGuide
Note:
1. Theprogressvalueisbetween0and1.
2. It'sonlyavailableinDSM5.2orabove.
3. Example:
flock-x"$SYNOPKG_PKG_PROGRESS_PATH"-cecho0.80>"$SYNOPKG_PKG_PROGRESS_PATH"
OncetheenduserentersorselectssomevaluesoftheUIcomponentswhichareconfiguredin
install_uifile(.sh)/upgrade_uifile(.sh)/uninstall_uifile(.sh)(PleaserefertoWIZARD_UIFILESsectionformoreinformation),the
namesandvaluesofthecomponentswillbesetintheenvironmentvariables.Alsonotethatthenamesofthesecomponentscannotbe
thesameasthoseoftheenvironmentvariables.
ScriptEnvironmentVariables
66
SynologyDSM6.0DeveloperGuide
conf
The“conf”foldercontainsspecialconfigurationsincludingsomeinformationwhichcannotbedescribedintheINFOfilewithkey/pair
format.PackageCentercontrolstheflowofinstallation,upgrading,un-installation,starting,andstoppingprocessesaccordingtothese
configurations.
InDSM4.2,therearetwoconfigurations,PKG_DEPSandPKG_CONX,whicharestoredinthisfolder.Theyareusedtodefine
dependencyorconflictbetweenthepackages.Thedependencyorconflictwillbecheckedaccordingtotheenduser’sDSMversion.For
example,PerlwasbuiltonDSM4.1,butitdoesnotexistonDSM4.2.Therefore,ifyourpackagedependsonPerl,thePerlpackage
mustbeinstalledonDSM4.2beforeyourpackagecanbeinstalled.YoucansetthePKG_DEPSconfigurationtoindicatethatthe
dependencyruleonlyworksonDSM4.2orlater.
Thedependencyorconflictissimilartoinstall_dep_packagesandinstall_conflict_packageskeysinINFOfile,buttheydonotdefine
therestrictionaccordingtospecificDSMversions.
PKG_DEPSandPKG_CONXalwayshavehigherprioritycomparedwiththekeysintheINFOfile.Thatis,ifyoudefinedependency
inthePKG_DEPSfile,thentheinstall_dep_packageskeyintheINFOfilewillbeignoredinDSM4.2orlater.Ifyoudefinethe
conflictinthePKG_CONXfile,thentheinstall_conflict_packageskeyintheINFOfilewillbeignoredinDSM4.2orlater.
Theconffoldercontainsthefollowingfiles:
File/Folder
Name
File/Folder
Type
DSM
Requirement
PKG_DEPS
DefinedependencybetweenpackageswithrestrictionsofDSMversion.
Beforeyourpackageisinstalledorupgraded,thesepackagesmustbe
installedfirst.PackageCentercontrolstheorderofstartorstoppackages
accordingtothedependency.
File
4.2-3160
PKG_CONX
DefineconflictsbetweenpackageswithrestrictionsofDSMversion.
Beforeyourpackageisinstalledorupgraded,theseconflictingpackages
cannotbeinstalled.
File
4.2-3160
Description
Note:Allwordsarecasesensitive.
Eachconfigurationfileisdefinedinstandard.inifileformatwithkey/valuepairsandsessions,forexample:
[session]
Asessiondescribesauniquenameofdependent/conflictingpackage.Eachsessioncontainsinformationabouttherequirementsof
packageversionsandtherestrictionofDSMversions.
KeysconfiguredinPKG_DEPSfileeachdependentpackage(session)contains:
Key
Description
Value
pkg_min_ver
Minimumversionofdependentpackage.Youmustinstallthisdependent
packagewiththisversionornewerbeforeinstallingyourpackage.
Packageversion
pkg_max_ver
Maximumversionofdependentpackage.Youmustinstallthisdependent
packagewiththeversionorolderbeforeinstallingyourpackage.
Packageversion
dsm_min_ver
MinimumrequiredDSMversion.Ifyouhavethisversionornewerof
DSM,thisdependencywillbeconsidered,butitwillbeignoredinanolder
DSM.
X.Y-Z
DSMmajornumber,DSM
minornumber,DSMbuild
number
dsm_max_ver
MaximumrequiredDSMversion.Ifyouhavethisversionorolderof
DSM,thisdependencywillbeconsidered,butitwillbeignoredinanewer
DSM.
X.Y-Z
DSMmajornumber,DSM
minornumber,DSMbuild
number
conf
67
SynologyDSM6.0DeveloperGuide
Example:
#YourpackagedependsonPackageAinanyversion
[PackageA]
#YourpackagedependsonPackageBversion2ornewer
pkg_min_ver=2
#YourpackagedependsonPackageCwithversion2orolder
[PackageC]
pkg_max_ver=2
#YourpackagedependsonPackageDwithversion2orolderbutitwillbeignoredwhenDSMversionisolderthan4.1-2668
[PackageD]
dsm_min_ver=4.1-2668
pkg_min_ver=2
#YourpackagedependsonPackageEwithversion2ornewerbutitwillbeignoredwhenDSMversionisnewerthan4.1-2668
[PackageE]
dsm_max_ver=4.1-2668
pkg_min_ver=2
KeysconfiguredinPKG_CONXfileeachconflictingpackage(session)contain:
Key
Description
Value
pkg_min_ver
Minimumversionofconflictingpackage.Ifenduserinstallsthisconflicting
packagewiththespecifiedversionornewer,hewillnotbeabletoinstallyour
package.
PackageVersion
pkg_max_ver
Maximumversionofconflictingpackage.Ifenduserinstallsthisconflicting
packagewiththespecifiedversionorolder,hewillnotbeabletoinstallyour
package.
PackageVersion
dsm_min_ver
MinimumrequriedDSMversion.Ifenduserhasthespecifiedversionor
newerofDSM,thisconflictwillbeconsidered,butitwillbeignoredinolder
versionsofDSM.
X.Y-Z
DSMmajornumber,DSM
minornumber,DSMbuild
number
dsm_max_ver
MaximumrequriedDSMversion.Iftheenduserhasthespecifiedversionor
olderofDSM,thisconflictwillbeconsidered,butitwillbeignoredinnewer
DSM.
X.Y-Z
DSMmajornumber,DSM
minornumber,DSMbuild
number
Example:
#YourpackageconflictswithPackageAinanyversion
[PackageA]
#YourpackageconflictswithPackageBversion2ornewer
[PackageB]
pkg_min_ver=2
#YourpackageconflictswithPackageCversion2orolder
[PackageC]
pkg_max_ver=2
#YourpackageconflictswithPackageDversion2orolder,butitwillbeignoredwhenDSMversionisolderthan4.1-2668
[PackageD]
dsm_min_ver=4.1-2668
pkg_min_ver=2
#YourpackageconflictonPackageEwithversion2ornewerbutitwillbeignoredwhenDSMversionisnewerthan4.1-2668
[PackageE]
dsm_max_ver=4.1-2668
pkg_min_ver=2
conf
68
SynologyDSM6.0DeveloperGuide
conf
69
SynologyDSM6.0DeveloperGuide
WIZARD_UIFILES
install_uifile,upgrade_uifile,anduninstall_uifilearefileswhichdescribeUIcomponentsinJSONformat.Theyarestoredinthe
“WIZARD_UIFILES”folder.Duringtheinstallation,upgrading,andun-installationprocesses,theseUIcomponentswillappearinthe
wizard.Oncethesecomponentsareselected,theirkeyswillbesetinthescriptenvironmentvariableswithtrue,false,ortextvalues.
Thesefilescanberegardedasusersettingsorusedtocontroltheflowofscriptexecution.
install_uifile:DescribesUIcomponentsfortheinstallationprocess.Duringtheprocessofthepreinstandpostinstscripts,these
componentkeysandvaluescanbefoundintheenvironmentvariables.
upgrade_uifile:DescribesUIcomponentsfortheupgradeprocess.Duringtheprocessofthepreupgrade,postupgrade,
preuninst,postuninst,preinstandpostinstscripts,thesecomponentkeysandvaluescanbefoundintheenvironmentvariables.
uninstall_uifile:DescribesUIcomponentsfortheun-installationprocess.Duringtheprocessofthepreuninstandpostuninst
scripts,thesecomponentkeysandvaluescanbefoundintheenvironmentvariables.
Ifyouwouldliketorunascripttogeneratethewizarddynamically,youcanaddinstall_uifile.sh,upgrade_uifile.shand
uninstall_uifile.shfiles,theyarerunbeforeinstalling,upgrading,anduninstallingapackagerespectivelytogenerateUIcomponentsin
JSONformatandwritetoSYNOPKG_TEMP_LOGFILE.Scriptenvironmentvariablesinthesescriptscanbegotteninthesescripts.
Pleasereferto"ScriptEnvironmentVariables"formoreinformation.
IfyouwouldliketolocalizethedescriptionsofUIcomponents,youcanaddalanguageabbreviationsuffixtothefile
“install_uifile_[DSMlanguage],”“upgrade_uifile_[DSMlanguage]”,“uninstall_uifile_[DSMlanguage]”,“install_uifile_[DSM
language].sh,”“upgrade_uifile_[DSMlanguage].sh”or“uninstall_uifile_[DSMlanguage].sh”inthisfolder.Forexample,inorder
toperforminstallationinTraditionalChinese,[DSMlanguage]shouldbereplacedwith“cht”asfollows:“install_uifile_cht”.
ExampleofthefileinJSONformat:
[{
"step_title":"Step1",
"items":[{
"type":"singleselect",
"desc":"aradiogroup",
"subitems":[{
"key":"radio1",
"desc":"Radiobutton1",
"defaultVaule":false
},{
"key":"radio2",
"desc":"Radiobutton2",
"defaultVaule":true
}]
}]
},{
"step_title":"Step2",
"items":[{
"type":"multiselect",
"desc":"acheckgroup",
"subitems":[{
"key":"check1",
"desc":"Checkbutton1"
},{
"key":"check2",
"desc":"Checkbutton2",
"defaultVaule":true,
"validator":{
"fn":"{varv=arguments[0];if(!v)return'Checkthis';returntrue;}"
}
}]
},{
"type":"textfield",
"desc":"textfield",
"subitems":[{
"key":"textfield1",
WIZARD_UIFILES
70
SynologyDSM6.0DeveloperGuide
"desc":"textfield1",
"defaultVaule":"default",
"validator":{
"allowBlank":false,
"minLength":2,
"maxLength":10
}
},{
"key":"textfield2",
"desc":"textfield2",
"emptyText":"abc1@cde.com",
"validator":{
"vtype":"email",
"regex":{
"expr":"/[0-9]/i",
"errorText":"Error"
}
}
}]
}]
},{
"step_title":"Step3",
"invalid_next_disabled":true,
"activeate":"{console.log('activeate',arguments);}",
"deactivate":"{console.log('deactivate',arguments);}",
"items":[{
"type":"singleselect",
"desc":"Checkit",
"subitems":[{
"key":"id1",
"desc":"Notchooseit",
"defaultValue":true
},
{
"key":"id2",
"desc":"Chooseit",
"defaultValue":false,
"validator":{
"fn":"{returnarguments[0];}"
}
}]
}]
}]
ExampleofusingascripttogenerateafileinJSONformat:
WIZARD_UIFILES
71
SynologyDSM6.0DeveloperGuide
#!/bin/sh
/bin/cat>/tmp/wizard.php<<'EOF'
<?php
$ini_array=parse_ini_file("/etc.defaults/synoinfo.conf");
$unique=$ini_array["unique"];
echo<<<EOF
[{
"step_title":"Step1",
"items":[{
"type":"textfield",
"desc":"modelname",
"subitems":[{
"key":"pkgwizard_db_name",
"desc":"name",
"defaultValue":"$unique"
}]
},{
"type":"combobox",
"desc":"Pleaseselectavolume",
"subitems":[{
"key":"volume",
"desc":"volumename",
"displayField":"display_name",
"valueField":"volume_path",
"editable":false,
"mode":"remote",
"api_store":{
"api":"SYNO.Core.Storage.Volume",
"method":"list",
"version":1,
"baseParams":{
"limit":-1,
"offset":0,
"location":"internal"
},
"root":"volumes",
"idProperty":"volume_path",
"fields":["display_name","volume_path"]
},
"validator":{
"fn":"{console.log(arguments);returntrue;}"
}
}]
}]
}];
EOF;
?>
EOF
/usr/bin/php-n/tmp/wizard.php>$SYNOPKG_TEMP_LOGFILE
rm/tmp/wizard.php
exit0
HerearethepropertiesforeachstepinthewizardinJSONformat:
WIZARD_UIFILES
72
SynologyDSM6.0DeveloperGuide
Property
Description
step_title
DSM
Requirement
Optional.Describesthetitleofthecurrentstepperformedinthewizard.
3.2-1922
items
Describesanarraycontainingthecomponentsof“singleselect”,“multiselect”,
“textfield”,“password”,or“combobox”type.
3.2-1922
type
Mustbe“singleselect”,“multiselect”,“textfield”“password”or“combobox”.
“singleselect”typerepresentsthecomponentsinthesub-itemswhichareallradio
buttons.Youcanselectonlyoneradioboxwithauniquekey.
“multiselect”typerepresentsthecomponentsinthesub-itemswhichareall
checkboxes.Youcancheckmorethanonecheckbox.
“textfield”typerepresentsthecomponentsinthesub-itemswhicharealltext
fields.Youcantypetext.
“password”typerepresentsthecomponentsinthesub-itemswhichareall
passwordfields.Youcantypepasswords.
“combobox”typerepresentsthecomponentsinthesub-itemswhichareall
comboboxfields.Theusercanchooseaiteminthecomboboxfield.
Note:“combobox”typeisonlyavailableinDSM5.2ornewer.
3.2-1922
desc
Optional.Describeacomponentinthelabeltext.
3.2-1922
subitems
Describeanarraycontainingradiobuttons,checkboxes,textfields,orpassword
components.
3.2-1922
activeate
JSON-stylestringtodescribeafunctionwhichisrunafterthestepofthewizard
hasbeenvisuallyactivated.
5.2
deactivate
JSON-stylestringtodescribeafunctionwhichisrunafterthestepofthewizard
hasbeenvisuallydeactivated.
5.2
Ifsettotrue,thenextbuttoninthestepofthewizardwillbedisabledbydefault.It
willbeenabledifallitemsarevalidatedscucuessfullybyvalidatorinthisstep.
5.2
invalid_next_disabled
HerearethepropertiesforcomponentsinsubitemsinJSONformat:
Property
Description
DSM
Requirement
AuniquecomponentkeyvaluerepresentsaUIcomponent.Ifyouselectacomponent,this
keywillbesetinthescriptenvironmentvariablesofpreinst,postinst,preupgrade,
postupgrade,preuninst,postuninst,start-stop-status(thestringvalueoftheselected
checkboxorradiobuttonisalways“true”.).
3.2-1922
Optional.true/falsevaluetoinitialize“singleselect”or“multiselect”component,orastring
valuetoinitialize“textfield”or“password”component.
4.2-3160
Optional.Theprompttexttoplaceintoanempty“textfield”or“password”componentto
prompttheuserhowtofillinifdefaultVauleisnotset.
4.2-3160
validator
JSON-styleobjecttodescribevalidationfunctions.Ifthevalidationfailswiththeuser's
value,theusercannotgotothenextstepofthewizard.Moredetailedpropertiesof
validatoraregiveninthevalidatortable.
4.2-3160
disabled
truetodisablethefield(defaultstofalse).
6.0
height
Theheightofthiscomponentinpixels.
6.0
hidden
truetohidethiscomponent.
6.0
Theerrortexttousewhenmarkingafieldinvalidandnomessageisprovided.
6.0
truetodisablemarkingthefieldinvalid.Defaultstofalse.
6.0
Thewidthofthiscomponentinpixels.
6.0
key
defaultVaule
emptyText
invalidText
preventMark
width
Herearethepropertiesofvalidator:
WIZARD_UIFILES
73
SynologyDSM6.0DeveloperGuide
Property
Description
Value
allowBlank
Specifyfalsetovalidatethatthevalue'slengthof“textfield”or“password”componentis>0
true/false
minLength
Minimumlengthof“textfield”or“password”component
Number
maxLength
Maximumlengthof“textfield”or“password”component
Number
vtype
Specifypre-definedvalidationfunction,
"alpha":validatealphavalue
"alphanum":validatealphanumericvalue
"email":validateemailaddress
"url":validateURL
"alpha",
"alphanum",
"email",
"url"
regex
Describevalidationfunctioninregularexpressionandinvalidmessage.Propertiescontain:
"expr":JavascriptRegularExpression
"errorText":invalidstring
JSON-style
object
fn
DescribetheJavascriptfunctionwhichisencodedbyJSON-stylestringwithcurlybrackets.In
thisfunction,youcanusearguments[0]togetthevalueofthecomponent.Inaddition,this
functionwillreturntrueifthevalueisvalidorasaninvalidstringifthevalueisinvalid.
String
Herearetheotherpropertiesfortextfield,passwordorcomboboxcomponentinsubitemsinJSONformat:
Property
blankText
Description
DSMRequirement
TheerrortexttodisplayiftheallowBlankvalidationfails
6.0
trueifthisfieldshouldautomaticallygrowandshrinktoitscontent
6.0
growMax
Themaximumheighttoallowwhengrowistrue
6.0
growMin
Theminimumheighttoallowwhengrowistrue
6.0
falsetoskipHTML-encodingthetextwhenrenderingit(defaultstofalse).
6.0
maxLengthText
ErrortexttodisplayifthemaximumlengthvalidationusingmaxLengthfails.
6.0
minLengthText
ErrortexttodisplayiftheminimumlengthvalidationusingminLengthfails.
6.0
grow
htmlEncode
HerearethepropertiesforcomboboxcomponentinsubitemsinJSONformat:
Property
Description
DSM
Requirement
JSON-styleobjecttodescribetosendaWebAPIrequestandstoretheresponseinthe
datastrustureforcomboboxuse.Moredetailedpropertiesofapi_storearegiveninthe
storetable.
Example:
{
api_store
"api":"SYNO.Core.XXX",
"method":"list",
"version":1,
"baseParams":{
"offset":0,
"limit":-1,
},
"root":"items",
"idProperty":"name",
"fields":["name"]
6.0
}
autoSelect
displayField
editable
forceSelection
WIZARD_UIFILES
truetoselectthefirstresultgatheredbythedatastore(defaultstotrue).Afalsevalue
wouldrequireamanualselectionfromthedropdownlisttosetthecomponentsvalue.
6.0
Theunderlyingdatafieldnametobindtothiscombobox.
6.0
falsetopreventtheuserfromtypingtextdirectlyintothefield,thefieldwillonly
respondtoaclickonthetriggertosetthevalue.(defaultstotrue).
6.0
truetorestricttheselectedvaluetooneofthevaluesinthelist,falsetoallowtheuserto
setarbitrarytextintothefield(defaultstofalse).
6.0
74
SynologyDSM6.0DeveloperGuide
handleHeight
Theheightinpixelsofthedropdownlistresizehandleifresizableistrue.
6.0
Avalidanchorpositionvalue.
6.0
Theemptytexttodisplayinthedataviewifnoitemsarefound.
6.0
Thewidthofthedropdownlist.
6.0
maxHeight
Themaximumheightinpixelsofthedropdownlistbeforescrollbarsareshown.
6.0
minChars
Theminimumnumberofcharacterstheusermusttypebeforeautocompleteand
typeAheadactivate
6.0
minHeight
Theminimumheightinpixelsofthedropdownlistwhenthelistisconstrainedbyits
distancetotheviewportedges.
6.0
Theminimumwidthofthedropdownlistinpixels.
6.0
listAlign
listEmptyText
listWidth
minListWidth
Setto'loacl'toloadlocalstoretoloadlocalJSON-arraydata.Moredetailedproperties
oflocalstorearegiveninthestoretable.
Example:
{
mode
"mode":"local",
"valueField":"myId",
"displayField":"displayText",
"store":{
"xtype":"arraystore",
"fields":["myId","displayText"],
"data":[[1,"item1"],[2,"item2"]]
}
6.0
}
pageSize
Ifgreaterthan0,apagingtoolbarisdisplayedinthefooterofthedropdownlistandthe
filterquerieswillexecutewithpagestartandlimitparameters.Onlyapplieswhenusing
api_store(defaultsto0).
6.0
queryDelay
Thelengthoftimeinmillisecondstodelaybetweenthestartoftypingandsendingthe
querytofilterthedropdownlist.
6.0
truetoaddaresizehandletothebottomofthedropdownlist(Defaultstofalse).
6.0
truetoselectanyexistingtextinthefieldimmediatelyonfocus.Onlyapplieswhen
editableistrue(defaultstofalse).
6.0
store
Adatastructuretostoredataincombobox(defaultstoundefined).Itcan'tbeusedwith
api_storeatthesametime.Acceptablevaluesforthispropertyare:
1-dimensionalarray:e.g., ["Foo","Bar"]
2-dimensionalarray:Fora2-dimensionalarray,thevalueinindex0ofeachitemwill
beassumedtobethevalueField,whilethevalueatindex1isassumedtobethe
displayField,e.g., [["f","Foo"],["b","Bar"]].
6.0
title
Ifsupplied,aheaderelementiscreatedcontainingthistextandaddedintothetopofthe
dropdownlist
6.0
typeAhead
truetopopulateandautoselecttheremainderofthetextbeingtypedafteraconfigurable
delay(typeAheadDelay).
6.0
Thelengthoftimeinmillisecondstowaituntilthetypeaheadtextisdisplayed.
6.0
Theunderlyingdatavaluenametobindtothiscombobox.
6.0
resizable
selectOnFocus
typeAheadDelay
valueField
Herearethepropertiesforapi_storeorstoredatastructureinJSONformat:
WIZARD_UIFILES
75
SynologyDSM6.0DeveloperGuide
Property
Description
DSM
Requirement
AnobjectcontainingpropertieswhicharetobesentasparametersforeveryWebAPI
requestinapi_store.
6.0
AninlinedataobjectreadablebythereaderinlocalstoretoloadlocalJSON-arraydata.
6.0
displayField
Theunderlyingdatafieldnametobindtothiscombobox.
6.0
fields
definedfieldsforthedatastoredinthisstoreorapi_store.
6.0
Identityofthepropertywithindatathatcontainsauniquevalue.
6.0
Thenameofthepropertywhichcontainsthearrayofdata.Defaultstoundefined.
6.0
Theunderlyingdatavaluenametobindtothiscombobox.
6.0
OnlysupportarraystoretypeforlocalstoretoloadlocalJSON-arraydata.
6.0
baseParams
data
idProperty
root
valueField
xtype
Note:
1. Allwordsarecasesensitive.
2. InDSM4.0orabove,ifboththetypeandsubitemspropertiesareempty,textinthedescpropertywillbedisplayedasone
ofthestepsofwizard.
3. install_uifile.sh,upgrade_uifile.sh,uninstall_uifile.shand*.shscriptstogernatethewizarddynamicallyareonlysupported
inDSM5.2ornewer.
WIZARD_UIFILES
76
SynologyDSM6.0DeveloperGuide
IntegrateYourPackageintoDSM
IntegrateYourPackageintoDSM
77
SynologyDSM6.0DeveloperGuide
ManageStorageforApplicationFiles
Whenapackageisinstalling,package.tgzwillbeextractedto/var/packages/[packageidentity]/target,whichisasymboliclink
pointingtoafolderinadatavolumeselectedbytheenduser./var/packages/[packageidentity]/targetisalsoavailableatthe
SYNOPKG_PKGDESTenvironmentvariable,oneofthesevenfilesinthescriptfolder.Pleaseseethe"scripts"formoreinformation.
Despitethefactthatthedirectory/var/packagesor/usr/localisreservedfor3rd-partyapplications,thestoragespaceofsystemvolume
islimited.Ifthesizeoffilestobeinstalledexceedsthecapacityofthesystemvolume,storagespacewillrunout.Hence,itis
recommendedthatyoudirectlyreadorwriteapplicationfilesin/var/packages/[packageidentity]/targetoranotherspaceofthedata
volume.Youcanalsomakeasymboliclinkin/usr/localtopointto/var/packages/[packageidentity]/targetoranotherspacewhen
runningthepostinstscript.Thepathcanbeaccessedeasierinalibraryoradaemon.Pleasenotethatyoumayneedtospecifythe
correctprefixwhenrunningaconfigurationscriptsothattheapplicationcanfindthecorrectpathinformationuponexecution.
SynologyreleasesDSMupdatesonaregularbasis.Giventhatapplicationfilesmightbeaffectedduringtheupdateprocedure,itis
importantthatyouinstallyourapplicationinthecorrectdirectorytopreventthemfrombeingdeletedwhenDSMisbeingupgradedin
thesystempartition.
WhenDSMisbeingupgraded,thedirectory/var/packages/[packageidentity]and/usr/localwillbebackedupandrestored
automatically.However,somelibraryfilesorbuilt-insoftwaremightbemodifiedduringtheupgradeprocedure.Inotherwords,ifyour
applicationdependsonthefileswhicharesubjecttochange,theapplicationmaynotworkafterward.Inthiscase,youshouldcheckthe
statusofthesefilesorre-linktheminthestart-stop-statusscripttorepairthemifnecessary.Alternatively,youcaninstallthemdirectly
to/var/packages/[packageidentity]/target.
ManageStorageforApplicationFiles
78
SynologyDSM6.0DeveloperGuide
IntegrateYourPackageintoDSMWebGUI
WithSynologyDSM,integrating3rd-partyapplicationsintoyourNASiseasy.Whenanapplicationisintegrated,itsiconwillappear
intheMainMenuofDSM.Userscanalsousetheirowncustomizediconsfortheseapplications.ToplaceanicononDSMdesktop,
simplydraganddropitfromtheMainMenutotheDSMdesktop.
IntegrateYourPackageintoDSMWebGUI
79
SynologyDSM6.0DeveloperGuide
Startup
TointegrateanapplicationintoSynologyDSM3.0orlater,pleasefollowthestepsbelow:
1. Createafolderunderthedirectory/usr/syno/synoman/webman/3rdparty/.
2. Createatextfilenamed"config"inyourfolder.
3. Underthesamedirectory,createasub-foldernamedafteryourapplication,suchas
/usr/syno/synoman/webman/3rdpaty/[packagename]/.PutallUIrelatedcomponents,suchasimages,CSS,andCGIinthe
directory.
IntheINFOfile,youcandefinethekeydsmuidir,whosevalueisaDSMdirectorynameinthepackage.tgzfile.PackageCenterwill
automaticallylink/unlinkitto/usr/syno/synoman/webman/3rdparty/[packagename]basedonthekeywhenyoustart/stopthe
package.YoushouldalsodefinedsmappnameintheINFOfiletointegratethepackagewithDSMapplications.Pleasereferto
dsmuidiranddsmappnamekeyinOptionalFieldssectionformoreinformationtolinkthefolderautomatically.
NextwewilldiscussthedetailsofUIconfiguration.
Startup
80
SynologyDSM6.0DeveloperGuide
Config
Thetextfile“config”isusedtoconfigureUIbehavior.ThecontentofconfigshouldbeinJSONformat.
Forexample:
{
".url":{
"com.company.App1":{
"type":"url",
"allUsers":true,
"title":"TestApp1",
"desc":"Description",
"icon":"images/app\_{0}.png",
"url":"http://www.yahoo.com"
},
"com.company.App2":{
"type":"legacy",
"allUsers":true,
"title":"TestApp2",
"desc":"Description2",
"icon":"images/app2\_{0}.png",
"url":"http://www.synology.com"
}
}
}
Detailsofapplication.cfgarestatedinbelow.
Config
81
SynologyDSM6.0DeveloperGuide
Property
com.company.App1
com.company.App2
title(Required)
desc
Description
In“.url”,eachobjectshouldhaveauniquepropertyname.
“title”representstheapplicationnamethatwillbedisplayedinthemainmenu.
“desc”displaysmoredetailsaboutthisapplicationuponmouse-over.
icon(Required)
“icon”indicatestheiconfortheapplication.Itisatemplatestring.The“{0}”canbereplacedby“16”,
“24”,“32”,“48”,“64”,“72”,“256”dependingontheresolutionoftheicon.
Theiconmustbesavedunder/usr/syno/synoman/webman/3rdparty/xxx/wherexxxisthedirectory
nameofyourpackage.
Forexample,ifyoucreateadirectorynamed"images"andputtheiconimagefile“icon.png”init,the
fullpathfortheiconwouldbe:
/usr/syno/synoman/webman/3rdparty/xxx/images/icon\_16.png
/usr/syno/synoman/webman/3rdparty/xxx/images/icon\_24.png
/usr/syno/synoman/webman/3rdparty/xxx/images/icon\_32.png
/usr/syno/synoman/webman/3rdparty/xxx/images/icon\_48.png
/usr/syno/synoman/webman/3rdparty/xxx/images/icon\_64.png
/usr/syno/synoman/webman/3rdparty/xxx/images/icon\_72.png
/usr/syno/synoman/webman/3rdparty/xxx/images/icon\_256.png
Theiconvalueshouldalsobesetas"images/icon_{0}.png"
type(Required)
Whenyouclickthemenuitem,theaddressyouusetoconnecttotheDSMmanagementUIwillbe
shownintherightframeofthemanagementUI.However,youcancustomizetheaddressasyouwish.
The“type”valuecanbe"url"or"legacy"."url"meanswhenyouclicktheapplicationicon,theURL
willbeopenedinapop-upwindow,while"legacy"impliesthattheURLwillbeopenedinaniframe
windowapplication.
YoucanfollowthedescriptionsbelowtosetupyourcustomizedURL.
url(Required)
allUsers
Config
ThefollowingisanexampleofvaluesettingforyourURLoftheapplication:
“url”:http://www.synology.com/
“url”:“3rdparty/xxx/index.html”
Thiskeydetermineswhetherornotthemenuitemscanbeseenbyuserswhentheyloginwithanadmin
account.Ifyouwouldliketohaveallusersseethemenuitems,pleasesetthekeyvalueasbelow:
"allUsers":true
Thedefaultsettingisthatonlytheadmincanfindtheapplication.
82
SynologyDSM6.0DeveloperGuide
IntegrateHelpDocumentintoDSMHelp
TointegrateahelpdocumentofyourapplicationintoDSMHelp,pleasedothefollowingsteps:
Classifythehelpdocumentsaccordingtolanguage,andputtheminthehelpfolderofyourapplication.
Tohaveconsistentstyle,andourcustomizedscrollbar,youshouldaddthefollowinghtmltag:
<!DOCTYPEhtml>
<head>
<metacharset="UTF-8"/>
<metahttp-equiv="X-UA-Compatible"content="IE=edge,chrome=1">
<linkhref="../../../../help/help.css"rel="stylesheet"type="text/css">
<linkhref="../../../../help/scrollbar/flexcroll.css"rel="stylesheet"type="text/css">
<scripttype="text/javascript"src="../../../../help/scrollbar/flexcroll.js"></script>
<scripttype="text/javascript"src="../../../../help/scrollbar/initFlexcroll.js"></script>
</head>
Note:Thejsfilesarerequiredbecausethenativebrowserscrollbarhasbeendisabled.
Youwillneedtoaddatextfile"helptoc.conf"intoyourapplication.Thistextfile"helptoc.conf"istoconfigurethestructureof
yourhelpdocument.Thecontentofhelptoc.confshouldbeinJSONformat.Forexample:
{
"app":"SYNO.App.TestAppInstance",
"title":"app_tree:index_title"
"helpset":"help",
"stringset":"texts",
"content":"testapp_index.html",
"toc":[{
"title":"app_tree:node_1"
"content":"testapp_node1.html",
"nodes":[{
"title":"app_tree:node_1_child"
"content":"testapp_node1_child.html"
}]
},{
"title":"app_tree:node_2"
"content":"testapp_node2.html"
}]
}
Detailsofhelptoc.confarestatedinbelow.
Property
Description
stringset
(Required)
"stringset"isthefolderthatstoresyourapplicationstrings.
app
"app"representstheapplicationinstance.
helpset
"helpset"displaysmoredetailsabouttheapplicationuponmouse-over.
title(Required)
"title"isthetextthatwillbedisplayedintheDSMHelptree.Itconsistsoftwoparts-sectionandkey,andis
separatedbyacolon.
content
(Required)
"content"representstheurlofthenode.
toc
"toc"arethechildnodesforyourapplication.(useemptyarrayifyourapplicationdoesn'thaveone)
nodes
"nodes"arethechildnodesoftoc.(notnecessaryifthereisnochildnodes)
IntegrateHelpDocumentintoDSMHelp
83
SynologyDSM6.0DeveloperGuide
Addthefollowingcontenttotheresourcespecificationfile.PleaserefertoIndexDBformoredetail.
"indexdb":{
"app-index":{
"conf-relpath":"ui/index.conf",
"db-relpath":"indexdb/appindexdb"
},
"help-index":{
"conf-relpath":"ui/helptoc.conf",
"db-relpath":"indexdb/helpindexdb"
}
}
IntegrateHelpDocumentintoDSMHelp
84
SynologyDSM6.0DeveloperGuide
IntegratewithDSMWebAuthentication
AfterintegratingyourapplicationintoSynologyDSM,youmaywanttoperformanauthenticationchecktoensureonlylogged-inusers
canaccessthepage.
Tocheckwhetherauserhasloggedin,runtheCGIcommandinbelow.
/usr/syno/synoman/webman/modules/authenticate.cgi
The“authenticate.cgi”willoutputtheusernameiftheuserhasloggedin.Therewillbenooutputiftheuserhasnotbeen
authenticated.
Belowisanexample:
IntegratewithDSMWebAuthentication
85
SynologyDSM6.0DeveloperGuide
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<strings.h>
/**
*Checkwhetheruserisloggedin.
*
*Ifuserhasloggedin,puttheusernameinto"user".
*
*@paramuserThebufferforgetusername
*@parambufsizeThebuffersizeofuser
*
*@return0:Usernotloggedinorerror
*1:Userloggedin.Theusernameiswrittentogiven"user"
*/
intIsUserLogin(char*user,intbufsize)
{
FILE*fp=NULL;
charbuf[1024];
intlogin=0;
bzero(user,bufsize);
fp=popen("/usr/syno/synoman/webman/modules/authenticate.cgi","r");
if(!fp){
return0;
}
bzero(buf,sizeof(buf));
fread(buf,1024,1,fp);
if(strlen(buf)>0){
snprintf(user,bufsize,"%s",buf);
login=1;
}
pclose(fp);
returnlogin;
}
intmain(intargc,char**argv)
{
charuser[256];
printf("Content-type:text/html\r\n\r\n");
if(IsUserLogin(user,sizeof(user))==1){
printf("Userisauthenticated.Name:%s\n",user);
}else{
printf("Userisnotauthenticated.\n");
}
return0;
}
DSMmightrequirearandomvaluecalledSynoTokentopreventaCSRF(cross-siterequestforgery)attackafter4.3.WhenCSRF
protectionisenabledinthecontrolpanel,youmustappendSynoTokentothequerystringorheaderoftheHTTPrequest.
Inthequerystring:
http://192.168.1.1:5000/webman/3rdparty/DownloadStation/webUI/downloadman.cgi?SynoToken=9WuK4Cf50Vw7Q
Intherequestheader:
X-SYNO-TOKEN:9WuK4Cf50Vw7Q
ThevalueofSynoTokencanbeobtainedfromlogin.cgiiftheuserisloggedin.
IntegratewithDSMWebAuthentication
86
SynologyDSM6.0DeveloperGuide
Request:
http://192.168.1.1:5000/webman/login.cgi
Response:
{"SynoToken":"9WuK4Cf50Vw7Q","result":"success","success":true}
IfyourapplicationisbasedonExtJsofDSM,pleaseincludedsmtoken.cgiinyourheadersection.
<header>
<scriptsrc="/webman/dsmtoken.cgi"></script>
</header>
Oncethedsmtoken.cgiisincluded,Ext.Ajax.Request,Ext.data.Connection,Ext.form.basicFormandExt.urlAppendwillappend
SynoTokentotheHTTPrequestautomatically.
<script>
Ext.Ajax.Request({…})//addSynoTokenatevent'beforerequest'
Ext.data.Connection({…})//addSynoTokenatevent'beforerequet'
newExt.form.basicForm({…})//addSynoTokenatevent'beforeaction'
//Ext.urlAppendwilladdSynoTokeninternally
url=Ext.urlAppend('http://192.168.1.1',Ext.urlEncode({…}));
</script>
IntegratewithDSMWebAuthentication
87
SynologyDSM6.0DeveloperGuide
DSMBackwardCompatibility
WeaklinkisapropertyofApple’sdevelopmentframeworkwhichensuresbackwardcompatibility.GCChasasimilarpropertycalled
“weaksymbol.”Weutilizethiscapabilitytoprovideaweaklinkframeworkinlibsynosdkforbackwardcompatibilityaswell.Youcan
findavailableheadersinusr/syno/include/libsynosdkunderchrootenvironment.Eachfunctionprototypeinsynosdk/*_p.hislabeled
withamacrotellingyouwhenthisfunctionisaddedintolibsynosdk.Therefore,youcaninputafunctioninDSM4.2asfollows:
/*DONOTinclude*_p.hdirectly*/
#include<synosdk/user.h>
#include<synosdk/service.h>
/*example,SYNOServiceHomePathCheckisavailablesinceDSM4.2*/
if(SYNOServiceHomePathCheck){
SYNOServiceHomePathCheck(szPath,TRUE,TRUE,&pResult);
}else{
/*implementalternativetoSYNOServiceHomePathCheckhere*/
}
Asaresult,whenyourapplicationrunsinDSM4.2andlater,functionSYNOServiceHomePathCheckinlibsynosdk.soisinvoked.In
DSM4.2andolder,else-partwillbeexecutedasareplacementtoSYNOServiceHomePathCheck.
DSMBackwardCompatibility
88
SynologyDSM6.0DeveloperGuide
ShowMessagestoUsers
Ifyouwanttopromptuserswithamessagebeforetheyinstall,upgrade,orun-installapackageinPackageCenter,youcanwritethese
messagesinthedesckeyininstall_uifile,upgrade_uifile,oruninstall_uifile.Pleasereferto"WIZARD_UIFILES"formore
information.
Ifyouwanttosendapromptmessagetousersaftertheyinstall,upgrade,un-install,start,orstopapackageinPackageCenter,youcan
implementthemintothe$SYNOPKG_TEMP_LOGFILEvariableintherelatedscripts.Forexample,
echo"HelloWorld!!">$SYNOPKG_TEMP_LOGFILE
IfyouwanttopromptusersinthelanguagespecifiedintheirDSMsettings,youcanrefertothe$SYNOPKG_DSM_LANGUAGE
variableforlanguageabbreviationasshowninthescriptsbelow:
ShowMessagestoUsers
89
SynologyDSM6.0DeveloperGuide
case$SYNOPKG_DSM_LANGUAGEin
chs)
echo""
>$SYNOPKG_TEMP_LOGFILE
;;
cht)
echo""
>$SYNOPKG_TEMP_LOGFILE
;;
csy)
echo"Český">$SYNOPKG_TEMP_LOGFILE
;;
dan)
echo"Dansk">$SYNOPKG_TEMP_LOGFILE
;;
enu)
echo"English">$SYNOPKG_TEMP_LOGFILE
;;
fre)
echo"Français">$SYNOPKG_TEMP_LOGFILE
;;
ger)
echo"Deutsch">$SYNOPKG_TEMP_LOGFILE
;;
hun)
echo"Magyar">$SYNOPKG_TEMP_LOGFILE
;;
ita)
echo"Italiano">$SYNOPKG_TEMP_LOGFILE
;;
jpn)
echo""
>$SYNOPKG_TEMP_LOGFILE
;;
krn)
echo""
>$SYNOPKG_TEMP_LOGFILE
;;
nld)
echo"Nederlands">$SYNOPKG_TEMP_LOGFILE
;;
nor)
echo"Norsk">$SYNOPKG_TEMP_LOGFILE
;;
plk)
echo"Polski">$SYNOPKG_TEMP_LOGFILE
;;
ptb)
echo"PortuguêsdoBrasil">$SYNOPKG_TEMP_LOGFILE
;;
ptg)
echo"PortuguêsEuropeu">$SYNOPKG_TEMP_LOGFILE
;;
rus)
echo"Русский">$SYNOPKG_TEMP_LOGFILE
;;
spn)
echo"Español">$SYNOPKG_TEMP_LOGFILE
;;
sve)
echo"Svenska">$SYNOPKG_TEMP_LOGFILE
;;
trk)
echo"Türkçe">$SYNOPKG_TEMP_LOGFILE
;;
*)
echo"English">$SYNOPKG_TEMP_LOGFILE
;;
esac
Pleaseseethe"scripts"and"ScriptEnvironmentVariables"sectionsformoreinformation.
Otherwise,youcanuse/usr/syno/bin/synodsmnotifytosendmessagestoDSMusers.Forexample,thestrings“title”and“messages”
aresenttothe“administrators”group.
ShowMessagestoUsers
90
SynologyDSM6.0DeveloperGuide
synodsmnotify@administratorstitlemessages
ShowMessagestoUsers
91
SynologyDSM6.0DeveloperGuide
CreatePHPApplication
Apache/NginxandPHPengineswhichallowyoutodevelopwebapplicationsandstorefilesinthewebspacetobuildyourown
website.Hence,thesefilesshouldbecompressedintopackage.tgz.Inthestart-stop-statusscript,youshouldlinkorcopythemtothe
webspacewhenstartingapackage.InDSM,thedefaultwebspaceisthewebsharedfolder.Youcangetthepathvia/var/services/web
whichisasymboliclinkpointingtotheactualpathinthevolume.
InDSM5.2orolder,thewebapplicationworksaftertheadministratorenablesWebStation.Youcanconfigurethe
install_dep_servicesandstart_dep_serviceskeyswiththeapache-webvalueintheINFOfiletomakesureWebStationisenabled
beforethepackageinstallation.InDSM6.0ornewer,thewebapplicationworksaftertheadministratorinstallsandstartsWebStation
andPHPpackage.Youcanconfiguretheinstall_dep_packageswith"WebStation:PHP5.6"valueintheINFOfiletomakesure
thesepackagesinstalledandstartedbeforethepackageinstallation.
YoucanthenprovideaURLinordertoaccessyourpagetoadminurl(ex:"/myapp/index.html")inINFOwhichwillbedisplayedin
PackageCentertotelltheclientwhichURLtoopen.Whenthepackagestops,thisURLshouldnotbeaccessible.Youcanremoveor
unlinkthewebsitefolderinthewebspace,orletthewebpageredirecttoanerrorpage.
Inaddition,itisrecommendedtoaddanicontoDSM’smainmenusothatuserscanclicktheicontolaunchtheapplicationintuitively.
TocustomizetheconfigsettingsforApache,NginxorPHP,pleasedonotmodifyanyoftheconfigfilesbelongingtoDSM.Instead,
youshouldcreatesymboliclinksforyourconfigfilesinthecorrespondinglocations.ForApache/Nginx,linkyourconfigtothefolder
/etc/httpd/sites-enabled-user/your_package_name.conf.ForPHP,pleaserefertoPHPINIformoredetail.
Inaddition,addtheapache-webinDSM5.2ororder,ornginxinDSM6.0ornewertothestart_stop_restart_servicestomake
Apache/Nginxreloadconfigfiles.Otherwise,thesesymboliclinksshouldberemovedalongwiththepackage.
Hereisanexampleofapacheconfig:
<Directory"/var/services/photo">
OptionsMultiViews
AllowOverrideNone
Orderallow,deny
Allowfromall
</Directory>
CreatePHPApplication
92
SynologyDSM6.0DeveloperGuide
RunScriptsWhentheSystemBoots
Ifyouwouldliketorunscriptswhenthesystemisbootinguporshuttingdown,youcanwritescriptsinstart-stop-status.Thisscript
willbeexecutedwiththe"start"or"stop"parameter,whenthepackageisenabled.Ifyouwanttoexecuteascriptduringtheboot-upor
shut-downprocess,youcanputastart-upscriptin/usr/local/etc/rc.d/.Belowaretherulesforthestart-upscript:
1. Itmustcontainthesuffix".sh".Forexample,"myprog.sh".
2. Thepermissionmustbe755.
3. Itmustcontaintheoptionsof"start"and"stop".Whenthesystembootsup,itwillcall myprog.shstart;whenitshutsdown,it
willcall myprog.shstop.
RunScriptsWhentheSystemBoots
93
SynologyDSM6.0DeveloperGuide
LocaleSupport
DSMprovideslocalesupportafterversion4.3.YoudonotneedtoaddorremovelocalerelatedfilesontheNASafterthisversion.
LocaleSupport
94
SynologyDSM6.0DeveloperGuide
InstallPackageRelatedPortsInformationintoDSM
Ifyourpackageserviceusesspecificportsforcommunication(e.g.SurveillanceStationusesports19997/udpforsourceportand
19998/udpfordestinationport),youshouldprepareaserviceconfigurationfileforthispackagetodescribewhichportswillbeused.
Afterthat,oncetheusercreatesfirewallrulesorportforwardingrulesfromthebuild-inapplication,yourpackageservicewillalsobe
listedforselection.
ServiceConfigureFileName
ThefilenameshouldfollowthenamingconventionSYNOPKG.sc(ex:SurveillanceStation.sc).SYNOPKGshouldbethepackage
namethatisspecifiedbythekey"package"intheINFOfile,andscmeansServiceConfigurefile.
ConfigureFormatTemplate
Pleaseseethefollowingexample:
[service_name]
title="Englishtitle"
desc="Englishdescription"
port_forward="yes"or"no"
src.ports="ports/protocols"
dst.ports="ports/protocols"
[service_name2]
…
Section/KeyDescriptions
Pleaseseethefollowingstatementsforthestringsandkeys:
InstallPackageRelatedPortsInformationintoDSM
95
SynologyDSM6.0DeveloperGuide
Section/Key
Description
Default
Value
DSM
Requirement
Uniqueservice
name
N/A
4.0-2206
Englishtitle
N/A
4.0-2206
English
description
N/A
4.0-2206
“yes”or“no”
“no”
4.0-2206
ports/protocols
ports:1~65535
(separatedby‘,’
anduse‘:’to
representport
range)
protocols:
tcp,udp
(separatedby
‘,’)
ports:
N/A
protocols:
tcp,udp
4.0-2206
ports/protocols
ports:1~65535
(separatedby‘,’
anduse‘:’to
representport
range)
protocols:
tcp,udp
(separatedby
‘,’)
ports:
N/A
protocols:
tcp,udp
4.0-2206
Value
Required
service_name
Usuallyapackageonlyhasoneuniqueservicename.
Ifyourpackageneedsmorethanoneport
description,youcandefineservice_name2,
service_name3,…
Note:service_namecannotbeemptyandcanonly
includecharacters“a~z”,“A~Z”,“0~9”,“-”,“\”,
“.”
Required
title
EnglishtitlewhichwillbeshownonfieldProtocol
atfirewallbuild-inselectionmenu.
Required
desc
Englishdescriptionwhichwillbeshownonfield
Applicationsatfirewallbuild-inselectionmenu.
Optional
port_forward
Ifsetto“yes,”yourpackageservicerelatedports
willbelistedwhenuserssetportforwardingrule
frombuild-inapplications.Otherwisetheywillnot
belisted.
Optional
src.ports
Ifyourpackageservicehasspecifiedsourceports,
youcansettheminthiskey.Thevalueshould
containatleasttheportnumbers,andadefault
protocolthatistcp+udp.
Ex:6000,7000:8000/tcp,udpmeanssourceportsare
6000,7000to8000,allportsaretcp+udp.
Required
dst.ports
Eachserviceshouldhavedestinationports.The
valueshouldcontainatleasttheportnumbers,anda
defaultprotocolthatistcp+udp.
Ex:6000,7000:8000/tcp,udpmeansdestinationports
are6000,7000to8000,allportsaretcp+udp.
Pleaseseethefollowingexample(SurveillanceStation.sc):
[ss_findhostd_port]
title="SearchSurveillanceStation"
desc="SurveillanceStation"
port_forward="yes"
src.ports="19997/udp"
dst.ports="19998/udp"
Aftertheserviceconfigurationfileisready,addthefollowingcontenttotheresourcespecificationfile.PleaserefertoPortConfigfor
moredetail.
"port-config":{
"protocol-file":"port_conf/xxdns.sc"
}
InstallPackageRelatedPortsInformationintoDSM
96
SynologyDSM6.0DeveloperGuide
InstallPackageRelatedPortsInformationintoDSM
97
SynologyDSM6.0DeveloperGuide
LowerPrivilege
Toreducesecurityrisks,wenowprovideaframeworktorunpackageswithalowerprivileged"packageuser"insteadofroot.Belowis
asummaryofhowtojointheframeworkandwhatpackagecenterdoesforyou:
1. Packagedevelopersprovideprivilegespecificationtospecifywhatprivilegeisneededduringprogramexecution.
2. Duringpackageinstallation,packagecentercreatescorrespondinguserandgroup.SeePackageUser&Groupformoredetail.
3. Accordingtotheprivilegespecification,packagecenter chownfilesunder/var/packages/${package}/target.(The setuidand
setgidbitwillbecleared)
4. Packageexecutablesarerunwithprivilege(packageuser,systemorroot)accordingtoitsfileownerandgroup.SeeMechanism
formoredetail.
Withthisframework,packagedeveloperiscapableof:
Configurewhichexecutableshouldberunwithwhatprivilegewithasimpleprivilegespecificationfile.
ResourceAcquistioncanbeusedtohelpmaintainsomechoresthatrequiresrootprivilege.
Whethertolowerthepackage'sprivilegeandcreatecorrespondinguser/groupisoptional.Thepackagehastoprovideprivilege
specificationtojointhisframework,otherwisethepackagewillstillberunwithrootprivilege,andnouser/groupwillbecreated.
LowerPrivilege
98
SynologyDSM6.0DeveloperGuide
PackageUser&Group
Duringpackageinstallation,packagecenterusesthepackagenametocreateauserandgroupforthepackage.Andtheiruid/gidwill
bethesamenumber,whichliesbetween100000and300000.Failureonuser/groupcreationwillcausepackageinstallationtoabort.If
acustomuserandgroupnameispreferred,seeprivilegespecification.
User&GroupCreation
Newlycreateduserandgroupwillhavethebelowconfiguration:
#/etc/passwd
${package}:x:${uid}:${gid}::/var/packages/${package}/target:/sbin/nologin
#/etc/shadow
${package}:*:10933:0:99999:7:::
#/etc/group
${package}:x:${gid}:
UIBehavior
PackageusersandgroupswillnotappearonmostUIsettings.Includingthefollowing:
Applicationprivilege'spermissionviewer
FPT'schrootuserselector
FileStations's
Changeowner
SharedLinksManager->Enablesecuresharing
Theonlyexceptionsare:
ControlPanel>SharedFolder>Edit>Permission>Systeminternaluser
ACLeditor
CreationPolicy
Whenthepackageuser/groupnameconflictswithalocaluser/group,itwillberenamedbyaddinga$PKG${time}postfixattheend.
Therenamingpolicyisshowedbelow:
PackageUser&Group
99
SynologyDSM6.0DeveloperGuide
PackageUser&Group
100
SynologyDSM6.0DeveloperGuide
Mechanism
Apackagemaycontainmultipleexecutables,eachofthemtriggeredindifferenttimesbytheDSM.Forexample,CGIswillbespawn
bythecgidaemon,andcontrolscripts(preinst,start_stop_status...)willbecalledbypackagecenter.Ourframeworkusestheowner
userandgroupoftheexecutabletodecidewhatuserprivilegetogrant.
Supposetheowneruseris```${package}:
Iftheownergroupis system,thenuse setresuid(-1,${package},-1),whichgivestheprocessabilitytochangeback
toroot```.
Otherwise,use setresuid(${package},${package},${package}),dropitsprivilege.
ASummoryoffileowneruser/groupandgrantedprivilegeisshownbelow:
run-as
owner
euid
ruid
package
${package}:${package}
${package}
${package}
system
${package}:system
${package}
0
root:root
0
0
root
Mechanism
101
SynologyDSM6.0DeveloperGuide
PrivilegeSpecification
Duringpackageinstallation,packagefileswillbe chownwith${package}:${package}.AsmentionedinMechanism,thisresultsin
packageexecutablestoberunas${package}.Butsomeexecutablesmightrequirehigherprivilege.HereweprovideaJsonconfigfile
calledprivilegespecification,locatedintheSPK'sconf/privilege.Thisprivilegespecificationspecifieswhatkindofprivilegethe
executablesneed.
NOTEForpackagesthatdoesnotsupportrunningwithlowerprivileges,simplydonotsupplythisprevilegespecification.Then
packagecenterwillnotapply chownonthefiles.
Thecontentofprivilegespecificationisshownbelow.defaultsspecifiesthedefaultprivilegeanddecideshowtoapplychownon
files.. "username"and groupnameareoptional,usedforcustomuser/groupname.Therestofthekeyisusedtooverwritethe
defaultsetting.
{
"defaults":{
"run-as":"<run-as>"
},
"username":"<username>",
"groupname":"<groupname>",
"ctrl-script":[{
"action":"<action>",
"run-as":"<run-as>"
},...],
"executable":[{
"relpath":"<relpath>",
"run-as":"<run-as>"
},...],
"tool":[{
"relpath":"<relpath>",
"user":"<user>",
"group":"<group>",
"permission":"<mode>"
},...]
}
<run-as>
Canbe package, system,or root,determineswhatprivilegewilltheexecutablebegranted:
run-as
description
package
Runas${package}anddropprivilege.
system
Runas${package},butpreservetheabilitytograntprivilege.
root
Runasroot.
defaults
Use run-astospecifywhatprivilegetobegranted,alsodecideshowtochown.
run-as
description
package
chown-hR"${package}:${package}"
system
chown-hR"${package}:system"
root
Donotchown.
PrivilegeSpecification
102
SynologyDSM6.0DeveloperGuide
PrivilegeSpecification
103
SynologyDSM6.0DeveloperGuide
Categories
Inhereweintroducewhatcategoriesprivilegespecificationsupportstooverwritethesettingof defaults.Afterapplyingchown
accordingto defaults'ssettings,chownagainwiththecaterogy'ssettings:
ctrl-script
executable
tool
Eachcategoryisakeyoftheprivilegespecificationjsonobject,andthecorrespondingvalueisajsonobjectarray.Anobjectinthe
arrayrepresentstheconfigurationofanexecutable.
ctrl-script
Controlscripts(preinst,post_inst,start_stop_status...)arespawnedbythePackageCenter:
"ctrl-script":[{
"action":"<action>",
"run-as":"<run-as>"
},...]
Member
Since
Description
action
6.05891
String,canonlybeoneof"preinst","postinst","preuninst","postuninst","preupgrade","postupgrade",
"start","stop,"status","prestart,"prestop",or"log"
run-as
6.05891
Seedefaults.
executable
ExecutablesdirectlyspawnedbytheDSMframeworkbelongstothiscategory:
"executable":[{
"relpath":"<relpath>",
"run-as":"<run-as>"
},...]
Member
Since
Description
relpath
6.0-5891
String,thefile'srelativepathunder/var/packages/${package}/target/.
run-as
6.0-5891
Seedefaults.
tool
ExecutablesindirectlycalledbytheDSMframeworkspawnbelongstothiscategory(Forexample,commandlinetoolcalledbya
CGI):
"tool":[{
"relpath":"<relpath>",
"user":"<user>",
"group":"<group>",
"permission":"<mode>"
},...]
PrivilegeSpecification
104
SynologyDSM6.0DeveloperGuide
Member
Since
Description
relpath
6.0-5891
String,thefile'srelativepathunder/var/packages/${package}/target/.
user
6.0-5891
String,file'sowneruser,canonlybe"package"or"root".
group
6.0-5891
String,file'sownergroup,canonlybe"package"or"root".
permission
6.0-5891
4digitnumbertosetfilepermission,forexample:4750
PrivilegeSpecification
105
SynologyDSM6.0DeveloperGuide
ResourceAcquisition
Duringpackageinstallationandstart-up,weoftenneedtoinstallconfigfiles(e.g.php.ini,apache.conf)orregisterservices(e.g.port
config,datashare)ontotheDSM.Aftersettingpackagetorunwithlowerprivilege,youmightlosetheabilitytodothesejobinthe
controlscripts.Insteadofwritingthesejobsintheinstallationscripts(preinst,postinst...),weprovideaframeworktosimplifythe
process.
Theconfigfilesandservicesthatneedstobeinstalledandregisteredarecalledresource.Eachresourcehasacorrespondingworker,
whichisresponsibleforinstallingtheresourceontotheDSM.Packagedevelopersjustneedtofollowapredefinedsyntaxandprovide
theresourcespecification,PackageCenterwillthencallthecorrespodingworkertofinishthejob.
NOTEIfapackageisusingthisframework,pleaseremembertoadjusttheINFOfile's firmwaretomeettheworker'srequirement
ResourceAcquisition
106
SynologyDSM6.0DeveloperGuide
ResourceSpecification
Thejsonfileresourceisusedtospecifyapackage'srequiredresources,anditshouldbeplacedintheconffolder.Afterpackage
installation,thisfilewillbelocatedat/var/packages/${package}/conf/resource.Thecontentofthefileshouldbesomethinglike:
{
"<resource-id>":<specification>,
...
}
<resource-id>
String,representstheresource'sID.
<specification>
Jsonobject,describestheresourcerequirements.
Takethebelow/usr/locallinkerworkerforexample:
{
"usr-local-linker":{
"lib":["lib/foo"],
"bin":["bin/foo"],
"etc":["etc/foo"],
}
}
"usr-local-linker"istheresourceIDandthecorrepondingJsonobjectisthespecification,whichspecifieswhatfilesshouldbe
installedintotheDSM.
DatafromWizard
AsmentionedinWIZARD_UIFILES,installationscriptscanoptainuser'sinputfromtheUIwizard,someworkersarealsocapableof
doingthis.Intheresourcefile,variablessurroundedby {{}}willbereplacedbytheuserinput.
TakethebelowDataShareworkerforexample:
"data-share":{
"name":"{{pkgwizard_share_name}}",
"permission":{
"ro":["admin"]
}
}
{{pkgwizard_share_name}}willbereplacedbyWIZARD_UIFILES/install_uifile'sorWIZARD_UIFILES/upgrade_uifiles's
pkgwizard_share_name
ResourceSpecification
107
SynologyDSM6.0DeveloperGuide
Timing
Everyworkeracquiresresourcesatcertaintimingsandholdsitduringaninterval.Forexample,/usr/locallinkerholdstheresource
duringtheinterval FROM_ENABLE_TO_DISABLE,whichmeansitacquiresresourceat WHEN_ENABLEandreleasesitat WHEN_DISABLE.
Thetimingsarelistedandexplainedbelow:
Timing
108
SynologyDSM6.0DeveloperGuide
timing
descrioption
whenFailure
WHEN_PREINST
beforepreinst
abortinstallation,rollback,showalertmessage
onUI
WHEN_POSTINST
beforepostinst
finishinstallation,showalertmessageonUI
WHEN_ENABLE
before WHEN_STARTUP,won'tprocessduring
bootup
abortstartup,rollback,showalertmessageonUI
WHEN_STARTUP
beforestart
abortstartup,rollback,showalertmessageonUI
WHEN_PREUNINST
afterpreuninst
finishuninstallation,showalertmessageonUI
WHEN_POSTUNINST
beforepostuninst
finishuninstallation,showalertmessageonUI
WHEN_DISABLE
after WHEN_HALT,won'tprocessduring
shutdown
ignore
WHEN_HALT
afterstop
ignore
NOTEToletthepackageitselfdecidewhetheruninstallationshouldcontinueornot, WHEN_PREUNINSTisprocessedafterthe
preuninstscript.
Timing
109
SynologyDSM6.0DeveloperGuide
ConfigUpdate
Someworkerssupportconfigupdateafterpackageinstallation./usr/syno/sbin/synopkghelershouldbeusedtoaccomplishthejob.
Belowarethestepstoupdatetheconfig:
1. Updatethecontentofconfigfileunder/var/packages/${package}/target/.
2. Executethecommand /usr/syno/sbin/synopkghelperupdate<package><resource-id>totriggerthecorrespondingworkerto
updatetheconfig.
Forexample,supposeapackageallowstheusertoedititslisteningportandneedstotriggerthePortconfigworkerforupdate:
1. ProvidetheusersomeUItoinputtheportnumber.
2. Afterreceivingthenewportnumber,updatetheconfigfileunder/var/packages/${package/target/.
3. Executethecommand /usr/syno/sbin/synopkghelperupdate${package}protocol_file,theworkerwillre-readtheconfigfile
andreloadfirewallandportforwarding.
NOTENotallworkersupportsconfigupdate,pleaserefertotheUpdatablesectionofeachworker.
ConfigUpdate
110
SynologyDSM6.0DeveloperGuide
AvailableWorkers
AsmentionedinthesectionResourceAcquisition,aworkerisneededforresourcemanagement.GivenaResourceSpecification
configurationfile,theworkerwillinstall\/uninstallthedescribedresourceatcertaintime.Thissectiondescribestheavailableworkers
ontheDSM.
AvailableWorkers
111
SynologyDSM6.0DeveloperGuide
/usr/locallinker
Description
Package'sexecutablesandlibraryfilesshouldbeinstalledto/usr/local.Thisworkerlink/unlinkfilesto/usr/local/{bin,lib,etc}during
packagestart/stop.
Acquire():Createsymboliclinksunder/usr/local/{bin,lib,etc}/thatpointstofilesin/var/packages/${package}/target/.
Filesnotfoundunder/var/packages/${package}/target/willbeignored.
Ifthetargetfilealreadyexistsin/usr/local/{bin,lib,etc},itwillbe unlink()first.
Failureonanyfilelinkresultsinthisworkertoabortandtriggersrollback.
Release():Deletethelinksunder/usr/local/{bin,lib,etc}/.
Ignorefilesthatarenotfound.
Ignore unlink()failure.
Provider
DSM
Timing
FROM_ENABLE_TO_DISABLE
EnvironmentVariables
None
Updatable
No
Syntax
"usr-local-linker":{
"bin"["<relpath>",...],
"lib"["<relpath>",...],
"etc"["<relpath>",...]
}
Member
Since
Description
bin
6.0-5941
Stringarray,listoffilestobelinkedunder/usr/local/bin/.
lib
6.0-5941
Stringarray,listoffilestobelinkedunder/usr/local/lib/.
etc
6.0-5941
Stringarray,listoffilestobelinkedunder/usr/local/etc/.
relpath
6.0-5941
String,targetfile'srelativepathunder/var/packages/${package}/target/.
Example
"usr-local-linker":{
"bin":["usr/bin/a2p","usr/bin/perl"],
"lib":["lib/perl5"]
}
AvailableWorkers
112
SynologyDSM6.0DeveloperGuide
TheabovespecificationsgeneratesthefollowingsymboliclinksforthePerlpackage:
root@DS$ls-l/usr/local/{bin,lib,etc}
/usr/local/bin/:
total0
lrwxrwxrwx1rootroot30Aug1306:32a2p->/var/packages/Perl/target/usr/bin/a2p
lrwxrwxrwx1rootroot31Aug1306:32perl->/var/packages/Perl/target/usr/bin/perl
/usr/local/lib/:
total0
lrwxrwxrwx1rootroot28Aug1306:32perl5->/var/packages/Perl/target/lib/perl5
/usr/local/etc/:
total0
AvailableWorkers
113
SynologyDSM6.0DeveloperGuide
Apache2.2Config
Description
Packagescancarrysites-enabled/*.conffilesforApacheHTTPServer2.2.Thisworkerinstalls/uninstallstheseconfigfilesduring
packagestart/stop.
Acquire():Copytheconffilesto/usr/local/etc/httpd/sites-enabled/.ThenreloadApache2.2.
Thefilesshouldhave.confextension,otherwiseitwillbeignored
Fileswillbeprefixedby${package}.
Existingfileswillbe unlink()first.
Failureonanyfilecopyresultsinthisworkertoabortandtriggersrollback.
Release():Deletepreviouslycreatedlinks
Ignorefilesthatarenotfound.
Ignore unlink()failure.
Provider
WebStation
Timing
FROM_ENABLE_TO_DISABLE
EnvironmentVariables
None
Updatable
No
Syntax
"apache22":{
"sites-enabled":[{
"relpath":"<conf-relpath>",
},...]
}
Member
Since
Description
sites-enabled
WebStation-1.0-0049
Objectarray,listofconffilestoinstall.
relpath
WebStation-1.0-0049
Targetfile'srelativepathunder/var/packages/${package}/target/.
Example
AvailableWorkers
114
SynologyDSM6.0DeveloperGuide
{
"apache22":{
"sites-enabled":[{
"relpath":"synology_added/test_1.conf"
},{
"relpath":"synology_added/test_2.conf"
},{
"relpath":"synology_added/test_3.conf"
}]
}
}
AvailableWorkers
115
SynologyDSM6.0DeveloperGuide
DataShare
Description
Thisworkercreatessharedfolderandsetitspermissionduringpackagestartup.Thesharenamecanbehard-codedinthespecification
orgivenbyuserinputfromtheUIwizard.Thesharedfolderwillnotberemovedafterpackageuninstallation,sinceitmightdeletethe
user’spersonaldataaswell.
Acquire():Createsharedfolderandsetitspermission.
Ifthesharedfolderalreadyexists,skipsharecreationandsetthepermission.
Release():Doesnothing.
Provider
DSM
Timing
FROM_ENABLE_TO_POSTUNINST
EnvironmentVariables
None
Updatable
No
Syntax
"data-share":{
"shares":[{
"name":"<share-name>",
"permission":{
"ro":["<user-name>",...],
"rw":["<user-name>",...]
},
"once":"<once>"
},...]
}
Member
Since
Description
shares
6.0-5914
Objectarray,arrayofsharestocreate
name
6.0-5914
String,nameoftheshare,canbeobtainedfromtheUIwizard
permission
6.0-5914
Jsonobject,permissionoftheshare.(optional)
ro
6.0-5914
Stringarrayuserstobeassignedwithread-onlypermission.
rw
6.0-5914
Stringarrayuserstobeassignedwithread/writepermission.
once
6.0-5914
Boolean,onlytrytocreateshareonpackage'sfirststart.(optional,default= false)
Example
AvailableWorkers
116
SynologyDSM6.0DeveloperGuide
Thefollowingspecificationcreatesasharemusic,andgivestheuserAudioStationread-onlypermission.Since oncedefaultsto
false,theaboveprocedureisraneverytimethepackagestarts.
"data-share":{
"shares":[{
"name":"music",
"permission":{
"ro":["AudioStation"]
}
}]
}
ThefollowingspecificationreadsthesharenamefromWIZARD_UIFILES/install_uifile's pkgwizard_share_name,andgivestheuser
adminread-onlypermission.
"data-share":{
"shares":[{
"name":"{{pkgwizard_share_name}}",
"permission":{
"ro":["admin"]
}
}]
}
AvailableWorkers
117
SynologyDSM6.0DeveloperGuide
IndexDB
Description
Index/unindexpackagehelpandappindexduringpackagestart/stop.
Fordetaileddescriptiononpackageappindexandhelpindex,pleaserefertoIntegegrateHelpDocumentintoDSMHelp.
Acquire():Indexpackagehelpandappcontent.
Release():Un-indexpackagehelpandappcontent.
Provider
DSM
Timing
FROM_ENABLE_TO_DISABLE
EnvironmentVariables
None
Updatable
No
Syntax
"indexdb":{
"app-index":{
"conf-relpath":"<confrelpath>",
"db-relpath":"<appdbrelpath>"
},
"help-index":{
"conf-relpath":"<confrelpath>",
"db-relpath":"<helpdbrelpath>"
}
}
Member
Since
Description
app-index
6.0-5924
Object,appindexinfo.
help-index
6.0-5924
Object,helpindexinfo.
conf-relpath
6.0-5924
String,configfile'srelativepathunder/var/packages/${package}/target/.
db-relpath
6.0-5924
String,dbfolder'srelativepathunder/var/packages/${package}/target/.
Example
AvailableWorkers
118
SynologyDSM6.0DeveloperGuide
"indexdb":{
"app-index":{
"conf-relpath":"app/index.conf",
"db-relpath":"indexdb/appindexdb"
},
"help-index":{
"conf-relpath":"app/helptoc.conf",
"db-relpath":"indexdb/helpindexdb"
}
}
AvailableWorkers
119
SynologyDSM6.0DeveloperGuide
MariaDB
Description
Create/deletedatabaseanddb-userduringpackageinstall/uninstall.Thedatabasenamecanbehard-coded,readfromconfigfileor
givenbytheuserfromUIwizard.Packagedevelopercandecideifcreatingacorrespondingdb-userisneededornot.
Acquire():Createdatabaseanddb-useraccrodingtoresourcespecification.
database:resourcespecificationcanspecifywhatactiontotakeifadatabasewiththesamenamealreadyexists:
1.
drop:Deletetheexistingdatabase.
2.
skip:Ignoredatabasecreation,keeptheexistingdatabaseandconitinueinstallation.
3.
error:Returnerrorandrollback.(Default: error)
db-user:Createdb-userandgrantaccesstothedatabaseaccordingtotheresourcespecification.Thedefaultdb-usertocreate
is '${package}'@'localhost'
Release():Deletedatabaseanddb-useraccrodingtotheresourcespecification.Defaultistokeepthedatabaseanddb-user.
Duringpackageupgrade,MariaDBworkerprovidestheget_key_valuemethodtoobtainpreviouslycreatedatabase'sname,and
therewillbenocreate/deletefordatabaseanddb-user
Provider
MariaDB
Timing
FROM_PREINST_TO_PREUNINST
EnvironmentVariables
Variable
Since
Description
SYNOPKG_DB_USER_RAND_PW
6.0-5920
Therandompasswordgeneratedduringdatebaseusercreation.
Updatable
No
Syntax
( (*)required)
AvailableWorkers
120
SynologyDSM6.0DeveloperGuide
"mysql-db":{
"info":{
"db-name":"<dbname>",(*)
"conf":"<conf>",
"key":"<key>"
},
"root-pw":"<dbpassword>",(*)
"create-db":{
"char-set":"<character-set>",
"collate":"<collate>",
"db-collision":"drop"|"skip"|"error"
},
"grant-user":{
"user-name":"<dbusername>",
"host":"<dbuserhost>",
"user-pw":"<userpassword>",
"rand-pw":true|false
},
"drop-db-uninst":true|false,
"drop-user-uninst":true|false
}
AvailableWorkers
121
SynologyDSM6.0DeveloperGuide
Member
Since
Description
info
5.5.470062
Object,infoofdb-name.Thepriorityofretrievingdatabase'snameis db-name> conf.Which
means,ifdb-nameisgiven,confandkeywillbeignored.
db-name
5.5.470062
String,databasename,canbegivenbyUIwizard.
conf
5.5.470062
String,filecontainingthedatabasename'skey-value-pair.
key
5.5.470062
String,thekeyin conffiletolookfordb-name.
root-pw
5.5.470062
String,rootpasswordofMariaDB.
create-db
5.5.470062
Object,infoofdatabase.Ifdoesnotexist,databasewillnotbecreatedduring Acquire().
characterset
5.5.470062
String,database'sCHARACTERSET.(default=utf8)
collate
5.5.470062
String,database'sCOLLATE.(default=utf8_unicode_ci)
dbcollision
5.5.470062
String,actiontotakeifthedatabaseexists.Canbe drop/ skip/ error.
grantuser
5.5.470062
Object,infoofdb-user.Ifdoesnotexist,db-userwillnotbecreatedduring Acquire().
user-name
5.5.470062
String,db-username.(default= ${package})
host
5.5.470062
String,db-user'shost.(defaults= localhost)
user-pw
5.5.470062
String,db-user'spassword.Ifemptyornull,db-user'spasswordwillnotbeset.Overridesexisting
user'spassword.
rand-pw
5.5.470062
Boolean,whethertogeneratearandompassword.Ifsetto true,thedb-userwillbegivena
randompasswordandbepassedtoenvironmentvariable SYNOPKG_DB_USER_RAND_PW.If user-pw
exists,thisvaluewillbeignored.
drop-dbuninst
5.5.470062
Boolean,whethertodeletedatabaseduring Release().CanbegivenbyUIwizard.(defaults=
false)
drop-useruninst
5.5.470062
Boolean,whethertodeletedb-userduring Release().CanbegivenbyUIwizard.(defaults=
false)
Example
"mysql-db":{
"info":{
"db-name":"wordpressblog"
},
"root-pw":"{{pkgwizard_mysql_password}}",
"create-db":{
"db-collision":"skip"
},
"grant-user":{
"user-name":"wordpress"
},
"drop-db-uninst":"{{pkgwizard_remove_mysql}}",
"drop-user-uninst":"{{pkgwizard_remove_mysql}}"
}
AvailableWorkers
122
SynologyDSM6.0DeveloperGuide
AvailableWorkers
123
SynologyDSM6.0DeveloperGuide
PHPINI
Description
Packagescancarrycustomphp.iniandfpm.conffiles.Thisworkerinstalls/uninstallstheseconfigfilesduringpackagestart/stop.
Acquire():Copythephp.iniandfpm.conffilesto/usr/local/etc/php56/conf.d/and/usr/local/etc/php56/fpm.d/.Thenreload
php56-fpm.
php.ini/fpm.conffilesshouldhave.ini/.confextension,otherwiseitwillbeignored
Fileswillbeprefixedby${package}.
Existingfileswillbe unlink()first.
Failureonanyfilecopyresultsinthisworkertoabortandtriggersrollback.
Release():Deletepreviouslycreatedlinks
Ignorefilesthatarenotfound.
Ignore unlink()failure.
Provider
PHP5.6
Timing
FROM_ENABLE_TO_DISABLE
EnvironmentVariables
None
Updatable
No
Syntax
"php":{
"php-ini":[{
"relpath":"<ini-relpath>",
},...],
"fpm-conf":[{
"relpath":"<conf-relpath>",
},...]
}
Member
Since
Description
php-ini
PHP5.6-5.6.17-0020
Objectarray,listofphp.inifilestoinstall.
fpm-conf
PHP5.6-5.6.17-0020
Objectarray,listoffpm.conffilestoinstall.
relpath
PHP5.6-5.6.17-0020
Targetfile'srelativepathunder/var/packages/${package}/target/.
Example
AvailableWorkers
124
SynologyDSM6.0DeveloperGuide
{
"php":{
"php-ini":[{
"relpath":"synology_added/etc/php/conf.d/test_1.ini"
},{
"relpath":"synology_added/etc/php/conf.d/test_2.ini"
},{
"relpath":"synology_added/etc/php/conf.d/test_3.ini"
}],
"fpm-conf":[{
"relpath":"synology_added/etc/php/fpm.d/test_1.conf"
},{
"relpath":"synology_added/etc/php/fpm.d/test_2.conf"
},{
"relpath":"synology_added/etc/php/fpm.d/test_3.conf"
}]
}
}
AvailableWorkers
125
SynologyDSM6.0DeveloperGuide
PortConfig
Description
Install/uninstallserviceportconfigfileduringpackageinstall/uninstall.
Fordetaileddescriptiononwhatisandhowtowriteaportconfigfile,pleaserefertoInstallPackageRelatedPortsInformationinto
DSM.
Acquire():copythe.scfileto/usr/local/etc/service.d/
Ifthedestinationfileexists,skipfilecopy.
Release():removethe.scfileandreloadthefirewallandportforward.
Update():updatethe.scfileandreloadfirewallandportforward.
Timing
FROM_POSTINST_TO_POSTUNINST
EnvironmentVariables
None
Updatable
Yes,pleaserefertoConfigUpdateonhowtotriggerupdate.
Syntax
"port-config":{
"protocol-file":<protocol_file>
}
Member
Since
Description
protocol_file
6.0-5936
.scfile'srelativepathunder/var/package/{$package}/target/
Example
"port-config":{
"protocol-file":"port_conf/xxdns.sc"
}
AvailableWorkers
126
SynologyDSM6.0DeveloperGuide
SyslogConfig
Description
Install/uninstallthesyslog-ngandlogrotateconfigfileduringpackagestart/stop.
Pleaserefertosyslog-ngonhowtowritethesyslog-ng'sconfigfile.
Acquire():Copypatterndb/logratoateto/usr/local/etc/syslog-ng/patterndb.d///usr/local/etc/logrotate.d/.Thenreloadsyslog-
ng.
Iffileexists, unlink()itfirst.
Failureonanyfilecopyresultsinthisworkertoabortandtriggersrollback.
Release():Deletetheconfigfilesandreloadsyslog-ng.
Ignore unlink()failure.
Provider
DSM
Timing
FROM_ENABLE_TO_DISABLE
EnvironmentVariables
None
Updatable
No
Syntax
"syslog-config":{
"patterndb-relpath":"<relpath>",
"logrotate-relpath":"<relpath>"
}
Member
Since
Description
patterndbrelpath
6.07145
String,syslog-ng'sconfigfile'srelativepathunder/var/packages/${package}/target/,ignorethisif
thelogisnotgeneratedbysyslog-ng(optional)
logrotaterelpath
6.05911
String,logrotate'sconfigfile'srelativepathunder/var/packages/${package}/target/,ignorethisif
logissavedtodatabase(optional)
Example
"syslog-config":{
"patterndb-relpath":"etc/syslog-ng.conf",
"logrotate-relpath":"etc/logrotate.conf"
}
AvailableWorkers
127
SynologyDSM6.0DeveloperGuide
AvailableWorkers
128
SynologyDSM6.0DeveloperGuide
PublishSynologyPackages
PublishSynologyPackages
129
SynologyDSM6.0DeveloperGuide
GetStartedwithPublishing
TopublishinSynologyPackageCenterrequiresafewsimplesteps.Hereishowtodoit:
1. AcquireaSynologyCheckoutMerchantAccountviaaSynologyspecialist(formoredetailspleasecontact
package@synology.com).
2. ReadandaccepttheDeveloperDistributionAgreement.NotethatpackagesthatyoupublishonPackageCentermustcomplywith
theTermsofServiceinPackageCenter.
Pleasenotethatthepackagequalitydirectlyinfluencesthelong-termsuccessofyourpackageintermsofinstallation,onlinereviews,
engagement,anduserretention.
GetStartedwithPublishing
130
SynologyDSM6.0DeveloperGuide
SubmittingthePackageforApproval
BeforeyoupublishyourpackageinPackageCenteranddistributeittousers,youneedtogetthepackage(theSPKfile)ready,testit,
andprepareyourpromotionmaterialsifneeded.Pleaseseethechecklistbelowbeforesubmittingyourpackagetous.
ConfirmPackageSize
TheoverallsizeofyourpackagecanaffectitsdesignandhowyoupublishitinPackageCenter.Currently,themaximumsizeforaSPK
filepublishedonPackageCenteris100MB.
FreeorPaidPackage
InPackageCenter,youcanpublishfreeorpaidpackages.FreepackagescanbedownloadedbyanyuserinPackageCenter.Paidapps
canbedownloadedonlybyuserswhohavearegisteredSynologyAccount.
Decidingwhetheryourpackagewillbefreeorpaidisimportantbecausefreepackagesmustremainfree.
Onceyourpackageispublishedasafreeone,youcannotchangeittoapaidpackage.
Ifyoupublishyourpackageasapaidone,youcanchangeittofreeatanytime(butcannotbechangedbacktopaid).
Ifyourpackageispaid,youneedtosetupaSynologyCheckoutMerchantAccountbeforethepackagecanbepublished.
ForqueriesabouttheSynologyCheckoutMerchantAccount,youcancontact package@synology.com.
SetaPriceforYourPackage
Ifyouhaveapaidpackage,SynologyletsyousetpricesforyourpackageonlyinUScurrencyforusersinmarketsaroundtheworld.
Beforeyoupublish,considerhowyouwillpriceyourpackageandwhatyourpricewillbeinvariouscurrencies.
PrepareScreenshots
WhenyoupublishinPackageCenter,youmustsupplyavarietyofhigh-qualityscreen-shotstoshowcaseyourpackageorbrand.After
youpublish,theywillappearonyourpackagedetailspage,orelsewhere.Thesescreen-shotsareakeypartofasuccessfulpackage
detailspagethatwillattractandengageusers.Therefore,youmayalsoconsiderhiringaprofessionaltoproducethemforyou.
SubmitYourPackage
Whenyouarereadytopublish,sendanemailtoaSynologyspecialist package@synology.comtomakeyoursubmission.
Makesurethat:
YouhaveappliedthroughSynologyDevCenterandbecomeanauthorizeddeveloper.
Yourpackageistherightversion.
Youprovideadownloadlinkforyourpackage.
Youprovideapackagedescriptionwithwhatitdoes.
Youprovideachangelogwithwhatwasupdatedinthisversion.
Packagepricingissettobefreeorpaid(forthefirsttimesubmission).
Thelinktoyourwebsiteandthesupportemailaddressiscorrect.
YouhaveacknowledgedthatyourpackagemeetstheDeveloperDistributionAgreementandalsotheTermsofServicefrom
PackageCenter.
SubmittingthePackageforApproval
131
SynologyDSM6.0DeveloperGuide
SubmittingthePackageforApproval
132
SynologyDSM6.0DeveloperGuide
RespondingtoUserIssues
Afteryoupublishapackage,ititcrucialforyoutooffersupporttoyourcustomers.Promptandcourteoussupportcanprovideabetter
experienceforusers,whichcanresultinmoredownloadsandmorepositiveonlinereviewsforyourpackages.Usersaremorelikelyto
bemoreengagedwithyourpackageandrecommenditifyouareresponsivetotheirneedsandfeedback.
Therearemanywaysthatyoucankeepintouchwithusersandofferthemsupport.Themostcommonwayistoprovideasupportemail
addressinyourpackagedetailspage.Youcanalsoprovidesupportinotherways,suchasaforumoramailinglist.TheSynology
technicalsupportteamprovidesusersupportfordownloading,installingandpaymentsissues,butissuesthatfalloutsideofthesetopics
willfallunderyourdomain.Examplesofissuesyoucansupportinclude:featurerequests,questionsaboutusingtheappandquestions
aboutcompatibilitysettings.
Afterpublishing,pleaseplanto:
Providealinktoyoursupportresourcesandsetupanyothersupportoutletssuchasaforum.
Provideanappropriatesupportemailaddressonyourpackagedetailpageandrespondtouserswhentheyemailyou.
Acknowledgeandfixissueswithyourpackage.Ithelpstobetransparentandlistknownissuesonyourpackagedetailspage
regularly.
Publishupdatesfrequently,withoutsacrificingqualityorannoyinguserswithtoo-frequentupdates.
Witheachupdate,makesureyouprovideasummaryofwhatisnew.Userswillreaditandappreciatethatyouareseriousabout
improvingthequalityofyourpackage.
RespondingtoUserIssues
133
SynologyDSM6.0DeveloperGuide
AppendixA:PlatformandArchValueMappingTable
ThearchitectureoftheNASisdevelopeduponvariousplatformsonwhichyourpackageisdesignedandneedstobeaddressedinthe
INFOfileinthepackage.
Inthebelowtable,youwillfindthestringvaluecorrespondingtotheplatforminquestion.Forexample,iftheplatformofyourNASis
MarvellKirkwood,88F6281,thevaluethatshouldtobeprovidedasapairofthearchkeyis88f6281.
PleasechecktheplatformsoftheNAStobesupportedandrefertothetablebelowfortheircorrespondingstringvalues:
PlatformName
ArchValue
MarvellKirkwood,88F6281
88f6281
MarvellKirkwood,88F6282
88f6282
IntelAtomD410/D510(Pineview)
x86
IntelAtomD2700(Cedarview)
cedarview
IntelSandyBridge,IntelIvyBridge,IntelHaswell
bromolow
MarvellArmada370
armada370
MarvellArmada375
armada375
MarvellArmadaXP
armadaxp
Annapurnalabs,Alpine
alpine/alpine4k
Mindspeed,Comcerto,C2000
comcerto2k
IntelAtomCESoC
evansport
FreescalePowerQUICCIII
ppc853x
Noplatformdependency
noarch
AppendixA:PlatformandArchValueMappingTable
134
SynologyDSM6.0DeveloperGuide
RevisionHistory
ThistabledescribesthechangestotheSynologyDSM3rdPartyAppsDeveloperGuide.
RevisionHistory
135
SynologyDSM6.0DeveloperGuide
Date
Note
2008/06/16
1.Originalreleasedateofdocument.
2009/02/09
1.AddedFreescale8533toolchaininformation.
2009/03/09
1.AddedMarvell6281toolchaininformation.
2.AddedDesktopIconchapter.
2010/05/20
1.Addedrelatedinformationfor10models.
2.ChangedallDSM2.0&2.1toDSM2.3.
3.Newscreenshotsfordesktopicon&DSMapplication.
4.Changedconfigurationfilesandtoolchains.
5.DS1010+usesIntelAtomD510.
2010/05/28
1.RevisedToolChaindescription
2.Revised88f5182-configto88f5281-configinKernelModule.
3.Revisedpathdescriptionofapplication.cfg/desktop.cfg.
2010/11/29
1.Renamedthedocumentto“SynologyDiskStationManager3rd-PartyAppsDeveloperGuide”.
2.AddedDSM3.0Integrationsection.
2011/10/31
1.AddedSynologypackagecreationsection.
2.UpdatedDSMtoolchaininformation.
2012/03/20
Addedtheguidelinetoapplicationstorage,webapplicationrunningonApacheandcreatedasharedfolder.
2012/09/19
AddedFreescaleQorIQtoolchaininformation.
2013/03/11
1.GeneralupdateforDSM4.2release.
2.Addedsectionregardingpaymentframework.
3.Updatedformatting.
2013/05/06
AddedMarvellArmada370toolchaininformation.
2013/05/29
AddedMarvellArmadaXPandEvansporttoolchaininformation.
2013/06/05
UpdatedQorIQ,ArmadaXP,Armada370,Evansport$CCvariable.
2013/07/09
1.Updatedinstall_dep_servicesandstart_dep_servicesinINFOsection.
2.AddedLocaleSupport.
2013/07/25
1.UpdatedLinuxkernelversion.
2.AddedCSRFprotectioninDSMWebAuthenticationsection.
2013/08/29
Generalupdateontoolchain,toolkit,andGPLkernelsourceforDSM4.3release.
2014/02/25
1.UpdatedkeysinINFOsectionforDSM5.0.
2.AddedDSM5.0supportinplatformchart.
3.UpdatedCreatePHPApplicationwithDSM5.0change.
4.AddedCreateUserAccountandSharePermission.
5.Minorcorrections.
2014/03/26
1.AddedAppendixforPlatformandArchstringmappingtable.
2.AddedcompilationinstructionforDSM5.0build.
2014/08/17
1.Addedcodesignmechanismforpackages.
2014/10/29
1.AddedChapter:QuickStartGuide.
2.Removedtheduplicatedcontent.
2015/09/10
1.AdedMarvellArmada375ANNAPURNALABS,AlpineAL212/AL314/AL514andMINDSPEED,
Comcerto,C2000toolchaininformation.
2016/01/14
1.Contentrevised.
2.ChangedtoformattoGitbook.
RevisionHistory
136
SynologyDSM6.0DeveloperGuide
CompileApplications
TheSynologyNASemploysembeddedSoCorx86-basedCPUs,implementingseveralplatforms--suchasARMandPowerPC--ona
varietyofSynologyNASmodels.Inordertorun3rd-partyapplicationsontheSynologyNAS,itisnecessarytocompileapplications
intoanexecutableformatforthecorrespondingplatform.
ThetablebelowliststheCPU,architecture,Endianness,andLinuxkernelversionofeachSynologyNASmodel.Thisinformationwill
helpyoudeterminewhichDSMtoolchain(pleaserefertothe“DownloadDSMToolChain”section)todownloadforeachmodel.
PleaserefertoWhatkindofCPUdoesmyNAShaveNeedtoupdatethehyperlinkforacompletemodellist.
Model(Tonameafew)
CPU
Arch
Endianness
Linux
DS112j,DS112,DS112+,DS411slim,DS213,DS212j
Marvell6281
Marvell6282
ARM
Little
Endian
2.6.32
DS213j
MarvellArmada370
ARM
Little
Endian
3.2.40
DS214,DS214+
MarvellArmadaXP
ARM
Little
Endian
3.2.40
DS215+,DS416
Annapurnalabs,Alpine
AL212
ARM
Little
Endian
3.2.40
DS715,DS1515
Annapurnalabs,Alpine
AL314
ARM
Little
Endian
3.2.40
DS2015xs
Annapurnalabs,Alpine
AL514
ARM
Little
Endian
3.2.40
DS115,DS215j
MarvellArmada375
ARM
Little
Endian
3.2.40
DS414j
Mindspeed,Comcerto,
C2000
ARM
Little
Endian
3.2.40
DS712+,DS2412+,RS2212+,DS1512+,DS1812+,
DS412+,RS812+
IntelAtom
Intelx86
Little
Endian
3.2.40
DS3612xs,RS3412xs,RS3412RPxs
IntelCorei3
Intelx86
Little
Endian
3.2.40
DS214play
IntelSoC
Intelx86
Little
Endian
3.2.40
DS213+,DS413
FreescaleQorIQP1022
PowerPC
BigEndian
2.6.32
DS110+,DS210+,DS410
Freescale8533
Freescale8533E
PowerPC
BigEndian
2.6.32
TocompileanapplicationfortheSynologyNAS,acompilerthatrunsonLinuxPCisrequiredinordertogenerateanexecutablefile
fortheSynologyNAS.Thiscompilingprocedureiscalledcross-compiling,andthesetofcompilingtools(compiler,linker,etc)usedto
compiletheapplicationiscalledatoolchain.
AppendixB:CompileApplicationsManually
137
SynologyDSM6.0DeveloperGuide
DownloadDSMToolChain
TodownloadtheDSMtoolchain,pleasegotoSourceForge.ThetablebelowshowsthefilenameoftoolchainsforNASwithdifferent
CPUs:
CPU
Marvell6281
ToolChain
Linux
Marvell88F628xLinux2.6.32
2.6.32
MarvellArmada370Linux3.2.403
3.2.40
MarvellArmadaXPMarv
MarvellArmadaxpLinux3.2.40
3.2.40
MarvellArmada375
MarvellArmada370Linux3.2.40
3.2.40
Annapurnalabs,AlpineLinux3.2.40
3.2.40
Mindspeed,Comcerto,C2000Linux3.2.40
3.2.40
PowerPC853xLinux2.6.32
2.6.32
PowerPCQorIQLinux2.6.32
2.6.32
IntelAtom
Intelx86Linux3.2.40(Pineview)
Intelx86Linux3.2.40(Cedarview)
3.2.40
IntelCorei3
Intelx86Linux3.2.40(Bromolow)
3.2.40
IntelSoC
Intelx86Linux3.2.40(Evansport)
3.2.40
MarvellArmada370
Annapurnalabs,AlpineAL212/AL314/AL514
Mindspeed,Comcerto,C2000
Freescale8533Freescale8533E
FreescaleQorIQ(P1022)
Ifyouarenotsureaboutwhichtoolchainyouneed,pleaseexecutethefollowingcommandonyourSynologyNAS.
#uname-a
Linuxmyds3.2.40#3503SMPThuMar2115:17:31CST2013x86_64
GNU/Linuxsynology_x86_712+
Thelast“synology_x64_712+”tellsyouwhichtoolchainisappropriate.Forexamples,x86meansyouneedthetoolchainfor
Pineview.
AfteryoudownloadtheDSMtoolchain,extractittowhereyouwantitonyourcomputer.Forthefollowinginstructionswewillextract
to/usr/local/asanexample.Youcanextractthetoolchainbyusingthefollowingcommand:
#tarzxpfgcc343_glibc232_88f5281.tgz–C/usr/local/
Pleasemakesurethetoolchainislocatedinthedirectory/usr/localonyourcomputertoensureproperintegration.
DownloadDSMToolChain
138
SynologyDSM6.0DeveloperGuide
Compile
Youcanstartcompilinganapplicationcalled“minimalPkg.c”,forexample,thatlookslikethis:
#include<sys/sysinfo.h>
intmain()
{
structsysinfoinfo;
intret;
ret=sysinfo(&info);
if(ret!=0){
printf("Failedtogetsysteminformation.\n");
return-1;
}
printf("TotalRAM:%u\n",info.totalram);
printf("FreeRAM:%u\n",info.freeram);
return0;
}
Tocompiletheapplication,runthefollowingcommand:
/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabigccminimalPkg.c–osysinfo
YoucanalsowriteaMakefileforit:
EXEC=sysinfo
OBJS=sysinfo.o
CC=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-gcc
LD=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-ld
CFLAGS+=-I/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/include
LDFLAGS+=-L/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/lib
all:$(EXEC)
$(EXEC):$(OBJS)
$(CC)$(CFLAGS)$(OBJS)-o$@$(LDFLAGS)
clean:
rm-rf*.o$(PROG)*.core
Compile
139
SynologyDSM6.0DeveloperGuide
CompileOpenSourceProjects
Tocompileanapplicationonmostopensourceprojects,youwillbeaskedtoexecutethefollowingthreesteps:
1.
configure
2.
make
3.
makeinstall
Theconfigurescriptbasicallyconsistsofmanylineswhichareusedtocheckdetailsaboutthemachineonwherethesoftwareisgoing
tobeinstalled.Thescriptwillcheckforalotofdependenciesonyoursystem.Whenyouruntheconfigurescript,youwillseealotof
outputonthescreen,eachbeingsomesortofquestionwitharespectiveyes/noreply.Ifthereareanymajorrequirementsmissingon
yoursystem,theconfigurescriptwillexitandyouwillnotbeabletoproceedwiththeinstallationuntilyoumeetalltherequirements.
Inmostcases,compileapplicationsonsomeparticulartargetmachineswillrequireyoutomodifytheconfigurescriptmanuallyto
providethecorrectvalues.
Whenrunningtheconfigurescripttoconfiguresoftwarepackagesforcross-compiling,youwillneedtospecifythe CC, LD,
RANLIB, CFLAGS, LDFLAGS, host, target,and build,etc.Someexamplesaregivenbelow.
ForPowerPC8544/8533platforminDSM5.0:
envCC=/usr/local/powerpc-none-linux-gnuspe/bin/powerpc-none-linuxgnuspe-gcc\
LD=/usr/local/powerpc-none-linux-gnuspe/bin/powerpc-none-linuxgnuspe-ld\
RANLIB=/usr/local/powerpc-none-linux-gnuspe/bin/powerpc-none-linuxgnuspe-ranlib\
CFLAGS="-I/usr/local/powerpc-none-linux-gnuspe/include-mcpu=8548-mhard-float-mfloat-gprs=double"\
LDFLAGS="-L/usr/local/powerpc-none-linux-gnuspe/lib"\
./configure\
--host=powerpc-unknown-linux\
--target=powerpc-unknown-linux\
--build=i686-pc-linux\
--prefix=/usr/local
ForPowerPCQorIQplatforminDSM5.0:
envCC=/usr/local/powerpc-none-linux-gnuspe/bin/powerpc-none-linuxgnuspe-gcc\
LD=/usr/local/powerpc-none-linux-gnuspe/bin/powerpc-none-linuxgnuspe-ld\
RANLIB=/usr/local/powerpc-none-linux-gnuspe/bin/powerpc-none-linuxgnuspe-ranlib\
CFLAGS="-I/usr/local/powerpc-none-linux-gnuspe/include-mcpu=8548-mhard-float-mfloat-gprs=double"\
LDFLAGS="-L/usr/local/powerpc-none-linux-gnuspe/lib"\
./configure\
--host=powerpc-unknown-linux\
--target=powerpc-unknown-linux\
--build=i686-pc-linux\
--prefix=/usr/local
ForMarvell6281platforminDSM5.0:
envCC=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-gcc\
LD=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-ld\
RANLIB=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-ranlib\
CFLAGS="-I/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/include"\
LDFLAGS="-L/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/lib"\
./configure\
--host=armle-unknown-linux\
--target=armle-unknown-linux\
--build=i686-pc-linux\
--prefix=/usr/local
ForMarvellArmada370platforminDSM5.0:
CompileOpenSourceProjects
140
SynologyDSM6.0DeveloperGuide
envCC=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-gcc\
LD=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-ld\
RANLIB=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-ranlib\
CFLAGS="-I/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/include-mhard-float-mfpu=vfpv3-d16"\
LDFLAGS="-L/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/lib"\
./configure\
--host=armle-unknown-linux\
--target=armle-unknown-linux\
--build=i686-pc-linux"\
--prefix=/usr/local
ForMarvellArmada375platforminDSM5.1:
envCC=/usr/local/armv7-marvell-linux-gnueabi-hard/bin/arm-marvelllinux-gnueabi-ccache-gcc\
LD=/usr/local/armv7-marvell-linux-gnueabi-hard/bin/arm-marvell-linuxgnueabi-ld\
RANLIB=/usr/local/armv7-marvell-linux-gnueabi-hard/bin/arm-marvelllinux-gnueabi-ranlib\
CFLAGS="-I/usr/local/armv7-marvell-linux-gnueabi-hard/arm-marvelllinux-gnueabi/libc/usr/include-mhard-float-mfpu=vfpv3"
LDFLAGS="-L/usr/local/armv7-marvell-linux-gnueabi-hard/arm-marvelllinux-gnueabi/libc/lib"\
./configure\
--host=armle-unknown-linux\
--target=armle-unknown-linux\
--build=i686-pc-linux"\
--prefix=/usr/local
ForMarvellArmadaXPplatforminDSM5.0:
envCC=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-gcc\
LD=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-ld\
RANLIB=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linuxgnueabi-ranlib\
CFLAGS="-I/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/include-mhard-float-mfpu=vfpv3-d16"\
LDFLAGS="-L/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linuxgnueabi/libc/lib"\
./configure\
--host=armle-unknown-linux\
--target=armle-unknown-linux\
--build=i686-pc-linux"\
--prefix=/usr/local
ForAnnapurnalabs,AlpineplatforminDSM5.1:
envCC=/usr/local/arm-cortex_a15-linux-gnueabi/bin/arm-cortex_a15-linux-gnueabi-ccache-gcc\
LD=/usr/local/arm-cortex_a15-linux-gnueabi/bin/arm-cortex_a15-linuxgnueabi-ld\
RANLIB=/usr/local/arm-cortex_a15-linux-gnueabi/bin/arm-cortex_a15-linux-gnueabi-ranlib\
CFLAGS="-I/usr/local/arm-cortex_a15-linux-gnueabi/arm-cortex_a15-linux-gnueabi/sysroot/usr/include-mfloat-abi=hard-mtune=cortex-a1
LDFLAGS="-L/usr/local/arm-cortex_a15-linux-gnueabi/arm-cortex_a15-linux-gnueabi/sysroot/lib"\
./configure\
--host=arm-cortex_a15-linux-gnueabi\
--target=arm-cortex_a15-linux-gnueabi\
--build=i686-pc-linux"\
--prefix=/usr/local
ForMindspeed,Comcerto,C2000platforminDSM5.0:
CompileOpenSourceProjects
141
SynologyDSM6.0DeveloperGuide
envCC=/usr/local/arm-cortexa9-linux-gnueabi/bin/arm-cortexa9-linuxgnueabi-ccache-gcc\
LD=/usr/local/arm-cortexa9-linux-gnueabi/bin/arm-cortexa9-linuxgnueabi-ld\
RANLIB=/usr/local/arm-cortexa9-linux-gnueabi/bin/arm-cortexa9-linuxgnueabi-ranlib\
CFLAGS="-I/usr/local/arm-cortexa9-linux-gnueabi/arm-cortexa9-linuxgnueabi/sysroot/include-mcpu=cortex-a9-march=armv7-a-mfpu=neon
LDFLAGS="-L/usr/local/arm-cortexa9-linux-gnueabi/arm-cortexa9-linuxgnueabi/sysroot/lib"\
./configure\
--host=armle-unknown-linux\
--target=armle-unknown-linux\
--build=i686-pc-linux"\
--prefix=/usr/local
ForIntelX86platforminDSM5.0:
envCC=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-gcc\
LD=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-ld\
RANLIB=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-ranlib\
CFLAGS="-I/usr/local/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include"\
LDFLAGS="-L/usr/local/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/lib"\
./configure\
--host=i686-pc-linux-gnu\
--target=i686-pc-linux-gnu\
--build=i686-pc-linux\
--prefix=/usr/local
ForIntelAtomEvansportplatforminDSM5.0:
envCC=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-gcc\
LD=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-ld\
RANLIB=/usr/local/i686-pc-linux-gnu/bin/i686-pc-linux-gnu-ranlib\
CFLAGS="-I/usr/local/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include"\
LDFLAGS="-L/usr/local/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/lib"\
./configure\
--host=i686-pc-linux-gnu\
--target=i686-pc-linux-gnu\
--build=i686-pc-linux\
--prefix=/usr/local
CompileOpenSourceProjects
142
SynologyDSM6.0DeveloperGuide
CompileKernelModules
Ifyouwouldliketocompilekernelmodules,youwillneedtoobtainaSynologyGPLtoaccessthekernelsourcecode.Pleasereferto
SourceForgeformoredetails.
Inthekernelsourcecode,therearemanyconfigurationfilesfordifferentplatforms.Theconfigurationfilesarelistedinbelow:
CPU
ConfigurationFile
Arch
Linux
Marvell6281
Marvell6282
synoconfigs/88f6281
ARM
2.6.32
MarvellArmada370
synoconfigs/armada370
ARM
3.2.40
MarvellArmada375
synoconfigs/armada375
ARM
3.2.40
MarvellArmadaXP
synoconfigs/armadaxp
ARM
3.2.40
Annapurnalabs,AlpineAL212/AL314/AL514
synoconfigs/alpine(DS715,DS1515,DS2015xs)
synoconfigs/alpine4k(DS215+,DS416)
ARM
3.2.40
Mindspeed,Comcerto,C2000
synoconfigs/comcerto2k
ARM
3.2.40
Freescale8533
synoconfigs/ppc8533
PowerPC
2.6.32
FreescaleQorIQ(P1022)
synoconfigs/ppcQorIQ
PowerPC
2.6.32
IntelAtomD525,D510,D410,D425
synoconfigs/x86_64
x86
3.2.40
IntelAtomD2700
synoconfigs/cedarview
x86
3.2.40
IntelSoCCE5335
synoconfigs/evansport
x86
3.2.40
IntelCorei3
synoconfigs/bromolow
x86
3.2.40
Pleasecopytheproperconfigurationfileto .config,andrun makeoldconfigand makemenuconfigtoselectyourkernelmodules.
Dependingontheplatformyouwouldliketocompile,youwillhavetosettheproper ARCHand CROSS_COMPILEintoenvironment
variables.
Forexample,thebelowcommandsaretocompile3.xkernelmodulesforbromolowplatform.
cdlinux-3.x
cpsynoconfigs/bromolow.config
makeARCH="x86_64"CROSS_COMPILE="/usr/local/x86_64-pc-linuxgnu/bin/x86_64-pc-linux-gnu-"oldconfig
makeARCH="x86_64"CROSS_COMPILE="/usr/local/x86_64-pc-linuxgnu/bin/x86_64-pc-linux-gnu-"menuconfig
makeARCH="x86_64"CROSS_COMPILE="/usr/local/x86_64-pc-linuxgnu/bin/x86_64-pc-linux-gnu-"modules
CompileKernelModules
143
Related documents
Download