2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the Revised BSD License.
5 This program is distributed in the hope that it will be useful,
6 but WITHOUT ANY WARRANTY; without even the implied warranty of
7 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 Revised BSD License for more details.
10 Copyright 2011-2016 Game Maker 2k - https://github.com/GameMaker2k
11 Copyright 2011-2016 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
13 $FileInfo: pypkg-gen.py - Last Update: 2/15/2016 Ver. 0.1.7 RC 1 - Author: cooldude2k $
16 from __future__
import absolute_import
, division
, print_function
, unicode_literals
;
17 import re
, os
, sys
, time
, datetime
, argparse
, subprocess
;
19 __version_info__
= (0, 1, 7, "rc1");
20 if(__version_info__
[3]!=None):
21 __version__
= str(__version_info__
[0])+"."+str(__version_info__
[1])+"."+str(__version_info__
[2])+"+"+str(__version_info__
[3]);
22 if(__version_info__
[3]==None):
23 __version__
= str(__version_info__
[0])+"."+str(__version_info__
[1])+"."+str(__version_info__
[2]);
25 proname
= "pypkg-gen";
27 profullname
= proname
+" "+prover
;
29 parser
= argparse
.ArgumentParser(conflict_handler
= "resolve", add_help
= True);
30 parser
.add_argument("-v", "--version", action
= "version", version
= profullname
);
31 parser
.add_argument("-s", "--source", default
= os
.path
.realpath(os
.getcwd()), help = "source dir");
32 parser
.add_argument("-d", "--distro", default
= "debian", help = "enter linux distribution name");
33 parser
.add_argument("-c", "--codename", default
= "jessie", help = "enter release code name");
34 parser
.add_argument("-p", "--pyver", default
= sys
.version
[0], help = "enter version of python to use");
35 getargs
= parser
.parse_args();
37 def which_exec(execfile):
38 for path
in os
.environ
["PATH"].split(":"):
39 if os
.path
.exists(path
+ "/" + execfile):
40 return path
+ "/" + execfile;
41 bashlocatout
= which_exec("bash");
43 getargs
.source
= os
.path
.realpath(getargs
.source
);
44 getargs
.codename
= getargs
.codename
.lower();
45 getargs
.distro
= getargs
.distro
.lower();
47 if(getargs
.pyver
=="2"):
49 if(getargs
.pyver
=="3"):
51 if(getargs
.pyver
!="2" and getargs
.pyver
!="3"):
52 if(sys
.version
[0]=="2"):
54 if(sys
.version
[0]=="3"):
57 get_pkgbuild_dir
= os
.path
.realpath(getargs
.source
+os
.path
.sep
+"pkgbuild");
58 get_pkgbuild_dist_pre_list
= [d
for d
in os
.listdir(get_pkgbuild_dir
) if os
.path
.isdir(os
.path
.join(get_pkgbuild_dir
, d
))];
59 get_pkgbuild_dist_list
= [];
60 for dists
in get_pkgbuild_dist_pre_list
:
61 tmp_pkgbuild_python
= os
.path
.realpath(get_pkgbuild_dir
+os
.path
.sep
+dists
+os
.path
.sep
+getpyver
);
62 if(os
.path
.exists(tmp_pkgbuild_python
) and os
.path
.isdir(tmp_pkgbuild_python
)):
63 get_pkgbuild_dist_list
.append(dists
);
64 if(not getargs
.distro
in get_pkgbuild_dist_list
):
65 print("Could not build for "+getargs
.distro
+" distro.");
68 if(getargs
.distro
=="debian" or getargs
.distro
=="ubuntu" or getargs
.distro
=="linuxmint"):
69 pypkgpath
= os
.path
.realpath(getargs
.source
+os
.path
.sep
+"pkgbuild"+os
.path
.sep
+getargs
.distro
+os
.path
.sep
+getpyver
+os
.path
.sep
+"pydeb-gen.sh");
70 pypkgenlistp
= subprocess
.Popen([bashlocatout
, pypkgpath
, getargs
.source
, getargs
.codename
], stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
);
71 pypkgenout
, pypkgenerr
= pypkgenlistp
.communicate();
72 if(sys
.version
[0]=="3"):
73 pypkgenout
= pypkgenout
.decode("utf-8");
77 if(getargs
.distro
=="archlinux"):
78 pypkgpath
= os
.path
.realpath(getargs
.source
+os
.path
.sep
+"pkgbuild"+os
.path
.sep
+getargs
.distro
+os
.path
.sep
+getpyver
+os
.path
.sep
+"pypac-gen.sh");
79 pypkgenlistp
= subprocess
.Popen([bashlocatout
, pypkgpath
, getargs
.source
, getargs
.codename
], stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
);
80 pypkgenout
, pypkgenerr
= pypkgenlistp
.communicate();
81 if(sys
.version
[0]=="3"):
82 pypkgenout
= pypkgenout
.decode("utf-8");
86 if(getargs
.distro
=="redhat"):
87 pypkgpath
= os
.path
.realpath(getargs
.source
+os
.path
.sep
+"pkgbuild"+os
.path
.sep
+getargs
.distro
+os
.path
.sep
+getpyver
+os
.path
.sep
+"pyrpm-gen.sh");
88 pypkgenlistp
= subprocess
.Popen([bashlocatout
, pypkgpath
, getargs
.source
, getargs
.codename
], stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
);
89 pypkgenout
, pypkgenerr
= pypkgenlistp
.communicate();
90 if(sys
.version
[0]=="3"):
91 pypkgenout
= pypkgenout
.decode("utf-8");