Skip to contentSkip to conversation

package/python-web2py: cleaning for space saving

PATCH Superseded Angelo Compagnucci 4 participants 5 messages Jul 28, 2015 – Feb 23, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 package/python-web2py: cleaning for space saving

This patch removes from web2py folder welcome, examples application and a bunch of other files uneeded in production, furthermore, it removes the admin interface if unneeded.

---
Changes:

v3->v4:
* Fixed erroneously removed installation of system v init script

v2->v3:
* Changed to a positive logic for PYTHON_WEB2PY_INSTALL_ADMIN (suggested by Thomas)
* Changed to a makefile based conditional logic (suggested by Thomas)
* Extended cleaning of uneeded files.

v1->v2:
* Reworked otion sequence as suggested by Thomas.
* Changed to a makefile based conditional as suggested by Thomas.

 package/python-web2py/Config.in        | 11 +++++++++++
 package/python-web2py/python-web2py.mk | 36 ++++++++++++++++++++++++++++++----
 2 files changed, 43 insertions(+), 4 deletions(-)
package/python-web2py/Config.in +11 -0
index b10d3a4..3b55153 100644
@@ -14,6 +14,15 @@ config BR2_PACKAGE_PYTHON_WEB2PY
 
 if BR2_PACKAGE_PYTHON_WEB2PY
 
+config BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN
+	bool "install admin panel application"
+	default y
+	help
+	  This option install web2py admin panel application.
+	  It can be removed to save space on embedded systems.
+
+if BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN
+
 config BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD
 	string "admin panel password"
 	default web2py
@@ -21,3 +30,5 @@ config BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD
 	  Set the admin panel password.
 
 endif
+
+endif
package/python-web2py/python-web2py.mk +32 -4
index 313114a..be95517 100644
@@ -11,13 +11,41 @@ PYTHON_WEB2PY_LICENSE_FILES = LICENSE
 PYTHON_WEB2PY_DEPENDENCIES = python python-pydal host-python-pydal
 
 define PYTHON_WEB2PY_INSTALL_TARGET_CMDS
