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

Make it easier to supply custom archive to packit srpm #566

Closed
TomasTomecek opened this issue Oct 14, 2019 · 18 comments · Fixed by #651
Closed

Make it easier to supply custom archive to packit srpm #566

TomasTomecek opened this issue Oct 14, 2019 · 18 comments · Fixed by #651
Labels
area/user-experience Usability issue kind/feature New feature or a request for enhancement. triaged This issue was already processed by the team.

Comments

@TomasTomecek
Copy link
Member

TomasTomecek commented Oct 14, 2019

I see. Makes sense. But it would be good to have a little bit more easier / straightforward way how to prepare the upstream archive. For fmf I had to add three Makefile targets plus this:

   current_version_command: ["make", "packit-version"]

   actions:
       create-archive:
       - make packit-tarball
       - make packit-path

I believe it should be much simpler/shorter/obvious.

Originally posted by @psss in packit/packit-service#103 (comment)

@TomasTomecek TomasTomecek added kind/feature New feature or a request for enhancement. area/user-experience Usability issue labels Oct 14, 2019
@jpopelka
Copy link
Member

jpopelka commented Dec 5, 2019

AI:
Write down documentation on how to do this the easiest way.
Deprecate dedicated config options for getting version and creating archive command for sake of actions.

@jpopelka jpopelka added the triaged This issue was already processed by the team. label Dec 5, 2019
@psss
Copy link

psss commented Dec 5, 2019

So there is already a better way, just not yet documented? Or the implementation is also in progress?

@lachmanfrantisek
Copy link
Member

lachmanfrantisek commented Dec 5, 2019

