Skip to content

Commit

Permalink
docker update
Browse files Browse the repository at this point in the history
  • Loading branch information
shinrax2 committed Dec 2, 2023
1 parent 964f24e commit e3165e9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
18 changes: 12 additions & 6 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#local files
import utils

def buildheader(release, filepath , pyiver="None"):
def buildheader(release, filepath , pyiver="None", winever=None):
lines = [ "Building PS3GameUpdateDownloader",
"Build script arguments: "+str(sys.argv[1:]),
"Version: "+release["version"],
Expand All @@ -35,10 +35,12 @@ def buildheader(release, filepath , pyiver="None"):
]
if pyiver != "None":
lines.append(f"Python version: Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}{sys.version_info.releaselevel} ({platform.python_implementation()})")
lines.append("Platform: "+platform.system()+" "+platform.architecture()[0])
if platform.system() == "Linux":
lines.append(f"Platform: {platform.system()} {platform.architecture()[0]}")
if platform.system() == "Windows" and winever is not None:
lines.append(f"Built on Wine Version: {winever}")
elif platform.system() == "Linux":
lines.append(f"LibC: {platform.libc_ver()[0]} {platform.libc_ver()[1]}")
lines.append("PyInstaller version: "+pyiver)
lines.append(f"PyInstaller version: {pyiver}")
lines.append("PyInstaller Output:")
with Prepender(filepath) as filehandle:
filehandle.write_lines(lines)
Expand Down Expand Up @@ -184,6 +186,7 @@ def __exit__(self, type, value, traceback):
parser.add_argument("-z", "--zip", action="store_true", help="pack the build to a .zip file")
parser.add_argument("--docker", action="store_true", help='copy build zip to "./docker_output", requires --zip')
parser.add_argument("--githash", action="store", help="gives git commit hash to build script(mostly useful for docker builds)")
parser.add_argument("--winever", action="store", help="gives wine version to build script(mostly useful for docker builds)")

args = parser.parse_args()
#constants
Expand All @@ -198,6 +201,7 @@ def __exit__(self, type, value, traceback):
dockerdir = os.path.abspath("./docker_output")
mainpyifile = "main_ps3gud.py"
updaterpyifile = "updater.py"
winever = None
#get data from release.json
with open("release.json", "r", encoding="utf8") as f:
release = json.loads(f.read())
Expand Down Expand Up @@ -230,6 +234,8 @@ def __exit__(self, type, value, traceback):
if os.path.exists(dockerdir) == False:
os.makedirs(dockerdir)

if args.winever is not None:
winever = args.winever
#auto config for build

suffix = ""
Expand Down Expand Up @@ -390,7 +396,7 @@ def __exit__(self, type, value, traceback):
print(f"copying data to '{builddir}'")
copyData(builddir, locdirname, imagedirname)
#write header to buildlog
buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__)
buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__, winever=winever)
#save commitid
saveCommitId(release, builddir)
#validate & minify json files
Expand Down Expand Up @@ -458,7 +464,7 @@ def __exit__(self, type, value, traceback):
print(f"copying data to '{builddir}'")
copyData(builddir, locdirname, imagedirname, debug=True)
#write header to buildlog
buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__)
buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__, winever=winever)
#save commitid
saveCommitId(release, builddir)
#validate json files
Expand Down
10 changes: 5 additions & 5 deletions dockerfiles/build-linux-win32.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ VOLUME /code/docker_output
RUN apt update -y && apt install wget xvfb git -y
# installing python
RUN wget -O /tmp/python-$PYVER.exe https://www.python.org/ftp/python/$PYVER/python-$PYVER.exe
RUN xvfb-run wine /tmp/python-$PYVER.exe /quiet InstallAllUsers=1 TargetDir=C:\\py32 Include_doc=0 Include_launcher=0 Include_test=0 PrependPath=1
RUN xvfb-run wine /tmp/python-$PYVER.exe /quiet InstallAllUsers=1 TargetDir=C:\\py Include_doc=0 Include_launcher=0 Include_test=0 PrependPath=1
# hack to bypass missing implementation of CopyFile2 in Wine(needed for python 3.12.0 and above)
RUN sed -i 's/"CopyFile2"/"CopyFile2_xx_invalid_disabled"/' /opt/wineprefix/drive_c/py32/Lib/shutil.py
RUN sed -i 's/"CopyFile2"/"CopyFile2_xx_invalid_disabled"/' /opt/wineprefix/drive_c/py/Lib/shutil.py
# copying code
COPY . /code
# installing pip depencies
RUN wine C:\\py32\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip
RUN wine C:\\py32\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt
RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip
RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt
# build
CMD ["sh", "-c", "wine 'C://py32//python.exe' build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD)"]
CMD ["sh", "-c", "wine 'C://py//python.exe' build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD) --winever $(wine --version)"]
15 changes: 11 additions & 4 deletions dockerfiles/build-linux-win64.dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# setup
FROM tobix/pywine:3.12
ENV WINEARCH=win64
# python version to install
ENV PYVER=3.12.0-amd64
WORKDIR /code
VOLUME /code/docker_output
# installing depencies
RUN apt update -y && apt install git -y
RUN apt update -y && apt install wget xvfb git -y
# installing python
RUN wget -O /tmp/python-$PYVER.exe https://www.python.org/ftp/python/$PYVER/python-$PYVER.exe
RUN xvfb-run wine /tmp/python-$PYVER.exe /quiet InstallAllUsers=1 TargetDir=C:\\py Include_doc=0 Include_launcher=0 Include_test=0 PrependPath=1
# hack to bypass missing implementation of CopyFile2 in Wine(needed for python 3.12.0 and above)
RUN sed -i 's/"CopyFile2"/"CopyFile2_xx_invalid_disabled"/' /opt/wineprefix/drive_c/py/Lib/shutil.py
# copying code
COPY . /code
# installing pip depencies
RUN wine python -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip
RUN wine python -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt
RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip
RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt
# build
CMD ["sh", "-c", "wine python build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD)"]
CMD ["sh", "-c", "wine C:\\py\\python.exe build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD) --winever $(wine --version)"]

0 comments on commit e3165e9

Please sign in to comment.