Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ls-files quoting #457

Merged
merged 1 commit into from
Feb 18, 2021
Merged

Conversation

quozl
Copy link
Contributor

@quozl quozl commented Feb 12, 2021

File names are quoted and then mishandled by the builder.
http://lists.sugarlabs.org/archive/sugar-devel/2021-February/058971.html

Use null-terminated files.

Untested.

@chimosky
Copy link
Member

chimosky commented Feb 14, 2021

Tested, goes into an infinite loop with error;

Traceback (most recent call last):
  File "./setup.py", line 20, in <module>
    bundlebuilder.start()
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 651, in start
    globals()['cmd_' + (options.command or '')](config, options)
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 514, in cmd_dist_source
    packager.package()
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 272, in package
    for f in self.get_files_in_git():
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 222, in get_files_in_git
    sub_list = self.get_files_in_git(sub_path)
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 222, in get_files_in_git
    sub_list = self.get_files_in_git(sub_path)
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 222, in get_files_in_git
    sub_list = self.get_files_in_git(sub_path)
  [Previous line repeated 984 more times]
  File "/usr/lib/python3.7/dist-packages/sugar3/activity/bundlebuilder.py", line 196, in get_files_in_git
    cwd=root)
  File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1443, in _execute_child
    for dir in os.get_exec_path(env))
  File "/usr/lib/python3.7/os.py", line 634, in get_exec_path
    warnings.simplefilter("ignore", BytesWarning)
  File "/usr/lib/python3.7/warnings.py", line 179, in simplefilter
    _add_filter(action, None, category, None, lineno, append=append)
  File "/usr/lib/python3.7/warnings.py", line 186, in _add_filter
    filters.remove(item)
RecursionError: maximum recursion depth exceeded in comparison

Looking more into it.

@chimosky
Copy link
Member

Took a look and I'm yet to figure out why it goes into an infinite loop even when ignore is True.

@quozl
Copy link
Contributor Author

quozl commented Feb 17, 2021

Looked into it, but could not reproduce your problem easily. Used sugarlabs/flipsticks@eb48ca9.

/home/guest/flipsticks-activity/po/hus.po:209: duplicate message definition...
/home/guest/flipsticks-activity/po/hus.po:207: ...this is the location of the first definition
msgfmt: found 1 fatal error
ERROR - msgfmt failed with return code 1.
Traceback (most recent call last):
  File "/home/guest/flipsticks-activity/./setup.py", line 20, in <module>
    bundlebuilder.start()
  File "/usr/lib/python3/dist-packages/sugar3/activity/bundlebuilder.py", line 649, in start
    globals()['cmd_' + (options.command or '')](config, options)
  File "/usr/lib/python3/dist-packages/sugar3/activity/bundlebuilder.py", line 496, in cmd_dist_xo
    packager = XOPackager(Builder(config, no_fail))
  File "/usr/lib/python3/dist-packages/sugar3/activity/bundlebuilder.py", line 243, in __init__
    self.builder.build_locale()
  File "/usr/lib/python3/dist-packages/sugar3/activity/bundlebuilder.py", line 159, in build_locale
    cat = gettext.GNUTranslations(open(mo_file, 'rb'))
FileNotFoundError: [Errno 2] No such file or directory: '/home/guest/flipsticks-activity/locale/hus/LC_MESSAGES/org.worldwideworkshop.olpc.FlipSticks.mo'

Removing po/hus.po does uncover;

Traceback (most recent call last):
  File "/home/guest/flipsticks-activity/./setup.py", line 20, in <module>
    bundlebuilder.start()
  File "/usr/lib/python3/dist-packages/sugar3/activity/bundlebuilder.py", line 649, in start
    globals()['cmd_' + (options.command or '')](config, options)
  File "/usr/lib/python3/dist-packages/sugar3/activity/bundlebuilder.py", line 497, in cmd_dist_xo
    packager.package()
  File "/usr/lib/python3/dist-packages/sugar3/activity/bundlebuilder.py", line 252, in package
    bundle_zip.write(os.path.join(self.config.source_dir, f),
  File "/usr/lib/python3.9/zipfile.py", line 1727, in write
    zinfo = ZipInfo.from_file(filename, arcname,
  File "/usr/lib/python3.9/zipfile.py", line 501, in from_file
    st = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/guest/flipsticks-activity/"lessons/es/Introducci\\303\\263n.txt"'

Made a local copy of sugar3;

guest@bullseye:~/flipsticks-activity$ sudo cp -rl /usr/lib/python3/dist-packages/sugar3 .
guest@bullseye:~/flipsticks-activity$ sudo chown -R guest:guest sugar3
guest@bullseye:~/flipsticks-activity$ ./setup.py dist_xo
Traceback (most recent call last):
  File "/home/guest/flipsticks-activity/./setup.py", line 20, in <module>
    bundlebuilder.start()
  File "/home/guest/flipsticks-activity/sugar3/activity/bundlebuilder.py", line 649, in start
    globals()['cmd_' + (options.command or '')](config, options)
  File "/home/guest/flipsticks-activity/sugar3/activity/bundlebuilder.py", line 497, in cmd_dist_xo
    packager.package()
  File "/home/guest/flipsticks-activity/sugar3/activity/bundlebuilder.py", line 252, in package
    bundle_zip.write(os.path.join(self.config.source_dir, f),
  File "/usr/lib/python3.9/zipfile.py", line 1727, in write
    zinfo = ZipInfo.from_file(filename, arcname,
  File "/usr/lib/python3.9/zipfile.py", line 501, in from_file
    st = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/guest/flipsticks-activity/"lessons/es/Introducci\\303\\263n.txt"'

Paths in traceback show local bundlebuilder is used. Check.

Applied my patch, and a CPU loop occurs for a while then RecursionError.

It would appear the coding is not defensive. 😁

Pushed a fix.

File names are quoted and then mishandled by the builder.
http://lists.sugarlabs.org/archive/sugar-devel/2021-February/058971.html

Use null-terminated files.
@quozl quozl marked this pull request as ready for review February 17, 2021 04:45
@chimosky
Copy link
Member

Tested, works as expected. Thanks.

@chimosky chimosky merged commit bc0f3cc into sugarlabs:master Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants