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 broken "Releases" Makefile #13787

Closed
wants to merge 2 commits into from
Closed

Conversation

truboxl
Copy link
Contributor

@truboxl truboxl commented Mar 29, 2021

It's safe to assume all the Makefiles in https://github.com/emscripten-core/emscripten/releases are broken
You can test this by downloading the tarball or zip from there, extract it, cd into it and run make.

I found these problems when trying to package emscripten for Termux / Android. See termux/termux-packages#5043. Should be done prototyping soon...

@truboxl
Copy link
Contributor Author

truboxl commented Mar 29, 2021

Very funny CircleCI... Failing at the last, most irrelevant test :(

@truboxl
Copy link
Contributor Author

truboxl commented Mar 30, 2021

Finally CI works! Forgot to add the errors I am trying to solve...

Problem 1: Extract from releases tarball and run make

~/test $ tar xf 2.0.16.tar.gz
~/test $ cd emscripten-2.0.16/
~/test/emscripten-2.0.16 $ make
./tools/install.py ../emscripten-2.0.16
make: ./tools/install.py: No such file or directory
make: *** [Makefile:9: install] Error 127
~/test/emscripten-2.0.16 $ ls
ls: reading directory '.': No such file or directory

Problem 2: .git does not exist

~/test $ cd emscripten-2.0.16
~/test/emscripten-2.0.16 $ make DESTDIR=../emscripten-2.0.16-alt
./tools/install.py ../emscripten-2.0.16-alt
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Traceback (most recent call last):
  File "/data/data/com.termux/files/home/test/emscripten-2.0.16/./tools/install.py", line 103, in <module>
      sys.exit(main())
  File "/data/data/com.termux/files/home/test/emscripten-2.0.16/./tools/install.py", line 98, in main
      add_revision_file(target)
  File "/data/data/com.termux/files/home/test/emscripten-2.0.16/./tools/install.py", line 41, in add_revision_file
      git_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], encoding='utf-8').strip()
  File "/data/data/com.termux/files/usr/lib/python3.9/subprocess.py", line 424, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/data/data/com.termux/files/usr/lib/python3.9/subprocess.py", line 528, in run
      raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'rev-parse', 'HEAD']' returned non-zero exit status 128.
make: *** [Makefile:9: install] Error 1

@truboxl
Copy link
Contributor Author

truboxl commented Apr 1, 2021

@kripken @sbc100
Any comments?

@sbc100
Copy link
Collaborator

sbc100 commented Apr 5, 2021

I think when I wrote this this Makefile and install.py script it imagined it as a way to generate the source archive.. not as something that could be run from within the source archive (hence the hard dependency on the git directory).

Perhaps we should remove install.py from the source archive? Can you instead just copy the entire archive contents?

Makefile Outdated
@@ -1,5 +1,7 @@
VERSION = $(shell cat emscripten-version.txt | sed s/\"//g)
DESTDIR ?= ../emscripten-$(VERSION)
ifeq ($(DESTDIR),)
DESTDIR := $(shell mktemp -d)/emscripten-$(VERSION)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the ?= syntax good enough here? Do we want to support DESTDIR being empty?

Copy link
Contributor Author

@truboxl truboxl Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, both can handle empty DESTDIR...
The problem is that ?= will have different values when DESTDIR is needed, whereas := is defined once. This is problematic for mktemp -d.
I can't find a one line equivalent of ?= that handles both empty and defined once...

EDIT: looks like this isn't compatible with BSD make, I will think of something else...

@truboxl
Copy link
Contributor Author

truboxl commented Apr 5, 2021

I think when I wrote this this Makefile and install.py script it imagined it as a way to generate the source archive.. not as something that could be run from within the source archive (hence the hard dependency on the git directory).

Perhaps we should remove install.py from the source archive? Can you instead just copy the entire archive contents?

I rely on install.py clean up functionality. It saved quite a lot of spaces. Very beneficial for downstream packaging...

truboxl added 2 commits April 5, 2021 16:15
Using "../emscripten-$(VERSION)" for "DESTDIR" has various problems
Notably it self destructs the source as the extracted sources has the
same name as "DESTDIR"
Fix it by making a unique temporary directory and point there
This is true for all "Releases" extracted sources
@sbc100
Copy link
Collaborator

sbc100 commented Apr 5, 2021

I think when I wrote this this Makefile and install.py script it imagined it as a way to generate the source archive.. not as something that could be run from within the source archive (hence the hard dependency on the git directory).
Perhaps we should remove install.py from the source archive? Can you instead just copy the entire archive contents?

I rely on install.py clean up functionality. It saved quite a lot of spaces. Very beneficial for downstream packaging...

But shouldn't the source archive you down already be the result of "install.py"? Oh no I see now that it is the result of make dist which does not run install.py.

@@ -1,5 +1,6 @@
VERSION = $(shell cat emscripten-version.txt | sed s/\"//g)
DESTDIR ?= ../emscripten-$(VERSION)
TMPDESTDIR := $(shell mktemp -d)
DESTDIR ?= $(TMPDESTDIR)/emscripten-$(VERSION)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand that problem this is solving. Can you explain?

Copy link
Contributor Author

@truboxl truboxl Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

../emscripten-$(VERSION) is exactly the same as $PWD when you first extracted from zip

It will end up delete itself down the line...

EDIT: sorry got confused a bit, err, I think you need to run make just to see what I am getting into

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but as long as you run with make DESTDIR=xxx it should be fine right?

Should we just error out if $DESTDIR already exists instead of deleting it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that running just make and errors out is wrong, lol
and tools/install.py has that error implemented so it must point to folder that is clean

Copy link
Contributor Author

@truboxl truboxl Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now I am not using this Makefile directly anymore as I opted to use the patched install.py. I just want to raise this issue whether it make sense to still use this Makefile from the "Releases" zips...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I suppose that's the way I guess
The archlinux guys seem to package using make install DESTDIR=xxx and from the git repo
https://github.com/archlinux/svntogit-community/blob/packages/emscripten/trunk/PKGBUILD

I think I will try to change from zip archive to git repo source somehow...

@truboxl
Copy link
Contributor Author

truboxl commented Apr 5, 2021

@sbc100
I think I will close this if you are okay with it. I think I can get away from not using "Releases" zips and use git clone now.
So that should solve most of the issues for me...

And because I am actually "cross compiling", the Makefile is also not good as it does a host npm install.
I guess I have to invoke install.py directly.

@truboxl
Copy link
Contributor Author

truboxl commented Apr 10, 2021

I am closing this. Can you please check out termux/termux-packages#6578? Thanks.

@truboxl truboxl closed this Apr 10, 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.

2 participants