diff --git a/Makefile b/Makefile index 30dfd192..9e8a2978 100644 --- a/Makefile +++ b/Makefile @@ -66,19 +66,25 @@ NANO=nano-$(NANO_VERSION) NANO_FILENAME=$(NANO).tar.gz NANO_DOWNLOAD=http://www.nano-editor.org/dist/v2.4/$(NANO_FILENAME) +PYTHON3_VERSION0=3.5 +PYTHON3_VERSION=$(PYTHON3_VERSION0).1 +PYTHON3=Python-$(PYTHON3_VERSION) +PYTHON3_FILENAME=$(PYTHON3).tgz +PYTHON3_DOWNLOAD=https://www.python.org/ftp/python/$(PYTHON3_VERSION)/$(PYTHON3_FILENAME) + TVHEADEND_COMMIT=master # 10663 10937 OSCAM_REV=11211 define GIT_CLONE - @mkdir -p apps/ + @mkdir -p apps/host git clone $(1) apps/$(2) cd apps/$(2) && git checkout -b axe $(3) endef define WGET - @mkdir -p apps/ + @mkdir -p apps/host wget --no-verbose --no-check-certificate -O $(2) $(1) endef @@ -113,11 +119,13 @@ CPIO_SRCS += tools/axehelper CPIO_SRCS += nfsutils CPIO_SRCS += nano CPIO_SRCS += mtd-utils +CPIO_SRCS += python3 fs.cpio: $(CPIO_SRCS) fakeroot tools/do_min_fs.py \ -r "$(VERSION)" \ -b "bash strace openssl" \ + -d "fs-add apps/$(PYTHON3)/dest" \ $(foreach m,$(EXTRA_AXE_MODULES), -e "$(EXTRA_AXE_MODULES_DIR)/$(m):lib/modules/axe/$(m)") \ -e "patches/axe_dmxts_std.ko:lib/modules/axe/axe_dmxts_std.ko" \ $(foreach m,$(ORIG_FILES), -e "$(EXTRA_AXE_MODULES_DIR)/../$(m):lib/modules/axe/$(m)") \ @@ -517,6 +525,110 @@ apps/$(NANO)/nano: apps/$(NANO)/configure .PHONY: nano nano: apps/$(NANO)/nano +# +# python3-host +# + +apps/host/$(PYTHON3)/pyconfig.h.in: + $(call WGET,$(PYTHON3_DOWNLOAD),apps/host/$(PYTHON3_FILENAME)) + tar -C apps/host -xzf apps/host/$(PYTHON3_FILENAME) + +apps/host/$(PYTHON3)/python: apps/host/$(PYTHON3)/pyconfig.h.in + cd apps/host/$(PYTHON3) && \ + ./configure + make -C apps/host/$(PYTHON3) + +.PHONY: python3-host +python3-host: apps/host/$(PYTHON3)/python + +# +# python3 +# + +apps/$(PYTHON3)/pyconfig.h.in: + $(call WGET,$(PYTHON3_DOWNLOAD),apps/$(PYTHON3_FILENAME)) + tar -C apps -xzf apps/$(PYTHON3_FILENAME) + +apps/$(PYTHON3)/patch.stamp: apps/$(PYTHON3)/pyconfig.h.in apps/host/$(PYTHON3)/python + cd apps/$(PYTHON3) && \ + PKG_CONFIG_PATH=$(TOOLCHAIN)/target/usr/lib/pkgconfig \ + PKG_CONFIG=$(TOOLPATH)/pkg-config \ + ARCH=sh \ + CPP=$(TOOLCHAIN)/bin/sh4-linux-cpp \ + CC=$(TOOLCHAIN)/bin/sh4-linux-gcc \ + READELF=/usr/bin/readelf \ + PYTHON_FOR_BUILD=$(CURDIR)/apps/host/$(PYTHON3)/python \ + CONFIG_SITE=$(CURDIR)/patches/python3.config.site \ + ./configure \ + --host=sh4-linux \ + --build=x86_64-redhat-linux \ + --target=sh4-linux \ + --sysconfdir=/etc \ + --prefix=/usr \ + --enable-ipv6=no + cd apps/$(PYTHON3) && patch -b -p0 < ../../patches/python3-makefile.patch + cd apps/$(PYTHON3) && patch -b -p0 < ../../patches/python3-setup.patch + cd apps/$(PYTHON3) && patch -b -p0 < ../../patches/python3-ccompiler.patch + cd apps/$(PYTHON3) && patch -b -p0 < ../../patches/python3-build-ext.patch + touch apps/$(PYTHON3)/patch.stamp + +apps/$(PYTHON3)/compiled.stamp: apps/$(PYTHON3)/patch.stamp + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest + make -C apps/$(PYTHON3) \ + PYINCDIRS="$(CURDIR)/apps/$(PYTHON3):$(CURDIR)/apps/$(PYTHON3)/Include" \ + PYLIBS="." \ + CROSS_COMPILE=yes \ + ABIFLAGS="" \ + PYTHON_FOR_BUILD=$(CURDIR)/apps/host/$(PYTHON3)/python \ + PGEN=$(CURDIR)/apps/host/$(PYTHON3)/Parser/pgen \ + FREEZE_IMPORTLIB=$(CURDIR)/apps/host/$(PYTHON3)/Programs/_freeze_importlib \ + PYTHONPATH=$(CURDIR)/apps/$(PYTHON3)/Lib \ + PYTHON_OPTIMIZE="" \ + PYTHONDONTWRITEBYTECODE=1 \ + _PYTHON_HOST_PLATFORM=linux-sh4 \ + PYTHONPATH="/usr/lib/python3.5:/usr/local/lib/python3.5" \ + DESTDIR=$(CURDIR)/apps/$(PYTHON3)/dest \ + sharedmods sharedinstall libinstall bininstall + rm -f $(CURDIR)/apps/$(PYTHON3)/dest/usr/bin/python*-config + rm -f $(CURDIR)/apps/$(PYTHON3)/dest/usr/bin/2to3* + rm -f $(CURDIR)/apps/$(PYTHON3)/dest/usr/bin/idle* + $(TOOLCHAIN)/bin/sh4-linux-strip $(CURDIR)/apps/$(PYTHON3)/dest/usr/bin/python3* + rm -f $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/*.a + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/test + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/ctypes/test + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/sqlite3 + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/turtle* + rm -f $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/__pycache__/turtle* + rm -f $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/lib-dynload/*test* + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/lib2to3 + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/unittest + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/tkinter + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/idlelib + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/distutils + rm -rf $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/python3*/ensurepip + find $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/ -name "*.opt-[12].pyc" -exec rm {} \; + find $(CURDIR)/apps/$(PYTHON3)/dest/usr/lib/ -name "test_*" -exec rm {} \; + touch apps/$(PYTHON3)/compiled.stamp + +apps/$(PYTHON3)/python1: + make -C apps/$(PYTHON3) \ + PYINCDIRS="$(CURDIR)/apps/$(PYTHON3):$(CURDIR)/apps/$(PYTHON3)/Include" \ + PYLIBS="." \ + CROSS_COMPILE=yes \ + ABIFLAGS="" \ + PYTHON_FOR_BUILD=$(CURDIR)/apps/host/$(PYTHON3)/python \ + PGEN=$(CURDIR)/apps/host/$(PYTHON3)/Parser/pgen \ + FREEZE_IMPORTLIB=$(CURDIR)/apps/host/$(PYTHON3)/Programs/_freeze_importlib \ + PYTHONPATH=$(CURDIR)/apps/$(PYTHON3)/Lib \ + PYTHON_OPTIMIZE="" \ + PYTHONDONTWRITEBYTECODE=1 \ + _PYTHON_HOST_PLATFORM=linux-sh4 \ + DESTDIR=$(CURDIR)/apps/$(PYTHON3)/dest \ + sharedmods + +.PHONY: python3 +python3: apps/$(PYTHON3)/compiled.stamp + # # tvheadend # diff --git a/patches/python3-build-ext.patch b/patches/python3-build-ext.patch new file mode 100644 index 00000000..9468148d --- /dev/null +++ b/patches/python3-build-ext.patch @@ -0,0 +1,14 @@ +--- Lib/distutils/command/build_ext.py.orig 2016-02-23 19:52:34.825132845 +0100 ++++ Lib/distutils/command/build_ext.py 2016-02-23 19:48:54.363347813 +0100 +@@ -677,7 +677,10 @@ + """ + from distutils.sysconfig import get_config_var + ext_path = ext_name.split('.') +- ext_suffix = get_config_var('EXT_SUFFIX') ++ if 'EXT_SUFFIX' in os.environ: ++ ext_suffix = os.environ['EXT_SUFFIX'] ++ else: ++ ext_suffix = get_config_var('EXT_SUFFIX') + return os.path.join(*ext_path) + ext_suffix + + def get_export_symbols(self, ext): diff --git a/patches/python3-ccompiler.patch b/patches/python3-ccompiler.patch new file mode 100644 index 00000000..d0555143 --- /dev/null +++ b/patches/python3-ccompiler.patch @@ -0,0 +1,21 @@ +--- Lib/distutils/ccompiler.py.orig 2016-02-23 18:05:38.709628967 +0100 ++++ Lib/distutils/ccompiler.py 2016-02-23 18:06:05.155956953 +0100 +@@ -329,6 +329,8 @@ + else: + raise TypeError( + "'include_dirs' (if supplied) must be a list of strings") ++ if 'PYINCDIRS' in os.environ: ++ incdirs = os.environ['PYINCDIRS'].split(':') + + if extra is None: + extra = [] +@@ -456,6 +458,9 @@ + raise TypeError("'runtime_library_dirs' (if supplied) " + "must be a list of strings") + ++ if 'PYLIBS' in os.environ: ++ library_dirs = os.environ['PYLIBS'].split(':') ++ + return (libraries, library_dirs, runtime_library_dirs) + + def _need_link(self, objects, output_file): diff --git a/patches/python3-makefile.patch b/patches/python3-makefile.patch new file mode 100644 index 00000000..f9cd1276 --- /dev/null +++ b/patches/python3-makefile.patch @@ -0,0 +1,52 @@ +--- Makefile.orig 2016-02-23 19:36:13.488682264 +0100 ++++ Makefile 2016-02-23 19:49:55.755131424 +0100 +@@ -610,7 +610,7 @@ + *) quiet="";; \ + esac; \ + $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ +- _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ ++ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' EXT_SUFFIX='$(EXT_SUFFIX)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build + + # Build static library +@@ -720,17 +720,19 @@ + ############################################################################ + # Importlib + ++FREEZE_IMPORTLIB ?= ./Programs/_freeze_importlib ++ + Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile + + Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) + $(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) + + Python/importlib_external.h: $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib +- ./Programs/_freeze_importlib \ ++ $(FREEZE_IMPORTLIB) \ + $(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h + + Python/importlib.h: $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib +- ./Programs/_freeze_importlib \ ++ $(FREEZE_IMPORTLIB) \ + $(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h + + +@@ -797,9 +799,6 @@ + $(GRAMMAR_C): $(GRAMMAR_H) + touch $(GRAMMAR_C) + +-$(PGEN): $(PGENOBJS) +- $(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) +- + Parser/grammar.o: $(srcdir)/Parser/grammar.c \ + $(srcdir)/Include/token.h \ + $(srcdir)/Include/grammar.h +@@ -1606,7 +1605,7 @@ + rm -rf $(COVERAGE_REPORT) + + clobber: clean profile-removal +- -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ ++ -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ + tags TAGS \ + config.cache config.log pyconfig.h Modules/config.c + -rm -rf build platform diff --git a/patches/python3-setup.patch b/patches/python3-setup.patch new file mode 100644 index 00000000..727e11ba --- /dev/null +++ b/patches/python3-setup.patch @@ -0,0 +1,12 @@ +--- setup.py~ 2015-12-07 02:39:11.000000000 +0100 ++++ setup.py 2016-02-23 15:07:35.315758509 +0100 +@@ -367,7 +367,8 @@ + spec = importlib.util.spec_from_file_location(ext.name, ext_filename, + loader=loader) + try: +- importlib._bootstrap._load(spec) ++ # importlib._bootstrap._load(spec) ++ aaaa = 1 + except ImportError as why: + self.failed_on_import.append(ext.name) + self.announce('*** WARNING: renaming "%s" since importing it' diff --git a/patches/python3.config.site b/patches/python3.config.site new file mode 100644 index 00000000..bd676e72 --- /dev/null +++ b/patches/python3.config.site @@ -0,0 +1,2 @@ +ac_cv_file__dev_ptmx=yes +ac_cv_file__dev_ptc=no diff --git a/tools/do_min_fs.py b/tools/do_min_fs.py index fdab3220..6a015268 100755 --- a/tools/do_min_fs.py +++ b/tools/do_min_fs.py @@ -358,14 +358,16 @@ def get_menu_opt(argv): try: # opts = '' # args = '' - opts , args = getopt.gnu_getopt(argv, 'hb:e:t:i:r:', - ['--init_type', '--binary=', '--extra', '--target_prefix=', '--version', '--help']) + opts , args = getopt.gnu_getopt(argv, 'hb:e:d:t:i:r:', + ['--init_type', '--binary=', '--extra', '--extradir', + '--target_prefix=', '--version', '--help']) except getopt.GetoptError: usage() target_prefix = '' console = '' binary_list=[] extra_list=[] + extradir_list=[] version = '' for o, v in opts: if o == '-b' or o == '--binary': @@ -374,10 +376,15 @@ def get_menu_opt(argv): if i != '': binary_list.append(i) elif o == '-e' or o == '--extra': - v = v.split(' ') # take out all blank spaces and replace the v string with binary_list + v = v.split(' ') for i in v: if i != '': extra_list.append(i) + elif o == '-d' or o == '--extradir': + v = v.split(' ') + for i in v: + if i != '': + extradir_list.append(i) elif o == '-t' or o == '--target_prefix': target_prefix = v elif o == '-i' or o == '--init_type': @@ -391,6 +398,7 @@ def get_menu_opt(argv): params.append(console) params.append(target_prefix) params.append(extra_list) + params.append(extradir_list) params.append(version) return params @@ -509,7 +517,8 @@ user_param = ['', '', ''] user_param = get_menu_opt(sys.argv[1:]) bin_list = user_param[0] # command list to find extra_list = user_param[3] -version = user_param[4] +extradir_list = user_param[4] +version = user_param[5] if user_param[1] != '': boot_type = user_param[1] # default busybox @@ -574,7 +583,8 @@ print ' ' + 30*'=' + '\n' gen_fs(library_list, boot_type) run_cmd('rm -v fs/etc/inittabBB fs/etc/init.d/rcSBB') -run_cmd('cp -av fs-add/* fs') +for d in extradir_list: + run_cmd('cp -av ' + d + '/* fs') f = open("fs/etc/motd") b = f.read(1024*1024) f.close()