diff --git a/composer.json b/composer.json index b9ee9a3..8fbd21e 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ ], "require": { "ext-soap": "*", - "vitexsoftware/ease-core": ">=1.12" + "vitexsoftware/ease-core": ">=1.12", + "spoje.net/subreg": "dev-master" }, "autoload": { "psr-4": { diff --git a/debian/Jenkinsfile b/debian/Jenkinsfile new file mode 100644 index 0000000..7f323e9 --- /dev/null +++ b/debian/Jenkinsfile @@ -0,0 +1,73 @@ +#!groovy + +String[] distributions = ['debian:bullseye', 'debian:bookworm', 'ubuntu:focal', 'ubuntu:jammy'] + +String vendor = 'vitexsoftware' +String distribution = '' +//String distroFamily = '' +String distroCodename = '' +String ver = '' + +properties([ + copyArtifactPermission('*') +]) +node() { + ansiColor('xterm') { + stage('SCM Checkout') { + checkout scm + } + } +} + +distributions.each { + distribution = it + + println "Dist:" + distribution + + def dist = distribution.split(':') + // distroFamily = dist[0] + distroCodename = dist[1] + + def buildImage = '' + + node { + ansiColor('xterm') { + stage('Checkout ' + distribution) { + buildImage = docker.image(vendor + '/' + distribution) + sh 'git checkout debian/changelog' + def version = sh ( + script: 'dpkg-parsechangelog --show-field Version', + returnStdout: true + ).trim() + ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename + } + stage('Build ' + distribution) { + buildImage.inside { + sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'sudo chown jenkins:jenkins ..' + sh 'debuild-pbuilder -i -us -uc -b' + sh 'mkdir -p $WORKSPACE/dist/debian/ ; rm -rf $WORKSPACE/dist/debian/* ; for deb in $(cat debian/files | awk \'{print $1}\'); do mv "../$deb" $WORKSPACE/dist/debian/; done' + } + } + + stage('Test ' + distribution) { + buildImage.inside { + def debconf_debug = 0 //Set to "5" or "developer" to debug debconf + sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' + sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'echo "INSTALATION"' + sh 'IFS="\n\b"; for package in `ls $WORKSPACE/dist/debian/ | grep .deb | grep -v dbgsym | awk -F_ \'{print \$1}\'` ; do echo -e "${GREEN} installing ${package} on `lsb_release -sc` ${ENDCOLOR} " ; sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $package ; done;' + stash includes: 'dist/**', name: 'dist-' + distroCodename + } + } + stage('Copy artifacts ' + distribution ) { + buildImage.inside { + sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE' + } + } + } + } +} + diff --git a/debian/README.Debian b/debian/README.Debian index 4262962..d71922d 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -1,7 +1,7 @@ -Ease framework Core for Debian +Subreg PHP library debian package ------------------------------ - Is installed by standard way in /usr/share/php/EaseCore + Is installed by standard way in /usr/share/php/Subreg -- Vítězslav Dvořák Ne říj 21 15:17:56 CEST 2012 diff --git a/debian/changelog b/debian/changelog index 0595bd3..5e9d68a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -php-subreg (0.3) unstable; urgency=medium +php-spojenet-subreg (1.0) unstable; urgency=medium * new support for Pricelist command diff --git a/debian/compat b/debian/compat index f599e28..9f1d48e 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1,2 @@ -10 +11 + diff --git a/debian/composer.json b/debian/composer.json index b180e0d..dd164a4 100644 --- a/debian/composer.json +++ b/debian/composer.json @@ -8,14 +8,20 @@ "email": "info@vitexsoftware.cz" } ], - "version": "0.2", + "version": "1.0", "require": { "ext-soap": "*", - "deb/ease-framework": "*" + "deb/ease-core": "*" }, "autoload": { "psr-4": { "Subreg\\": "." } - } + }, + "repositories": [ + { + "type": "path", + "url": "/usr/share/php/EaseCore" + } + ] } diff --git a/debian/control b/debian/control index 5a71c0b..038b9ec 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: php-subreg +Source: php-spojenet-subreg Build-Depends: debhelper (>= 7.0.50~) Section: web Standards-Version: 3.9.8 @@ -7,8 +7,8 @@ Uploaders: Vitex Priority: optional Homepage: https://github.com/Spoje-NET/php-subreg -Package: php-subreg -Depends: ${misc:Depends}, ease-framework +Package: php-spojenet-subreg +Depends: ${misc:Depends}, php-vitexsoftware-ease-core, php-soap Architecture: all Section: web Priority: optional diff --git a/debian/files b/debian/files index 3abeedd..30f66cc 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,2 @@ -php-subreg_0.3_all.buildinfo web optional -php-subreg_0.3_all.deb web optional +php-spojenet-subreg_1.0_all.deb web optional +php-spojenet-subreg_1.0_amd64.buildinfo web optional diff --git a/debian/fixversion.sh b/debian/fixversion.sh index edf9984..c254307 100755 --- a/debian/fixversion.sh +++ b/debian/fixversion.sh @@ -1,9 +1,9 @@ #!/bin/bash VERSTR=`dpkg-parsechangelog --show-field Version` COMPOSER_VERSTR=`echo ${VERSTR}|sed 's/-/./g'` -echo update debian/php-subreg/usr/share/php/Subreg/composer.json version to ${COMPOSER_VERSTR} +echo update debian/php-spojentet-subreg/usr/share/php/Subreg/composer.json version to ${COMPOSER_VERSTR} sed -i -e '/\"version\"/c\ \"version\": \"'${COMPOSER_VERSTR}'",' debian/php-subreg/usr/share/php/Ease/composer.json echo Update debian/php-subreg/usr/share/php/Subreg/Client.php version to ${VERSTR} -sed -i -e "/static public \$libVersion/c\ static public \$libVersion = '${VERSTR}';" debian/php-subreg/usr/share/php/Subreg/Client.php +sed -i -e "/static public \$libVersion/c\ static public \$libVersion = '${VERSTR}';" debian/php-spojenet-subreg/usr/share/php/Subreg/Client.php echo Update src/Ease/Atom.php version to ${VERSTR} sed -i -e "/static public \$libVersion/c\ static public \$libVersion = '${VERSTR}';" src/Subreg/Client.php diff --git a/debian/php-subreg-doc.conf b/debian/php-spojenet-subreg-doc.conf similarity index 100% rename from debian/php-subreg-doc.conf rename to debian/php-spojenet-subreg-doc.conf diff --git a/debian/php-subreg-doc.install b/debian/php-spojenet-subreg-doc.install similarity index 100% rename from debian/php-subreg-doc.install rename to debian/php-spojenet-subreg-doc.install diff --git a/debian/php-subreg.install b/debian/php-spojenet-subreg.install similarity index 100% rename from debian/php-subreg.install rename to debian/php-spojenet-subreg.install diff --git a/debian/postinst b/debian/php-spojenet-subreg.postinst similarity index 95% rename from debian/postinst rename to debian/php-spojenet-subreg.postinst index f5b86c9..d60f812 100644 --- a/debian/postinst +++ b/debian/php-spojenet-subreg.postinst @@ -1,5 +1,5 @@ #!/bin/sh -# postinst script for ease-core +# postinst script for php-spojenet-subreg # # see: dh_installdeb(1) diff --git a/src/Subreg/Client.php b/src/Subreg/Client.php index f6cc2b1..0da6295 100644 --- a/src/Subreg/Client.php +++ b/src/Subreg/Client.php @@ -1,9 +1,10 @@ - * @copyright (C) 2018 Spoje.Net + * @copyright (C) 2018,2023 Spoje.Net */ namespace Subreg; @@ -15,11 +16,13 @@ */ class Client extends \Ease\Molecule { + use \Ease\Log\Logging; + /** * ClientLibrary version - * @var string + * @var string */ - static public $libVersion = '0.3'; + public static $libVersion = '1.0'; /** * Object Configuration @@ -35,7 +38,7 @@ class Client extends \Ease\Molecule /** * Authentification - * @var string + * @var string */ public $token = null; @@ -47,25 +50,25 @@ class Client extends \Ease\Molecule /** * Last call error Data - * @var array + * @var array */ public $lastError = []; /** * Last call obtained Data - * @var array + * @var array */ public $lastResult = []; /** - * + * * @param type $config */ public function __construct($config) { - parent::__construct(); $this->config = $config; - $this->soaper = new \SoapClient(null, + $this->soaper = new \SoapClient( + null, [ "location" => $config['location'], "uri" => $config['uri'] @@ -78,22 +81,27 @@ public function __construct($config) * Add Info about used user, server and libraries * * @param string $additions Additional note text - * + * * @return boolean was logged ? */ public function logBanner($additions = null) { - return $this->addStatusMessage('API '.str_replace('://', - '://'.$this->config['login'].'@', $this->config['uri']).' php-subreg v'.self::$libVersion.' EasePHP Framework v'.\Ease\Atom::$frameworkVersion.' '.$additions, - 'debug'); + return $this->addStatusMessage( + 'API ' . str_replace( + '://', + '://' . $this->config['login'] . '@', + $this->config['uri'] + ) . ' php-subreg v' . self::$libVersion . ' EasePHP Framework v' . \Ease\Atom::$frameworkVersion . ' ' . $additions, + 'debug' + ); } /** * API Call - * + * * @param string $command command to execute * @param array $params command parameters - * + * * @return array */ public function call($command, $params = []) @@ -129,19 +137,21 @@ public function call($command, $params = []) /** * log Error - * + * * @param array $errorData */ public function logError($errorData) { $this->lastError = $errorData; - $this->addStatusMessage($errorData['errorcode']['major'].' '.$errorData['errorcode']['minor'].': '.$errorData['errormsg'], - 'error'); + $this->addStatusMessage( + $errorData['errorcode']['major'] . ' ' . $errorData['errorcode']['minor'] . ': ' . $errorData['errormsg'], + 'error' + ); } /** * Perform Login to Server - * + * * @return boolean success */ public function login() @@ -161,11 +171,11 @@ public function login() /** * Check if domain is available or not - * + * * @link https://subreg.cz/manual/?cmd=Check_Domain Command: Check_Domain - * + * * @param string $domain - * + * * @return array */ public function checkDomain($domain) @@ -175,9 +185,9 @@ public function checkDomain($domain) /** * Create a new domain - * + * * @link https://subreg.cz/manual/?cmd=Create_Domain Order: Create_Domain - * + * * @param string $domain * @param string $registrantID * @param string $contactsAdminID @@ -185,14 +195,20 @@ public function checkDomain($domain) * @param string $authID * @param array $nsHosts Hostnames of nameservers: ['ns.domain.cz','ns2.domain.cz'] * @param string $nsset Nameserver Set (only for FRED registries (.CZ,.EE,...)) - * @param int $period - * + * @param int $period + * * @return array */ - public function registerDomain($domain, $registrantID, $contactsAdminID, - $contactsTechID, $authID, $nsHosts = [], - $nsset = null, $period = 1) - { + public function registerDomain( + $domain, + $registrantID, + $contactsAdminID, + $contactsTechID, + $authID, + $nsHosts = [], + $nsset = null, + $period = 1 + ) { foreach ($nsHosts as $host) { $ns[]["hostname"] = $host; @@ -232,9 +248,9 @@ public function registerDomain($domain, $registrantID, $contactsAdminID, /** * Get all domains from your account - * + * * @link https://subreg.cz/manual/?cmd=Domains_List Command: Domains_List - * + * * @return array */ public function domainsList() @@ -244,43 +260,41 @@ public function domainsList() /** * Get pricelist from your account - * + * * @link https://subreg.cz/manual/?cmd=Pricelist Command: Pricelist - * + * * @return array */ public function pricelist() { return $this->call('Pricelist'); } - + /** * Get specified pricelist from your account - * + * * @link https://subreg.cz/manual/?cmd=Get_Pricelist Command: Get_Pricelist - * + * * @param string requested pricelist name - * + * * @return array */ public function getPricelist($pricelist) { - return $this->call('Get_Pricelist', ['pricelist'=>$pricelist]); + return $this->call('Get_Pricelist', ['pricelist' => $pricelist]); } - + /** - * + * * @link https://subreg.cz/manual/?cmd=Renew_Domain Command: Renew_Domain - * + * * @param string $domain name * @param int $years - * + * * @return type */ public function renewDomain(string $domain, int $years = 1) { - return $this->call('Make_Order', ['order' => ['domain' => $domain, 'params' => ['period' => $years], 'type' => 'Renew_Domain']] ); + return $this->call('Make_Order', ['order' => ['domain' => $domain, 'params' => ['period' => $years], 'type' => 'Renew_Domain']]); } - - } diff --git a/src/demo.php b/src/demo.php index 6436bb0..0c78d59 100644 --- a/src/demo.php +++ b/src/demo.php @@ -1,4 +1,5 @@