Ñò
ýÉªWc           @   sw   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d e f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(   iÿÿÿÿNt   GenerateTarc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   d |  _  d  S(   Ns   (.*)-(\d\.\d\.\d\d\d\.\d)\.rpm(   t   regex(   t   self(    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyt   __init__	   s    c         C   s5   t  i i | ƒ o t i | ƒ n t  i | ƒ d  S(   N(   t   ost   patht   existst   shutilt   rmtreet   mkdir(   R   t   dirName(    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyR	      s    c   
      C   s–  t  i t | ƒ ƒ } | d i d d ƒ } | d } t i i d d d | | f ƒ } |  i | ƒ t d | d	 ƒ } | i	 d
 ƒ | i	 d | ƒ | i	 d | | f ƒ | i	 d ƒ x" | d D] } |  i
 | | ƒ qÄ W| i	 d ƒ | i	 d ƒ | i	 d ƒ | i ƒ  |  i | | ƒ t i ƒ  } t i | ƒ |  i d ƒ d | | f }	 t i d |	 t i i d |	 ƒ ƒ t i | ƒ t i | ƒ d  S(   Nt   namet    t   -t   versions   ..t   packagess   %s-%ss
   %s/pom.xmlt   wsó   <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

sÁ   	<parent>
		<groupId>com.ericsson.cms</groupId>
		<artifactId>prepack-baseline</artifactId>
		<version>%s</version>
		<relativePath>../../../prepack-baseline/pom.xml</relativePath>
	</parent>

sÄ   	<modelVersion>4.0.0</modelVersion>
	<groupId>com.ericsson.cms</groupId>
	<artifactId>%s</artifactId>
	<name>%s</name>
	<packaging>pom</packaging>
	<description>AMS PrePack for CMS</description>

s   	<dependencies>
t   rpmss   	</dependencies>

s†  	<build>
		<plugins>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<executions>
					<execution>
						<id>make-assembly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<descriptor>prepackzip.xml</descriptor>
				</configuration>
			</plugin>
		</plugins>
	</build>
s   </project>
s   mvn clean packages   %s-%s-release.tar.gzs	   target/%s(   t   jsont   loadt   opent   replaceR   R   t   joinR	   t   filet   writet   addRPMtoPomt   closet   addPackagingt   getcwdt   chdirt   runSystemCommandt   renameR   R   (
   R   t   jsonFilet   configR   R   R
   t   pomt   rpmt
   currentDirt   tarName(    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyt   generateTar   s6    
"		 
#c         C   si   t  i |  i | ƒ } | oI | i d ƒ | i d ƒ } } d | | f GH| i d | | f ƒ n d  S(   Ni   i   s   Adding '%s-%s' to pom.xmls›   		<dependency>
			<groupId>${project.parent.groupId}</groupId>
			<artifactId>%s</artifactId>
			<version>%s</version>
			<type>rpm</type>
		</dependency>
(   t   ret   matchR   t   groupR   (   R   R"   R#   R(   R   R   (    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyR   Y   s    	c         C   sì   t  i t | ƒ ƒ } t d | d ƒ } | i d ƒ | i d ƒ d i t d „  | d | d ƒ ƒ } | i d	 ƒ | i d
 | ƒ | | i d ƒ  } | i d ƒ d } | i d | | f ƒ | i d ƒ | i d ƒ | i	 ƒ  d  S(   Ns   %s/prepackzip.xmlR   s  <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

	<id>release</id>
	<formats>
		<format>tar.gz</format>
	</formats>
	<includeBaseDirectory>true</includeBaseDirectory>

s   	<dependencySets>
		<dependencySet>
			<outputDirectory>rpms</outputDirectory>
			<useProjectArtifact>true</useProjectArtifact>
			<unpack>false</unpack>
			<useTransitiveDependencies>false</useTransitiveDependencies>
		</dependencySet>
	</dependencySets>
t    c         S   s   d  |  d S(   s   				<include>%s</include>
t   FILENAME(    (   t   ruleSet(    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyt   <lambda>~   s    t   ruleSetst   contentClassess  	<fileSets>
		<fileSet>
			<directory>../../../configurations</directory>
			<includes>
				<include>pysetup/**</include>
				<include>scripts/**</include>
				<include>deploy.sh</include>
			</includes>
			<outputDirectory>/</outputDirectory>
		</fileSet>
s¤   		<fileSet>
			<directory>../../../configurations/resources</directory>
			<includes>
%s			</includes>
			<outputDirectory>resources</outputDirectory>
		</fileSet>
t   /iÿÿÿÿs˜   		<fileSet>
			<directory>../%s</directory>
			<includes>
				<include>%s</include>
			</includes>
			<outputDirectory>/</outputDirectory>
		</fileSet>
s   	</fileSets>
s   	</assembly>
(
   R   R   R   R   R   R   t   mapt   rindext   splitR   (   R   R
   R    R!   t   prepackt   rulest   jsonDirt   jsonName(    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyR   f   s    
'		c         C   s*   d | GHt  i | d ƒ i ƒ  } | GHd  S(   Ns   Running '%s'...t   r(   R   t   popent   read(   R   t   commandt   output(    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyR   £   s    	(   t   __name__t
   __module__R   R	   R&   R   R   R   (    (    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyR       s   			H		=c          C   s   t  ƒ  }  |  i d ƒ d  S(   Ns.   ../../prepack-ams/src/main/resources/base.json(   R    R&   (   t   gt(    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyt   main¨   s    	t   __main__(	   R   R   t   os.pathR'   R   t   objectR    R@   R=   (    (    (    se   /home/jenkins/workspace/prepack-aio-release-4.2/prepack-aio/src/main/resources/scripts/GenerateTar.pyt   <module>   s    	