Wait whats your spec looking like right

Wait, whats your spec looking like right now? You should %global the variable first in the top section and then use that variable later.
44 Replies
bsherman
bsherman•2y ago
lets thread
Arcitec
ArcitecOP•2y ago
Yeah
bsherman
bsherman•2y ago
this is getting busy 😄
Arcitec
ArcitecOP•2y ago
https://src.fedoraproject.org/rpms/sil-charis-fonts/blob/f38/f/sil-charis-fonts.spec This is how they define using the longform, they do a similar thing to what we need. Cutting out a part of a word.
bsherman
bsherman•2y ago
snippets of known file ublue-os-update-services.spec
Source0: ublue-os-update-services.tar.gz

%global project_name %{lua:t=string.gsub("%{NAME}", "^ublue%-os%-", ""); print(t)}

%description
Adds systemd units and configuration files for enabling automatic updates in rpm-ostree and
Source0: ublue-os-update-services.tar.gz

%global project_name %{lua:t=string.gsub("%{NAME}", "^ublue%-os%-", ""); print(t)}

%description
Adds systemd units and configuration files for enabling automatic updates in rpm-ostree and
and...
%files
%dir %attr(0755,root,root) %{_datadir}/%{VENDOR}/%{project_name}
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/system-preset/10-flatpak-system-update.preset
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/system/flatpak-system-update.service
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/system/flatpak-system-update.timer
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/user-preset/10-flatpak-user-update.preset
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/user/flatpak-user-update.service
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/user/flatpak-user-update.timer
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_sysconfdir}/rpm-ostreed.conf
%files
%dir %attr(0755,root,root) %{_datadir}/%{VENDOR}/%{project_name}
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/system-preset/10-flatpak-system-update.preset
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/system/flatpak-system-update.service
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/system/flatpak-system-update.timer
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/user-preset/10-flatpak-user-update.preset
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/user/flatpak-user-update.service
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_exec_prefix}/lib/systemd/user/flatpak-user-update.timer
%attr(0644,root,root) %{_datadir}/%{VENDOR}/%{project_name}/%{_sysconfdir}/rpm-ostreed.conf
Arcitec
ArcitecOP•2y ago
Hmm maybe put %global above the source like they did, right below all the standardized Name: etc. You can use https://pb.envs.net btw 🙂
bsherman
bsherman•2y ago
fair location if global should be fine... that location with shorthand gsub was creating garbage values in the variable
Arcitec
ArcitecOP•2y ago
When you used ${gsub then the variable literally became the word gsub right?
bsherman
bsherman•2y ago
yeah like
error: Directory not found: /tmp/ublue-os/rpmbuild/BUILDROOT/ublue-os-update-services-0.3-1.fc38.x86_64/usr/share/ublue-os/%{gsub:"ublue-os-update-services":"^ublue":""}
error: Directory not found: /tmp/ublue-os/rpmbuild/BUILDROOT/ublue-os-update-services-0.3-1.fc38.x86_64/usr/share/ublue-os/%{gsub:"ublue-os-update-services":"^ublue":""}
Arcitec
ArcitecOP•2y ago
Seems to me like gsub macro shorthand isn't implemented and the docs are old/wrong or maybe even for a newer version than waht Fedora uses
bsherman
bsherman•2y ago
i think the longhand is close, just missing the match
Arcitec
ArcitecOP•2y ago
Yeah The match is tricky, I am guessing the % gets interpreted before passing in I think we need to escpe the %, try the usual things, first %% then \%
bsherman
bsherman•2y ago
yep, was just thinking the same
Arcitec
ArcitecOP•2y ago
%global project_name %{lua:t=string.gsub("%{NAME}", "^ublue%%-os%%-", ""); print(t)}

%global project_name %{lua:t=string.gsub("%{NAME}", "^ublue\%-os\%-", ""); print(t)}
%global project_name %{lua:t=string.gsub("%{NAME}", "^ublue%%-os%%-", ""); print(t)}

%global project_name %{lua:t=string.gsub("%{NAME}", "^ublue\%-os\%-", ""); print(t)}
bsherman
bsherman•2y ago
neither hmm
Arcitec
ArcitecOP•2y ago
Okay try this
%global project_name %{lua:t=string.gsub("%{NAME}", "ublue", ""); print(t)}
%global project_name %{lua:t=string.gsub("%{NAME}", "ublue", ""); print(t)}
Just to see what it does
bsherman
bsherman•2y ago
ok, somethings wrong
Directory not found: /tmp/ublue-os/rpmbuild/BUILDROOT/ublue-os-update-services-0.3-1.fc38.x86_64/usr/share/ublue-os/ublue-os-update-services
Directory not found: /tmp/ublue-os/rpmbuild/BUILDROOT/ublue-os-update-services-0.3-1.fc38.x86_64/usr/share/ublue-os/ublue-os-update-services
using a simple "ublue" match should have at least changed that output
Arcitec
ArcitecOP•2y ago
Yeah that's really mysterious We're basically the same as fedora's own spec now Can you post the full file on https://pb.envs.net ? I saw from what you posted that you're using %{project_name} in the paths though so that's correct. And the longform we are usign is identical to what Fedora uses, including the fact that "" works inside string.gsub()... :/ https://src.fedoraproject.org/rpms/sil-charis-fonts/blob/f38/f/sil-charis-fonts.spec Hmm @bsherman What happens if you do this?
%global project_name %{lua:t=string.gsub("%{NAME}FOO", "ublue", ""); print(t)}
%global project_name %{lua:t=string.gsub("%{NAME}FOO", "ublue", ""); print(t)}
Does it at least add a foo to prove that it's doing anything at all?
bsherman
bsherman•2y ago
sorry, had to step away... i'm being loose with actual work today, but have to address a couple questions one sec and i'll test that
Arcitec
ArcitecOP•2y ago
You know, the worst case scenario is that something is wrong with our RPM builder if it can't run Lua. In that case, a pure plaintext solution would be something like:
Name: ublue-os-update-services
%global shared_data_dir update-services
Name: ublue-os-update-services
%global shared_data_dir update-services
I am fairly sure globals can be defined anywhere in that top section, so keeping it next to name would work. I have seen people put %globals at the literal first line of the file.
bsherman
bsherman•2y ago
foo is in the result here
Arcitec
ArcitecOP•2y ago
Ah, so it definitely ran the Lua and ran gsub with a parameter that was "projectnameFOO", and ended up with that in the output path, yeah? Then why the heck isn't it replacing anything. It's the simplest string possible...
bsherman
bsherman•2y ago
yup
Arcitec
ArcitecOP•2y ago
I ran this in real lua:
string.gsub("ublue-os-startup-scriptsFOO", "ublue", "")


-os-startup-scriptsFOO 1
string.gsub("ublue-os-startup-scriptsFOO", "ublue", "")


-os-startup-scriptsFOO 1
That's what we should have gotten. But your result didn't replace the ublue?
bsherman
bsherman•2y ago
right, i got "ublue-os-update-servicesfoo" (i used lowercase) i'm reading docs again myself, a moment plz
Arcitec
ArcitecOP•2y ago
Okay, it makes no sense to me that it's literally runnign the lua, literally running the function, but getting no replacements. We're calling string.gsub the same way Fedora calls it themselves in their spec If you wanna try one more thing, try:
%global project_name %{lua:t=string.gsub("%{NAME}bar", "b", ""); print(t)}
%global project_name %{lua:t=string.gsub("%{NAME}bar", "b", ""); print(t)}
Literally one letter replacement.
bsherman
bsherman•2y ago
that worked
Arcitec
ArcitecOP•2y ago
As a reminder, Fedora does:
%global archivename %{lua:t=string.gsub(rpm.expand("%{fontfamily}"), "[%p%s]+", ""); print(t)}-%{version}
%global archivename %{lua:t=string.gsub(rpm.expand("%{fontfamily}"), "[%p%s]+", ""); print(t)}-%{version}
bsherman
bsherman•2y ago
Directory not found: /tmp/ublue-os/rpmbuild/BUILDROOT/ublue-os-update-services-0.3-1.fc38.x86_64/usr/share/ublue-os/ublue-os-update-servicesar
Directory not found: /tmp/ublue-os/rpmbuild/BUILDROOT/ublue-os-update-services-0.3-1.fc38.x86_64/usr/share/ublue-os/ublue-os-update-servicesar
yeah, so we shouldn't need the expand, because that's expanding a macro
Arcitec
ArcitecOP•2y ago
Okay that's interesting. That's looking really wrong somehow. ublue-os-update-servicesar Notice how it only replaced the "b" nthe loose "bar" part
bsherman
bsherman•2y ago
yeah, it's like it's doing the replacement before interpretting the variable so maybe we DO need the expand
Arcitec
ArcitecOP•2y ago
Yeah I think you have figured it out But check how fedora does expansion:
bsherman
bsherman•2y ago
YES! Directory not found: /tmp/ublue-os/rpmbuild/BUILDROOT/ublue-os-update-services-0.3-1.fc38.x86_64/usr/share/ublue-os/ulue-os-update-servicesar
Arcitec
ArcitecOP•2y ago
string.gsub(rpm.expand("%{fontfamily}"), "[%p%s]+", "");
string.gsub(rpm.expand("%{fontfamily}"), "[%p%s]+", "");
Hell yeah great work brother! 😄 Funny coincidence that the "b" in "bar" lined up with the hopeless 1-character replacement test. But lucky. So this should be the final code, I guess?
%global project_name %{lua:t=string.gsub(rpm.expand("%{NAME}"), "^ublue%-os%-", ""); print(t)}
%global project_name %{lua:t=string.gsub(rpm.expand("%{NAME}"), "^ublue%-os%-", ""); print(t)}
bsherman
bsherman•2y ago
that's what i have... the gsub is good now! i'm just trying to sort out why other build problems exist
Arcitec
ArcitecOP•2y ago
Perfect. 🙂 I will resume work on the firstboot autostarter. And hey, after you've moved this file, take a long break, you've earned it. 😄 That was tedious!
bsherman
bsherman•2y ago
lol, like, a break to work on my real job? 🤣
Arcitec
ArcitecOP•2y ago
Hahahhah! Yes. Playing solitaire and minesweeper, multitasking and stuff like that. 😄
bsherman
bsherman•2y ago
not a good description of my job 😉 try again
Arcitec
ArcitecOP•2y ago
I know it's some important job, I think Jorge mentioned it on the tech over tea podcast. 😄
bsherman
bsherman•2y ago
nah, he didn't mention me... i'm stealth
Arcitec
ArcitecOP•2y ago
Haha 🙂 Speaking of stealth, why not contributor name color on Discord?
bsherman
bsherman•2y ago
eh, whatever, i'm just happy tot help
Arcitec
ArcitecOP•2y ago
I thought it may be because you didn't want to be bothered by people here haha. "Special name, can not resist urge to ask that person special question..."
Want results from more Discord servers?
Add your server