As part of efforts in Fedora 24 to address certain issues with the edition-specific fedora-release content (such as /etc/os-release, /etc/issues and edition-specific presets), I built a moderately complex series of bash scripts to run in %post and %posttrans to ensure that all of the right files were symlinked in the correct places. Unfortunately, the result here is that %post and %posttrans for fedora-release now requires both bash and coreutils to function properly, and this introduces a cyclical dependency. It works properly on upgrades of realistic systems (all of which have bash and coreutils on them), but it introduces issues with mock and minimalistic systems on installation. So what I am looking for is someone who is fluent in LUA to help me convert these scripts over so that they can run entirely under the built-in LUA interpreter of RPM and eliminate this problem. This is a fairly urgent issue, as it may cause blocking issues for Fedora 24 installations. So if you think you can help, please respond promptly. I'm attaching the current fedora-release.spec and convert-to-edition bash script for perusal.
#!/bin/bash # Simple script to set up Edition defaults for Fedora OPTIND=1 VARIANT_FILE=/usr/lib/variant # Defaults are set to provide the fewest suprises for anyone running this # script manually to convert their own system. In nearly all cases, it should # be possible to run `convert-to-edition -e <edition>` and get expected results # By default, install new packages to ensure that all the necessary files are # available before symlinking. This must be skipped when running this file as # part of an RPM scriptlet. do_installation=1 # By default, do not modify the enabled or disabled state of any service on the # system. This should only be done when this script is run as part of system # installation or if the user is certain that they want to apply the changes to # the presets to their system. enable_presets=0 exit_usage() { echo "Usage: convert-to-edition [options] -e cloud|non-edition|server|workstation" echo " Options:" echo " -e: The edition to install (cloud, non-edition, server or workstation)" echo " -i: Skip installing additional files and just update symlinks" echo " -p: Also enable newly-added systemd presets" exit 1 } while getopts "e:ihp" opt; do case "$opt" in e) EDITION=$OPTARG ;; i) do_installation=0 ;; p) enable_presets=1 ;; h) exit_usage ;; esac done # None of the actions below can be run by a non-root user if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi case $EDITION in cloud) if [ $do_installation -gt 0 ]; then echo "Installing Fedora Cloud Packages" dnf install -y fedora-release-cloud fi echo "VARIANT_ID=cloud" > $VARIANT_FILE # Ensure that the os-release file is pointing to the correct version ln -sf ./os.release.d/os-release-cloud /usr/lib/os-release || : # Ensure that the issue file is pointing to the correct version ln -sf ./os.release.d/issue-fedora /usr/lib/issue # Remove any presets from other Editions. rm -f /usr/lib/systemd/system-preset/80-*.preset ;; non-edition) echo "VARIANT_ID=nonproduct" > $VARIANT_FILE # Ensure that the os-release file is pointing to the correct version ln -sf ./os.release.d/os-release-fedora /usr/lib/os-release || : # Ensure that the issue file is pointing to the correct version ln -sf ./os.release.d/issue-fedora /usr/lib/issue # Remove any presets from other Editions. rm -f /usr/lib/systemd/system-preset/80-*.preset ;; server) if [ $do_installation -gt 0 ]; then echo "Installing Fedora Server Packages" dnf install -y fedora-release-server fi echo "VARIANT_ID=server" > $VARIANT_FILE # Ensure that the os-release and issue files are pointing to the correct # version ln -sf ./os.release.d/os-release-server /usr/lib/os-release ln -sf ./os.release.d/issue-server /usr/lib/issue # Remove any presets from other Editions. This should always be a no-op, # but it's good to be explicit. # We reserve 80-*.preset for Editions rm -f /usr/lib/systemd/system-preset/80-*.preset # Symlink in the proper preset ln -sf ../../os.release.d/presets/80-server.preset \ /usr/lib/systemd/system-preset/80-server.preset if [ $enable_presets -gt 0 ]; then # Enable new units specified by presets units=$(sed -n 's/^enable//p' \ < /usr/lib/systemd/system-preset/80-server.preset) /usr/bin/systemctl preset $units >/dev/null 2>&1 || : # Disable new units specified by presets units=$(sed -n 's/^disable//p' \ < /usr/lib/systemd/system-preset/80-server.preset) /usr/bin/systemctl preset $units >/dev/null 2>&1 || : fi ;; workstation) if [ $do_installation -gt 0 ]; then echo "Installing Fedora Workstation Packages" dnf install -y fedora-release-workstation fi echo "VARIANT_ID=workstation" > $VARIANT_FILE # Ensure that the os-release and issue files are pointing to the correct # version ln -sf ./os.release.d/os-release-workstation /usr/lib/os-release ln -sf ./os.release.d/issue-fedora /usr/lib/issue # Remove any presets from other Editions. This should always be a no-op, # but it's good to be explicit. # We reserve 80-*.preset for Editions rm -f /usr/lib/systemd/system-preset/80-*.preset # Symlink in the proper preset ln -sf ../../os.release.d/presets/80-workstation.preset \ /usr/lib/systemd/system-preset/80-workstation.preset if [ $enable_presets -gt 0 ]; then # Enable new units specified by presets units=$(sed -n 's/^enable//p' \ < /usr/lib/systemd/system-preset/80-workstation.preset) /usr/bin/systemctl preset $units >/dev/null 2>&1 || : # Disable new units specified by presets units=$(sed -n 's/^disable//p' \ < /usr/lib/systemd/system-preset/80-workstation.preset) /usr/bin/systemctl preset $units >/dev/null 2>&1 || : fi ;; *) exit_usage ;; esac # Update the grub2 bootloader text to show the correct edition # Not all ARM or Cloud Images use grub2, so we'll skip this step # if grub2-mkconfig doesn't exist. if [ -x /usr/sbin/grub2-mkconfig ]; then /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg 2>&1 || : fi echo This system has been converted to $EDITION exit 0
%define release_name Twenty Four %define dist_version 24 %define bug_version 24 Summary: Fedora release files Name: fedora-release Version: 24 Release: 0.12 License: MIT Group: System Environment/Base URL: http://fedoraproject.org Source: %{name}-%{version}.tar.bz2 Obsoletes: redhat-release Provides: redhat-release Provides: system-release Provides: system-release(%{version}) # Kill off the fedora-release-nonproduct package Provides: fedora-release-nonproduct = %{version} Obsoletes: fedora-release-nonproduct <= 23-0.3 Provides: fedora-release-standard = 22-0.8 Obsoletes: fedora-release-standard < 22-0.8 Requires: fedora-repos(%{version}) BuildArch: noarch %description Fedora release files such as various /etc/ files that define the release. %package cloud Summary: Base package for Fedora Cloud-specific default configurations Provides: system-release-cloud Provides: system-release-cloud(%{version}) Provides: system-release-product Requires: fedora-release = %{version}-%{release} %description cloud Provides a base package for Fedora Cloud-specific configuration files to depend on. %package server Summary: Base package for Fedora Server-specific default configurations Provides: system-release-server Provides: system-release-server(%{version}) Provides: system-release-product Requires: fedora-release = %{version}-%{release} Requires: systemd Requires: cockpit Requires: rolekit Requires(post): sed Requires(post): systemd %description server Provides a base package for Fedora Server-specific configuration files to depend on. %package workstation Summary: Base package for Fedora Workstation-specific default configurations Provides: system-release-workstation Provides: system-release-workstation(%{version}) Provides: system-release-product Requires: fedora-release = %{version}-%{release} # needed for captive portal support Requires: NetworkManager-config-connectivity-fedora Requires(post): /usr/bin/glib-compile-schemas Requires(postun): /usr/bin/glib-compile-schemas %description workstation Provides a base package for Fedora Workstation-specific configuration files to depend on. %prep %setup -q sed -i 's|@@VERSION@@|%{dist_version}|g' Fedora-Legal-README.txt %build %install install -d $RPM_BUILD_ROOT/etc echo "Fedora release %{version} (%{release_name})" > $RPM_BUILD_ROOT/etc/fedora-release echo "cpe:/o:fedoraproject:fedora:%{version}" > $RPM_BUILD_ROOT/etc/system-release-cpe # Symlink the -release files ln -s fedora-release $RPM_BUILD_ROOT/etc/redhat-release ln -s fedora-release $RPM_BUILD_ROOT/etc/system-release # Create the common os-release file install -d $RPM_BUILD_ROOT/usr/lib/os.release.d/ cat << EOF >>$RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-fedora NAME=Fedora VERSION="%{dist_version} (%{release_name})" ID=fedora VERSION_ID=%{dist_version} PRETTY_NAME="Fedora %{dist_version} (%{release_name})" ANSI_COLOR="0;34" CPE_NAME="cpe:/o:fedoraproject:fedora:%{dist_version}" HOME_URL="https://fedoraproject.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=%{bug_version} REDHAT_SUPPORT_PRODUCT="Fedora" REDHAT_SUPPORT_PRODUCT_VERSION=%{bug_version} PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy EOF # Create the common /etc/issue echo "\S" > $RPM_BUILD_ROOT/usr/lib/os.release.d/issue-fedora echo "Kernel \r on an \m (\l)" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/issue-fedora echo >> $RPM_BUILD_ROOT/usr/lib/os.release.d/issue-fedora # Create /etc/issue.net echo "\S" > $RPM_BUILD_ROOT/usr/lib/issue.net echo "Kernel \r on an \m (\l)" >> $RPM_BUILD_ROOT/usr/lib/issue.net ln -s ../usr/lib/issue.net $RPM_BUILD_ROOT/etc/issue.net # Create os-release and issue files for the different editions # Cloud cp -p $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-fedora \ $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-cloud echo "VARIANT=\"Cloud Edition\"" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-cloud echo "VARIANT_ID=cloud" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-cloud sed -i -e "s|(%{release_name})|(Cloud Edition)|g" $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-cloud # Server cp -p $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-fedora \ $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-server echo "VARIANT=\"Server Edition\"" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-server echo "VARIANT_ID=server" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-server sed -i -e "s|(%{release_name})|(Server Edition)|g" $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-server cp -p $RPM_BUILD_ROOT/usr/lib/os.release.d/issue-fedora \ $RPM_BUILD_ROOT/usr/lib/os.release.d/issue-server echo "Admin Console: https://\4:9090/ or https://[\6]:9090/" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/issue-server echo >> $RPM_BUILD_ROOT/usr/lib/os.release.d/issue-server # Workstation cp -p $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-fedora \ $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-workstation echo "VARIANT=\"Workstation Edition\"" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-workstation echo "VARIANT_ID=workstation" >> $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-workstation sed -i -e "s|(%{release_name})|(Workstation Edition)|g" $RPM_BUILD_ROOT/usr/lib/os.release.d/os-release-workstation # Create the symlink for /etc/os-release # We don't create the /usr/lib/os-release symlink until %%post # so that we can ensure that the right one is referenced. ln -s ../usr/lib/os-release $RPM_BUILD_ROOT/etc/os-release # Create the symlink for /etc/issue # We don't create the /usr/lib/os-release symlink until %%post # so that we can ensure that the right one is referenced. ln -s ../usr/lib/issue $RPM_BUILD_ROOT/etc/issue # Set up the dist tag macros install -d -m 755 $RPM_BUILD_ROOT%{_rpmconfigdir}/macros.d cat >> $RPM_BUILD_ROOT%{_rpmconfigdir}/macros.d/macros.dist << EOF # dist macros. %%fedora %{dist_version} %%dist .fc%{dist_version} %%fc%{dist_version} 1 EOF # Add presets mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/user-preset/ mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-preset/ mkdir -p $RPM_BUILD_ROOT/usr/lib/os.release.d/presets # Default system wide install -m 0644 85-display-manager.preset $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-preset/ install -m 0644 90-default.preset $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-preset/ install -m 0644 99-default-disable.preset $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-preset/ # Fedora Server install -m 0644 80-server.preset $RPM_BUILD_ROOT%{_prefix}/lib/os.release.d/presets/ # Fedora Workstation install -m 0644 80-workstation.preset $RPM_BUILD_ROOT%{_prefix}/lib/os.release.d/presets/ # Override the list of enabled gnome-shell extensions for Workstation mkdir -p $RPM_BUILD_ROOT%{_datadir}/glib-2.0/schemas/ install -m 0644 org.gnome.shell.gschema.override $RPM_BUILD_ROOT%{_datadir}/glib-2.0/schemas/ # Copy the make_edition script to /usr/sbin mkdir -p $RPM_BUILD_ROOT/%{_prefix}/sbin/ install -m 0744 convert-to-edition $RPM_BUILD_ROOT/%{_prefix}/sbin/ %post # On initial installation, we'll at least temporarily put the non-product # symlinks in place. It will be overridden by fedora-release-$EDITION # %%post sections because we don't write the /usr/lib/variant file until # %%posttrans to avoid trumping the fedora-release-$EDITION packages. # This is necessary to avoid breaking systemctl scripts since they rely on # /usr/lib/os-release being valid. We can't wait until %%posttrans to default # to os-release-fedora. if [ $1 = 0 ]; then ln -sf ./os.release.d/os-release-fedora $RPM_BUILD_ROOT/usr/lib/os-release || : ln -sf ./os.release.d/issue-fedora $RPM_BUILD_ROOT/usr/lib/issue || : fi # We also want to forcibly set these paths on upgrade if we are explicitly # set to "nonproduct" if [ -e /usr/lib/variant ]; then . /usr/lib/variant || : if [ "x$VARIANT_ID" = "xnonproduct" ]; then # Run the convert-to-edition script. %{_prefix}/sbin/convert-to-edition -ie non-edition fi fi %posttrans # If we get to %%posttrans and nothing created /usr/lib/variant, set it to # nonproduct if [ \! -e /usr/lib/variant ]; then %{_prefix}/sbin/convert-to-edition -ipe non-edition fi %post cloud # == Run every time == # Create the variant file if it does not already exist. This needs to be done # on both installation and upgrade, to ensure that we upgrade from F23 # and earlier properly. if [ \! -e /usr/lib/variant ]; then echo "VARIANT_ID=cloud" > /usr/lib/variant || : fi . /usr/lib/variant || : if [ "x$VARIANT_ID" = "xcloud" ]; then if [ $1 -eq 1 ] ; then # (On initial installation only), fix up after %%systemd_post in packages # possibly installed before our preset file was added %{_prefix}/sbin/convert-to-edition -ipe cloud else # On upgrades, do not enable or disable presets to avoid surprising # the user %{_prefix}/sbin/convert-to-edition -ie cloud fi fi %preun cloud # If we are uninstalling, we need to reset the variant file and force # the os-release file back to os-release-fedora. # We do this in %%preun so that we don't have any time where the os-release # symlink is dangling (since in %%postun, the os-release-$EDITION file # will have already been removed) if [ $1 = 0 ]; then . /usr/lib/variant || : if [ "x$VARIANT_ID" = "xcloud" ]; then # Do not enable or disable presets when uninstalling %{_prefix}/sbin/convert-to-edition -ie non-edition fi fi %post server # == Run every time == # Create the variant file if it does not already exist. This needs to be done # on both installation and upgrade, to ensure that we upgrade from F23 # and earlier properly. if [ \! -e /usr/lib/variant ]; then echo "VARIANT_ID=server" > /usr/lib/variant || : fi . /usr/lib/variant || : if [ "x$VARIANT_ID" = "xserver" ]; then if [ $1 -eq 1 ] ; then # (On initial installation only), fix up after %%systemd_post in packages # possibly installed before our preset file was added %{_prefix}/sbin/convert-to-edition -ipe server else # On upgrades, do not enable or disable presets to avoid surprising # the user %{_prefix}/sbin/convert-to-edition -ie server fi fi %preun server # If we are uninstalling, we need to delete the variant file and # force the os-release file back to os-release-fedora. # We do this in %%preun so that we don't have any time where the os-release # symlink is dangling (since in %%postun, the os-release-$EDITION file # will have already been removed) if [ $1 = 0 ]; then . /usr/lib/variant || : if [ "x$VARIANT_ID" = "xserver" ]; then # Do not enable or disable presets when uninstalling %{_prefix}/sbin/convert-to-edition -ie non-edition fi fi %post workstation # == Run every time == # Create the variant file if it does not already exist. This needs to be done # on both installation and upgrade, to ensure that we upgrade from F23 # and earlier properly. if [ \! -e /usr/lib/variant ]; then echo "VARIANT_ID=workstation" > /usr/lib/variant || : fi . /usr/lib/variant || : if [ "x$VARIANT_ID" = "xworkstation" ]; then if [ $1 -eq 1 ] ; then # (On initial installation only), fix up after %%systemd_post in packages # possibly installed before our preset file was added %{_prefix}/sbin/convert-to-edition -ipe workstation else # On upgrades, do not enable or disable presets to avoid surprising # the user %{_prefix}/sbin/convert-to-edition -ie workstation fi fi %preun workstation # If we are uninstalling, we need to delete the variant file and # force the os-release file back to os-release-fedora. # We do this in %%preun so that we don't have any time where the os-release # symlink is dangling (since in %%postun, the os-release-$EDITION file # will have already been removed) if [ $1 = 0 ]; then . /usr/lib/variant || : if [ "x$VARIANT_ID" = "xworkstation" ]; then # Do not enable or disable presets when uninstalling %{_prefix}/sbin/convert-to-edition -ie non-edition fi fi %postun workstation if [ $1 -eq 0 ] ; then glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : fi %posttrans workstation glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %files %defattr(-,root,root,-) %{!?_licensedir:%global license %%doc} %license LICENSE Fedora-Legal-README.txt %ghost /usr/lib/variant %dir /usr/lib/os.release.d %dir /usr/lib/os.release.d/presets %config %attr(0644,root,root) /usr/lib/os.release.d/os-release-fedora %ghost /usr/lib/os-release /etc/os-release %config %attr(0644,root,root) /etc/fedora-release /etc/redhat-release /etc/system-release %config %attr(0644,root,root) /etc/system-release-cpe %config %attr(0644,root,root) /usr/lib/os.release.d/issue-fedora %ghost /usr/lib/issue %config(noreplace) /etc/issue %config %attr(0644,root,root) /usr/lib/issue.net %config(noreplace) /etc/issue.net %attr(0644,root,root) %{_rpmconfigdir}/macros.d/macros.dist %dir /usr/lib/systemd/user-preset/ %dir %{_prefix}/lib/systemd/system-preset/ %{_prefix}/lib/systemd/system-preset/85-display-manager.preset %{_prefix}/lib/systemd/system-preset/90-default.preset %{_prefix}/lib/systemd/system-preset/99-default-disable.preset /usr/sbin/convert-to-edition %files cloud %{!?_licensedir:%global license %%doc} %license LICENSE %config %attr(0644,root,root) /usr/lib/os.release.d/os-release-cloud %files server %{!?_licensedir:%global license %%doc} %license LICENSE %config %attr(0644,root,root) /usr/lib/os.release.d/os-release-server %config %attr(0644,root,root) /usr/lib/os.release.d/issue-server %ghost %{_prefix}/lib/systemd/system-preset/80-server.preset %config %attr(0644,root,root) /usr/lib/os.release.d/presets/80-server.preset %files workstation %{!?_licensedir:%global license %%doc} %license LICENSE %config %attr(0644,root,root) /usr/lib/os.release.d/os-release-workstation %{_datadir}/glib-2.0/schemas/org.gnome.shell.gschema.override %ghost %{_prefix}/lib/systemd/system-preset/80-workstation.preset %config %attr(0644,root,root) /usr/lib/os.release.d/presets/80-workstation.preset %changelog * Mon Feb 29 2016 Stephen Gallagher <sgallagh@xxxxxxxxxx> - 24-0.12 - Only run grub2-mkconfig for platforms that support it - Remove erroneous RPM_BUILD_ROOT variables in convert-to-edition * Fri Feb 26 2016 Stephen Gallagher <sgallagh@xxxxxxxxxx> - 24-0.11 - Fix upgrade bug in Workstation and Cloud * Tue Feb 23 2016 Dennis Gilmore <dennis@xxxxxxxx> - 24-0.10 - setup for f24 being branched * Thu Jan 21 2016 Stephen Gallagher <sgallagh@xxxxxxxxxx> 24-0.9 - Install Edition presets only for the configured Edition - Add script to convert from non-edition to an Edition - Fix upgrade bugs with non-edition installs - Explicitly set issue-fedora for cloud installs - Resolves: rhbz#1288205 * Tue Dec 15 2015 Stephen Gallagher <sgallagh@xxxxxxxxxx> 24-0.8 - Fix copy-paste error for Workstation os-release and issue * Tue Sep 29 2015 Stephen Gallagher <sgallagh@xxxxxxxxxx> 24-0.7 - Rework os-release and issue mechanism to avoid upgrade issues such as competing fedora-release-$EDITION packages - Make a non-product install persistent (it won't be converted to an Edition install if something pulls in a fedora-release-$EDITION package * Mon Sep 28 2015 Dennis Gilmore <dennis@xxxxxxxx> - 24-0.6 - set bug_version to be rawhide rhbz#1259287 * Tue Sep 15 2015 Stephen Gallagher <sgallagh@xxxxxxxxxx> - 24-0.5 - Do not clobber /etc/issue[.net] customizations * Wed Sep 09 2015 Stephen Gallagher <sgallagh@xxxxxxxxxx> - 24-0.4 - Update preset file with FESCo decisions - https://fedorahosted.org/fesco/ticket/1472 * Wed Sep 09 2015 Stephen Gallagher <sgallagh@xxxxxxxxxx> - 24-0.3 - Enclose IPv6 addresses in square brackets in /etc/issue * Mon Aug 24 2015 Stephen Gallagher <sgallagh@xxxxxxxxxx> - 24-0.2 - Make /etc/issue configurable per-edition - Resolves: RHBZ#1239089 * Tue Jul 14 2015 Dennis Gilmore <dennis@xxxxxxxx> - 24-0.1 - setup for rawhide being f24
Attachment:
signature.asc
Description: OpenPGP digital signature
-- devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxxx http://lists.fedoraproject.org/admin/lists/devel@xxxxxxxxxxxxxxxxxxxxxxx