-	$(HOST_DIR)/usr/bin/python2 -c 'import os; \
-		os.chdir("$(@D)"); \
-		from gluon.main import save_password; \
-		save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)'
 	mkdir -p $(TARGET_DIR)/var/www/web2py
 	cp -dpfr $(@D)/* $(TARGET_DIR)/var/www/web2py
+	rm -rf $(TARGET_DIR)/var/www/web2py/welcome.w2p
+	rm -rf $(TARGET_DIR)/var/www/web2py/applications/examples
+	rm -rf $(TARGET_DIR)/var/www/web2py/applications/welcome
+	rm -rf $(TARGET_DIR)/var/www/web2py/deposit
+	rm -rf $(TARGET_DIR)/var/www/web2py/docs
+	rm -rf $(TARGET_DIR)/var/www/web2py/examples
+	rm -rf $(TARGET_DIR)/var/www/web2py/extras
+	rm -rf $(TARGET_DIR)/var/www/web2py/handlers
+	rm -rf $(TARGET_DIR)/var/www/web2py/scripts
+	rm -rf $(TARGET_DIR)/var/www/web2py/ABOUT
+	rm -rf $(TARGET_DIR)/var/www/web2py/anyserver.py
+	rm -rf $(TARGET_DIR)/var/www/web2py/CHANGELOG
+	rm -rf $(TARGET_DIR)/var/www/web2py/Makefile
+	rm -rf $(TARGET_DIR)/var/www/web2py/MANIFEST.in
+	rm -rf $(TARGET_DIR)/var/www/web2py/README.markdown
+	rm -rf $(TARGET_DIR)/var/www/web2py/setup.py
+	rm -rf $(TARGET_DIR)/var/www/web2py/tox.ini
+endef
+
+ifeq ($(BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN),y)
+define PYTHON_WEB2PY_GENERATE_PASSWORD
+	$(HOST_DIR)/usr/bin/python2 -c 'import os; \
+	os.chdir("$(@D)"); \
+	from gluon.main import save_password; \
+	save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)';
+endef
+PYTHON_WEB2PY_POST_BUILD_HOOKS += PYTHON_WEB2PY_GENERATE_PASSWORD
+else
+define PYTHON_WEB2PY_REMOVE_ADMIN
+	rm -rf $(TARGET_DIR)/var/www/web2py/applications/admin
 endef
+PYTHON_WEB2PY_POST_INSTALL_TARGET_HOOKS += PYTHON_WEB2PY_REMOVE_ADMIN
+endif
 
 define PYTHON_WEB2PY_INSTALL_INIT_SYSV
 	$(INSTALL) -m 0755 -D package/python-web2py/S51web2py \
Signature · 1 line
1.9.1
#1 lore raw

PATCH v4 1/1 package/python-web2py: cleaning for space saving

Dear Yann E. MORIN,

This patch works and applies cleanly on master, I just rebased and tested.

2015-07-28 10:04 GMT+02:00 Angelo Compagnucci <[email protected]>:

Quoted 103 lines

This patch removes from web2py folder welcome, examples application and a bunch of other files uneeded in production, furthermore, it removes the admin interface if unneeded.

---
Changes:

v3->v4:
* Fixed erroneously removed installation of system v init script

v2->v3:
* Changed to a positive logic for PYTHON_WEB2PY_INSTALL_ADMIN (suggested by Thomas)
* Changed to a makefile based conditional logic (suggested by Thomas)
* Extended cleaning of uneeded files.

v1->v2:
* Reworked otion sequence as suggested by Thomas.
* Changed to a makefile based conditional as suggested by Thomas.

 package/python-web2py/Config.in        | 11 +++++++++++
 package/python-web2py/python-web2py.mk | 36 ++++++++++++++++++++++++++++++----
 2 files changed, 43 insertions(+), 4 deletions(-)
package/python-web2py/Config.in +11 -0
index b10d3a4..3b55153 100644
@@ -14,6 +14,15 @@ config BR2_PACKAGE_PYTHON_WEB2PY
 
 if BR2_PACKAGE_PYTHON_WEB2PY
 
+config BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN
+       bool "install admin panel application"
+       default y
+       help
+         This option install web2py admin panel application.
+         It can be removed to save space on embedded systems.
+
+if BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN
+
 config BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD
        string "admin panel password"
        default web2py
@@ -21,3 +30,5 @@ config BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD
          Set the admin panel password.
 
 endif
+
+endif
package/python-web2py/python-web2py.mk +32 -5
index 313114a..be95517 100644
@@ -11,13 +11,41 @@ PYTHON_WEB2PY_LICENSE_FILES = LICENSE
 PYTHON_WEB2PY_DEPENDENCIES = python python-pydal host-python-pydal
 
 define PYTHON_WEB2PY_INSTALL_TARGET_CMDS
-       $(HOST_DIR)/usr/bin/python2 -c 'import os; \
-               os.chdir("$(@D)"); \
-               from gluon.main import save_password; \
-               save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)'
        mkdir -p $(TARGET_DIR)/var/www/web2py
        cp -dpfr $(@D)/* $(TARGET_DIR)/var/www/web2py
+       rm -rf $(TARGET_DIR)/var/www/web2py/welcome.w2p
+       rm -rf $(TARGET_DIR)/var/www/web2py/applications/examples
+       rm -rf $(TARGET_DIR)/var/www/web2py/applications/welcome
+       rm -rf $(TARGET_DIR)/var/www/web2py/deposit
+       rm -rf $(TARGET_DIR)/var/www/web2py/docs
+       rm -rf $(TARGET_DIR)/var/www/web2py/examples
+       rm -rf $(TARGET_DIR)/var/www/web2py/extras
+       rm -rf $(TARGET_DIR)/var/www/web2py/handlers
+       rm -rf $(TARGET_DIR)/var/www/web2py/scripts
+       rm -rf $(TARGET_DIR)/var/www/web2py/ABOUT
+       rm -rf $(TARGET_DIR)/var/www/web2py/anyserver.py
+       rm -rf $(TARGET_DIR)/var/www/web2py/CHANGELOG
+       rm -rf $(TARGET_DIR)/var/www/web2py/Makefile
+       rm -rf $(TARGET_DIR)/var/www/web2py/MANIFEST.in
+       rm -rf $(TARGET_DIR)/var/www/web2py/README.markdown
+       rm -rf $(TARGET_DIR)/var/www/web2py/setup.py
+       rm -rf $(TARGET_DIR)/var/www/web2py/tox.ini
+endef
+
+ifeq ($(BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN),y)
+define PYTHON_WEB2PY_GENERATE_PASSWORD
+       $(HOST_DIR)/usr/bin/python2 -c 'import os; \
+       os.chdir("$(@D)"); \
+       from gluon.main import save_password; \
+       save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)';
+endef
+PYTHON_WEB2PY_POST_BUILD_HOOKS += PYTHON_WEB2PY_GENERATE_PASSWORD
+else
+define PYTHON_WEB2PY_REMOVE_ADMIN
+       rm -rf $(TARGET_DIR)/var/www/web2py/applications/admin
 endef
+PYTHON_WEB2PY_POST_INSTALL_TARGET_HOOKS += PYTHON_WEB2PY_REMOVE_ADMIN
+endif
 
 define PYTHON_WEB2PY_INSTALL_INIT_SYSV
        $(INSTALL) -m 0755 -D package/python-web2py/S51web2py \
--

1.9.1

Signature · 1 line
Profile: http://it.linkedin.com/in/compagnucciangelo
#2 lore raw

PATCH v4 1/1 package/python-web2py: cleaning for space saving

Quoted 79 lines · Angelo Compagnucci

Dear Yann E. MORIN,

This patch works and applies cleanly on master, I just rebased and tested.

2015-07-28 10:04 GMT+02:00 Angelo Compagnucci <[email protected]>:

Quoted 73 lines

This patch removes from web2py folder welcome, examples application and a bunch of other files uneeded in production, furthermore, it removes the admin interface if unneeded.

---
Changes:

v3->v4:
* Fixed erroneously removed installation of system v init script

v2->v3:
* Changed to a positive logic for PYTHON_WEB2PY_INSTALL_ADMIN (suggested by Thomas)
* Changed to a makefile based conditional logic (suggested by Thomas)
* Extended cleaning of uneeded files.

v1->v2:
* Reworked otion sequence as suggested by Thomas.
* Changed to a makefile based conditional as suggested by Thomas.

 package/python-web2py/Config.in        | 11 +++++++++++
 package/python-web2py/python-web2py.mk | 36 ++++++++++++++++++++++++++++++----
 2 files changed, 43 insertions(+), 4 deletions(-)
package/python-web2py/Config.in +11 -0
index b10d3a4..3b55153 100644
@@ -14,6 +14,15 @@ config BR2_PACKAGE_PYTHON_WEB2PY
 
 if BR2_PACKAGE_PYTHON_WEB2PY
 
+config BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN
+       bool "install admin panel application"
+       default y
+       help
+         This option install web2py admin panel application.
+         It can be removed to save space on embedded systems.
+
+if BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN
+
 config BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD
        string "admin panel password"
        default web2py
@@ -21,3 +30,5 @@ config BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD
          Set the admin panel password.
 
 endif
+
+endif
package/python-web2py/python-web2py.mk +9 -4
index 313114a..be95517 100644
@@ -11,13 +11,41 @@ PYTHON_WEB2PY_LICENSE_FILES = LICENSE
 PYTHON_WEB2PY_DEPENDENCIES = python python-pydal host-python-pydal
 
 define PYTHON_WEB2PY_INSTALL_TARGET_CMDS
-       $(HOST_DIR)/usr/bin/python2 -c 'import os; \
-               os.chdir("$(@D)"); \
-               from gluon.main import save_password; \
-               save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)'
        mkdir -p $(TARGET_DIR)/var/www/web2py
        cp -dpfr $(@D)/* $(TARGET_DIR)/var/www/web2py
+       rm -rf $(TARGET_DIR)/var/www/web2py/welcome.w2p
+       rm -rf $(TARGET_DIR)/var/www/web2py/applications/examples
+       rm -rf $(TARGET_DIR)/var/www/web2py/applications/welcome
+       rm -rf $(TARGET_DIR)/var/www/web2py/deposit
+       rm -rf $(TARGET_DIR)/var/www/web2py/docs
+       rm -rf $(TARGET_DIR)/var/www/web2py/examples
+       rm -rf $(TARGET_DIR)/var/www/web2py/extras
+       rm -rf $(TARGET_DIR)/var/www/web2py/handlers
+       rm -rf $(TARGET_DIR)/var/www/web2py/scripts
Quoted 8 lines

package/python-web2py/python-web2py.mk PYTHON_WEB2PY_LICENSE_FILES = LICENSE · line 32

Quoted 8 lines
package/python-web2py/python-web2py.mk +8 -0
+       rm -rf $(TARGET_DIR)/var/www/web2py/ABOUT
+       rm -rf $(TARGET_DIR)/var/www/web2py/anyserver.py
+       rm -rf $(TARGET_DIR)/var/www/web2py/CHANGELOG
+       rm -rf $(TARGET_DIR)/var/www/web2py/Makefile
+       rm -rf $(TARGET_DIR)/var/www/web2py/MANIFEST.in
+       rm -rf $(TARGET_DIR)/var/www/web2py/README.markdown
+       rm -rf $(TARGET_DIR)/var/www/web2py/setup.py
+       rm -rf $(TARGET_DIR)/var/www/web2py/tox.ini

I would have found it cleaner to avoid copying all these files to begin with,
by using rsync with --exclude to copy the files. Then you can have the exclusions in a variable:

PYTHON_WEB2PY_EXCLUSIONS = \
	welcome.w2p \
	applications/examples \

...

	rsync -a $(@D)/ $(TARGET_DIR)/var/www/web2py/ \
		$(addprefix --exclude=,$(PYTHON_WEB2PY_EXCLUSIONS))

But regardless of that:

Regards,
Arnout

Quoted 25 lines
Quoted 22 lines
package/python-web2py/python-web2py.mk +15 -1
+endef
+
+ifeq ($(BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN),y)
+define PYTHON_WEB2PY_GENERATE_PASSWORD
+       $(HOST_DIR)/usr/bin/python2 -c 'import os; \
+       os.chdir("$(@D)"); \
+       from gluon.main import save_password; \
+       save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)';
+endef
+PYTHON_WEB2PY_POST_BUILD_HOOKS += PYTHON_WEB2PY_GENERATE_PASSWORD
+else
+define PYTHON_WEB2PY_REMOVE_ADMIN
+       rm -rf $(TARGET_DIR)/var/www/web2py/applications/admin
 endef
+PYTHON_WEB2PY_POST_INSTALL_TARGET_HOOKS += PYTHON_WEB2PY_REMOVE_ADMIN
+endif
 
 define PYTHON_WEB2PY_INSTALL_INIT_SYSV
        $(INSTALL) -m 0755 -D package/python-web2py/S51web2py \
--

1.9.1

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH v4 1/1 package/python-web2py: cleaning for space saving

In reply to Angelo Compagnucci

Angelo, All,

On 2015-07-28 10:04 +0200, Angelo Compagnucci spake thusly:

Quoted 3 lines

This patch removes from web2py folder welcome, examples application and a bunch of other files uneeded in production, furthermore, it removes the admin interface if unneeded.

Well, I think this should have been two commits:
- one to get rid of the admin interface
- one to get rid of unnecessary files

See mor ecomments below...

Quoted 1 line

[--SNIP--]

Quoted 31 lines
package/python-web2py/python-web2py.mk +17 -4
index 313114a..be95517 100644
@@ -11,13 +11,41 @@ PYTHON_WEB2PY_LICENSE_FILES = LICENSE
 PYTHON_WEB2PY_DEPENDENCIES = python python-pydal host-python-pydal
 
 define PYTHON_WEB2PY_INSTALL_TARGET_CMDS
-	$(HOST_DIR)/usr/bin/python2 -c 'import os; \
-		os.chdir("$(@D)"); \
-		from gluon.main import save_password; \
-		save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)'
 	mkdir -p $(TARGET_DIR)/var/www/web2py
 	cp -dpfr $(@D)/* $(TARGET_DIR)/var/www/web2py
+	rm -rf $(TARGET_DIR)/var/www/web2py/welcome.w2p
+	rm -rf $(TARGET_DIR)/var/www/web2py/applications/examples
+	rm -rf $(TARGET_DIR)/var/www/web2py/applications/welcome
+	rm -rf $(TARGET_DIR)/var/www/web2py/deposit
+	rm -rf $(TARGET_DIR)/var/www/web2py/docs
+	rm -rf $(TARGET_DIR)/var/www/web2py/examples
+	rm -rf $(TARGET_DIR)/var/www/web2py/extras
+	rm -rf $(TARGET_DIR)/var/www/web2py/handlers
+	rm -rf $(TARGET_DIR)/var/www/web2py/scripts
+	rm -rf $(TARGET_DIR)/var/www/web2py/ABOUT
+	rm -rf $(TARGET_DIR)/var/www/web2py/anyserver.py
+	rm -rf $(TARGET_DIR)/var/www/web2py/CHANGELOG
+	rm -rf $(TARGET_DIR)/var/www/web2py/Makefile
+	rm -rf $(TARGET_DIR)/var/www/web2py/MANIFEST.in
+	rm -rf $(TARGET_DIR)/var/www/web2py/README.markdown
+	rm -rf $(TARGET_DIR)/var/www/web2py/setup.py
+	rm -rf $(TARGET_DIR)/var/www/web2py/tox.ini

package/python-web2py/python-web2py.mk PYTHON_WEB2PY_LICENSE_FILES = LICENSE · line 42

Quoted 10 lines
package/python-web2py/python-web2py.mk +10 -0
+endef
+
+ifeq ($(BR2_PACKAGE_PYTHON_WEB2PY_INSTALL_ADMIN),y)
+define PYTHON_WEB2PY_GENERATE_PASSWORD
+	$(HOST_DIR)/usr/bin/python2 -c 'import os; \
+	os.chdir("$(@D)"); \
+	from gluon.main import save_password; \
+	save_password($(BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD),8000)';
+endef
+PYTHON_WEB2PY_POST_BUILD_HOOKS += PYTHON_WEB2PY_GENERATE_PASSWORD

Previously, the password was generated at install time; now, it is generated at build time. Why?

If I read the thing corretly, that's because the password was previously generated before the files were being copied. So I think you could have used a pre-install hook to generate the password, keeping the same sequence as we have today:

    PYTHON_WEB2PY_PRE_INSTALL_TARGET_HOOKS += PYTHON_WEB2PY_GENERATE_PASSWORD

However, I think that is is correct and better to generate it at the end of the build. It would have warranted a bit of explanations in the commit log, though.

Regards,
Yann E. MORIN.

Quoted 16 lines
package/python-web2py/python-web2py.mk +5 -0
+else
+define PYTHON_WEB2PY_REMOVE_ADMIN
+	rm -rf $(TARGET_DIR)/var/www/web2py/applications/admin
 endef
+PYTHON_WEB2PY_POST_INSTALL_TARGET_HOOKS += PYTHON_WEB2PY_REMOVE_ADMIN
+endif
 
 define PYTHON_WEB2PY_INSTALL_INIT_SYSV
 	$(INSTALL) -m 0755 -D package/python-web2py/S51web2py \
Signature · 6 lines
1.9.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH v4 1/1 package/python-web2py: cleaning for space saving

In reply to Angelo Compagnucci

Angelo,

Quoted 5 lines · Angelo Compagnucci

This patch removes from web2py folder welcome, examples application and a bunch of other files uneeded in production, furthermore, it removes the admin interface if unneeded.

I saw this old patch having Reviewed-by from Arnout and Yann and was therefore tempted to apply it. However, I believe Arnout and Yann made some very valuable comments before giving their Reviewed-by, and I would prefer to see those comments be implemented rather than applying the patch as-is.

To sum-up, the comments are:

* Split in three patches: 1/ clean-up the installation, 2/ add option to remove the admin interface, 3/ move the admin password generation from install time to build time. This will also mean you'll have more detailed commit log, which will also fulfill a comment made by Yann.

* Use rsync with exclude to copy only the useful files

Could you rework this patch to take into account those comments?

Thanks a lot!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com