Skip to content

Commit

Permalink
yupdate improvement
Browse files Browse the repository at this point in the history
- Allow optionally skipping update of the DBus backend or the web fronend
- Set environment variable YUPDATE_SKIP_FRONTEND=1 or YUPDATE_SKIP_BACKEND=1
  to skip the frontend or backend update
- YUPDATE_SKIP_FRONTEND=1 can be used when you use the webpack development
  server for running the web frontend, in that case updating the web frontend
  does not make sense, it just takes long time and consumes additional
  disk/RAM space
- YUPDATE_SKIP_BACKEND=1 was added mainly as a complement,
  just in case somebody needs to handle the opposite case
  • Loading branch information
lslezak committed Mar 21, 2023
1 parent 13a31ce commit f18d463
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
4 changes: 4 additions & 0 deletions .yupdate.pre
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# run the yupdate script several times
#

if [ "$YUPDATE_SKIP_FRONTEND" == "1" ]; then
exit 0
fi

# the needed packages for compiling the d-installer cockpit module
PACKAGES=(appstream-glib-devel make npm)

Expand Down
68 changes: 36 additions & 32 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,45 @@ SERVICES_DIR = "/usr/share/dbus-1/d-installer-services"
if File.exist?("/.packages.initrd") || `mount`.match?(/^[\w]+ on \/ type overlay/)
Rake::Task["install"].clear
task :install do
destdir = ENV["DESTDIR"] || "/"

puts "Installing the DBus service..."
Dir.chdir("service") do
sh "gem build d-installer.gemspec"
sh "gem install --local --force --no-format-exec --no-doc --build-root #{destdir.shellescape} d-installer-*.gem"

# update the DBus configuration files
FileUtils.mkdir_p(SERVICES_DIR)
sh "cp share/org.opensuse.DInstaller*.service #{SERVICES_DIR}"
sh "cp share/dbus.conf /usr/share/dbus-1/d-installer.conf"

# update the systemd service file
source_file = "share/systemd.service"
target_file = "/usr/lib/systemd/system/d-installer.service"

unless FileUtils.identical?(source_file, target_file)
FileUtils.cp(source_file, target_file)
sh "systemctl daemon-reload"
if ENV["YUPDATE_SKIP_BACKEND"] != "1"
destdir = ENV["DESTDIR"] || "/"

puts "Installing the DBus service..."
Dir.chdir("service") do
sh "gem build d-installer.gemspec"
sh "gem install --local --force --no-format-exec --no-doc --build-root #{destdir.shellescape} d-installer-*.gem"

# update the DBus configuration files
FileUtils.mkdir_p(SERVICES_DIR)
sh "cp share/org.opensuse.DInstaller*.service #{SERVICES_DIR}"
sh "cp share/dbus.conf /usr/share/dbus-1/d-installer.conf"

# update the systemd service file
source_file = "share/systemd.service"
target_file = "/usr/lib/systemd/system/d-installer.service"

unless FileUtils.identical?(source_file, target_file)
FileUtils.cp(source_file, target_file)
sh "systemctl daemon-reload"
end
end
end

puts "Installing the Web frontend..."
Dir.chdir("web") do
node_env = ENV["NODE_ENV"] || "production"
sh "NODE_ENV=#{node_env.shellescape} make install"

# clean up the extra files when switching the development/production mode
if node_env == "production"
# remove the uncompressed and development files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/index.{css,html,js}"))
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.map"))
else
# remove the compressed files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.gz"))
if ENV["YUPDATE_SKIP_FRONTEND"] != "1"
puts "Installing the Web frontend..."
Dir.chdir("web") do
node_env = ENV["NODE_ENV"] || "production"
sh "NODE_ENV=#{node_env.shellescape} make install"

# clean up the extra files when switching the development/production mode
if node_env == "production"
# remove the uncompressed and development files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/index.{css,html,js}"))
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.map"))
else
# remove the compressed files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.gz"))
end
end
end
end
Expand Down

0 comments on commit f18d463

Please sign in to comment.