So there is already a better way, just not yet documented? Or the implementation is also in progress?

  • We need to document the prefered way for the current state at first. (It's definitely not so clear now.)
  • We support some values that were replaced by the actions (e.g. current_version_command).
    • We want to get rid of those.
  • After that, we can simplify the config or support more workflows so less people needs to do it.
    • Do you have some better way, how it can be configured?

@psss
Copy link

psss commented Dec 13, 2019

I think the best way would be just a single command which would either:

  • show the resulting archive file name in the output (e.g. last line)
  • or store the archive to the location provided in an environment variable

It should not be necessary to configure the current_version_command.

@lachmanfrantisek
Copy link
Member

lachmanfrantisek commented Dec 13, 2019

  • show the resulting archive file name in the output (e.g. last line)

@psss
Copy link

psss commented Jan 6, 2020

Nice, thanks. Trying on psss/edd#10

@psss
Copy link

psss commented Jan 6, 2020

Does not seem to be working:

The create-archive action did not output a path to the
generated archive. Please make sure that an absolute path to
the archive is printed.

Here's the output of the make packit-tarball command:

> make packit-tarball
mkdir -p /home/psss/git/edd/tmp/{SOURCES,edd-0.3}
cp -a LICENSE README.rst Makefile edd.spec edd docs /home/psss/git/edd/tmp/edd-0.3
cp docs/man.rst /home/psss/git/edd/tmp
tail -n+16 README.rst >> /home/psss/git/edd/tmp/man.rst
rst2man /home/psss/git/edd/tmp/man.rst | gzip > /home/psss/git/edd/tmp/edd-0.3/docs/edd.1.gz
rst2html README.rst --stylesheet=style.css --link-stylesheet > /home/psss/git/edd/tmp/edd-0.3/docs/index.html
cd /home/psss/git/edd/tmp && tar cfj SOURCES/edd-0.3.tar.bz2 edd-0.3
/home/psss/git/edd/tmp/SOURCES/edd-0.3.tar.bz2

Is there anything wrong with the file path format? Or anything else needs to be done?

@lachmanfrantisek
Copy link
Member

lachmanfrantisek commented Jan 6, 2020

Is there anything wrong with the file path format? Or anything else needs to be done?

I am just playing with that locally.

@lachmanfrantisek
Copy link
Member

lachmanfrantisek commented Jan 6, 2020

Using user-defined script for ActionName.create_archive: ['make', 'packit-tarball']
13:37:52.794 utils.py          DEBUG  cmd = 'make packit-tarball'
13:37:52.845 utils.py          DEBUG  b'mkdir -p /home/flachman/Projects/psss/edd/tmp/{SOURCES,edd-0.3}'
13:37:52.848 utils.py          DEBUG  b'cp -a LICENSE README.rst Makefile edd.spec edd docs /home/flachman/Projects/psss/edd/tmp/edd-0.3'
13:37:52.852 utils.py          DEBUG  b'cp docs/man.rst /home/flachman/Projects/psss/edd/tmp'
13:37:52.854 utils.py          DEBUG  b'tail -n+16 README.rst >> /home/flachman/Projects/psss/edd/tmp/man.rst'
13:37:52.858 utils.py          DEBUG  b'rst2man /home/flachman/Projects/psss/edd/tmp/man.rst | gzip > /home/flachman/Projects/psss/edd/tmp/edd-0.3/docs/edd.1.gz'
13:37:53.439 utils.py          DEBUG  b'rst2html README.rst --stylesheet=style.css --link-stylesheet > /home/flachman/Projects/psss/edd/tmp/edd-0.3/docs/index.html'
13:37:54.122 utils.py          DEBUG  b'cd /home/flachman/Projects/psss/edd/tmp && tar cfj SOURCES/edd-0.3.tar.bz2 edd-0.3'
13:37:54.141 utils.py          DEBUG  b'/home/flachman/Projects/psss/edd/tmp/SOURCES/edd-0.3.tar.bz2'
13:37:54.142 base_git.py       DEBUG  Action command output: ['mkdir -p /home/flachman/Projects/psss/edd/tmp/{SOURCES,edd-0.3}\ncp -a LICENSE README.rst Makefile edd.spec edd docs /home/flachman/Projects/psss/edd/tmp/edd-0.3\ncp docs/man.rst /home/flachman/Projects/psss/edd/tmp\ntail -n+16 README.rst >> /home/flachman/Projects/psss/edd/tmp/man.rst\nrst2man /home/flachman/Projects/psss/edd/tmp/man.rst | gzip > /home/flachman/Projects/psss/edd/tmp/edd-0.3/docs/edd.1.gz\nrst2html README.rst --stylesheet=style.css --link-stylesheet > /home/flachman/Projects/psss/edd/tmp/edd-0.3/docs/index.html\ncd /home/flachman/Projects/psss/edd/tmp && tar cfj SOURCES/edd-0.3.tar.bz2 edd-0.3\n/home/flachman/Projects/psss/edd/tmp/SOURCES/edd-0.3.tar.bz2\n']
Created archive: /home/flachman/Projects/psss/edd/tmp/SOURCES/edd-0.3.tar.bz2

It looks like the parsing went well but the build failed, because we expect to have the archive in the current directory:

12:37:54.443 utils.py          DEBUG  cmd = 'rpmbuild -bs --define _sourcedir . --define _specdir /home/flachman/Projects/psss/edd --define _srcrpmdir /home/flachman/Projects/psss/edd --define _topdir /home/flachman/Projects/psss/edd --define _builddir /home/flachman/Projects/psss/edd --define _rpmdir /home/flachman/Projects/psss/edd --define _buildrootdir /home/flachman/Projects/psss/edd edd.spec'
b'error: Bad source: ./edd-0.3.tar.bz2: No such file or directory'
ERROR    Command ['rpmbuild', '-bs', '--define', '_sourcedir .', '--define', '_specdir /home/flachman/Projects/psss/edd', '--define', '_srcrpmdir /home/flachman/Projects/psss/edd', '--define', '_topdir /home/flachman/Projects/psss/edd', '--define', '_builddir /home/flachman/Projects/psss/edd', '--define', '_rpmdir /home/flachman/Projects/psss/edd', '--define', '_buildrootdir /home/flachman/Projects/psss/edd', 'edd.spec'] failed
ERROR    Command ['rpmbuild', '-bs', '--define', '_sourcedir .', '--define', '_specdir /home/flachman/Projects/psss/edd', '--define', '_srcrpmdir /home/flachman/Projects/psss/edd', '--define', '_topdir /home/flachman/Projects/psss/edd', '--define', '_builddir /home/flachman/Projects/psss/edd', '--define', '_rpmdir /home/flachman/Projects/psss/edd', '--define', '_buildrootdir /home/flachman/Projects/psss/edd', 'edd.spec'] failed.
ERROR    Failed to create SRPM: PackitCommandFailedError("Command ['rpmbuild', '-bs', '--define', '_sourcedir .', '--define', '_specdir /home/flachman/Projects/psss/edd', '--define', '_srcrpmdir /home/flachman/Projects/psss/edd', '--define', '_topdir /home/flachman/Projects/psss/edd', '--define', '_builddir /home/flachman/Projects/psss/edd', '--define', '_rpmdir /home/flachman/Projects/psss/edd', '--define', '_buildrootdir /home/flachman/Projects/psss/edd', 'edd.spec'] failed: Command ['rpmbuild', '-bs', '--define', '_sourcedir .', '--define', '_specdir /home/flachman/Projects/psss/edd', '--define', '_srcrpmdir /home/flachman/Projects/psss/edd', '--define', '_topdir /home/flachman/Projects/psss/edd', '--define', '_builddir /home/flachman/Projects/psss/edd', '--define', '_rpmdir /home/flachman/Projects/psss/edd', '--define', '_buildrootdir /home/flachman/Projects/psss/edd', 'edd.spec'] failed.")
ERROR    Failed to create SRPM.

@lachmanfrantisek
Copy link
Member

What do you/we preffer?

  • Copy the archive to the root directory.
  • Edit the rpmbuild command to accept other location?
  • Anything else what can be done to fix that?

@psss
Copy link

psss commented Jan 6, 2020

I think the rpmbuild command should not depend on the archive location. If a full path is provided (and if I understand it correctly this is required by packit) then the archive should be taken from that location. No additional steps (such as moving or copying the archive) should be required. Packit should take care of it.

@psss
Copy link

psss commented Jan 6, 2020

Also, while we're looking into this, could we get rid of the current_version_command as well?. Would be nice if the custom tarball could be enabled with just this:

actions:
    create-archive:
    - make packit-tarball

@lachmanfrantisek
Copy link
Member

I am going to fix the archive path in the specfile to be relative to the spec location. (Currently, we use only the filename.)

Also, while we're looking into this, could we get rid of the current_version_command as well?

  • It's an old config value from the times before actions, now we have get-current-version action. (We left that because of the backwards compatibility.)
  • We need to know the version before we run the create_archive command. (e.g. we are forwarding PACKIT_PROJECT_VERSION to the create-archive action)

@lachmanfrantisek
Copy link
Member

I am going to fix the archive path in the specfile to be relative to the spec location. (Currently, we use only the filename.)

OK, that does not work. We need to:

  • change the _sourcedir rpmbuild macro or
  • copy the archive to the root or
  • use absolute path but the srpm can be built only locally because of the absolute path. (?)

@psss
Copy link

psss commented Jan 6, 2020

Changing the _sourcedir macro seems to be the most natural solution to me.

@psss
Copy link

psss commented May 20, 2020

@lachmanfrantisek, so what is now the shortest way to enable custom archive? Something like this?

actions:
  create-archive:
  - make packit-tarball
  - make packit-path
  get-current-version:
  - make packit-version

Or is it possible now to have only a single create-archive command? The following part of the documentation is not clear to me:

If there are more steps, then one of them has to return the archive name.

Should it return the archive name as the last line? Or?

@lachmanfrantisek
Copy link
Member

@psss Your example looks good to me.

Or is it possible now to have only a single create-archive command?

Yes, if it contains archive-name in the output.

If there are more steps, then one of them has to return the archive name.

We run the commands one-by-one and then go through the output in reverse order and for each line of the output (also in the reverse order), we check if it is an existing file. If yes, we accept that as a newly created archive. I know, it's a bit complicated but should work for most situations.

@psss
Copy link

psss commented May 21, 2020

Nice, thanks! Trying with teemtee/tmt#249. Does not work...

Venefilyn pushed a commit to Venefilyn/packit that referenced this issue Oct 24, 2024
Mark recursively searching for a specfile as deprecated

The functionality is going to be removed in the future, see packit#1799.
Related to packit#1771.
Signed-off-by: Hunor Csomortáni [email protected]

Reviewed-by: Jiri Popelka <None>
Reviewed-by: Tomas Tomecek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/user-experience Usability issue kind/feature New feature or a request for enhancement. triaged This issue was already processed by the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants