Skip to content

Distribution packaging changes #228

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPDX-License-Identifier: (LGPL-2.1 OR LGPL-3.0)
# Copyright (C) SUSE LLC 2023, all rights reserved.

#TODO libexec?
bindir ?= /usr/bin
libdir ?= /usr/lib
pkglibdir ?= ${libdir}/rapido
sysconfdir ?= /etc

.PHONY: install clean test all

all:
$(info No compilation required.)

clean:
$(info Nothing to clean up.)

test:
selftest/selftest.sh

install: all
install -D -t $(DESTDIR)$(pkglibdir)/cut cut/*.sh
install -D -t $(DESTDIR)$(pkglibdir)/autorun/lib autorun/lib/*.sh
install -t $(DESTDIR)$(pkglibdir)/autorun autorun/*.sh
install -D -t $(DESTDIR)$(pkglibdir)/tools tools/*.sh
install -m 644 -D -t $(DESTDIR)$(pkglibdir)/dracut.conf.d \
dracut.conf.d/.empty dracut.conf.d/01-rapido-dracut.conf
install -t $(DESTDIR)$(pkglibdir) \
rapido runtime.vars vm.sh vm_autorun.env
mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(sysconfdir)/rapido
# symlink ensures that RAPIDO_DIR can be found via realpath
ln -s $(pkglibdir)/rapido $(DESTDIR)$(bindir)/
install -D tools/bash_completion \
$(DESTDIR)$(sysconfdir)/bash_completion.d/rapido
# use etc for configuration, and PWD for all (throwaway) VM image state
sed -e 's/^#VM_NET_CONF=.*/VM_NET_CONF="\/etc\/rapido\/net-conf"/' \
-e 's/^#QEMU_PID_DIR=.*/QEMU_PID_DIR="$$PWD"/' \
-e 's/^#DRACUT_OUT=.*/DRACUT_OUT="$${PWD}\/rapido.cpio"/' \
rapido.conf.example > $(DESTDIR)$(sysconfdir)/rapido/rapido.conf


.DEFAULT_GOAL = all
26 changes: 7 additions & 19 deletions rapido
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#!/bin/bash
#
# Copyright (C) SUSE LINUX GmbH 2018, all rights reserved.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) version 3.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.

RAPIDO_DIR="$(realpath -e ${0%/*})"
# SPDX-License-Identifier: (LGPL-2.1 OR LGPL-3.0)
# Copyright (C) SUSE LLC 2018, all rights reserved.

RAPIDO_DIR="$(realpath -e $BASH_SOURCE)"
RAPIDO_DIR="${RAPIDO_DIR%/*}"

declare -A short_help

Expand Down Expand Up @@ -95,20 +86,17 @@ rapido_cut()
exit 1
fi

pushd "$RAPIDO_DIR" > /dev/null
cut_script="cut/${testname//-/_}.sh"
cut_script="${RAPIDO_DIR}/cut/${testname//-/_}.sh"

if [[ ! -x $cut_script ]]; then
[[ -f $cut_script ]] \
&& echo "$cut_script lacks execute permission." \
|| echo "$testname not found. See \"rapido list\"."
popd > /dev/null
exit
fi

./$cut_script "${post_autorun_files[@]}"
"$cut_script" "${post_autorun_files[@]}"
local cut_status=$?
popd > /dev/null
[ $cut_status -ne 0 ] && exit $cut_status
[ -n "$boot_img" ] || exit 0
"${RAPIDO_DIR}/vm.sh"
Expand Down
8 changes: 6 additions & 2 deletions runtime.vars
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ if [[ -n $RAPIDO_CONF ]]; then
# explicit user-provided conf path; fail if missing.
. "$RAPIDO_CONF" || _fail "$RAPIDO_CONF missing"
else
# use default rapido.conf path; continue if missing.
RAPIDO_CONF="${RAPIDO_DIR}/rapido.conf"
# default conf path; continue if missing. etc path is for distributions
if [ -f "/etc/rapido/rapido.conf" ]; then
RAPIDO_CONF="/etc/rapido/rapido.conf"
else
RAPIDO_CONF="${RAPIDO_DIR}/rapido.conf"
fi
. "$RAPIDO_CONF" 2> /dev/null \
|| _warn "$(realpath $RAPIDO_CONF) missing - see rapido.conf.example"
fi
Expand Down
18 changes: 11 additions & 7 deletions tools/bash_completion
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
# SPDX-License-Identifier: (LGPL-2.1 OR LGPL-3.0)
# Copyright (C) SUSE LLC 2019-2022, all rights reserved.

Expand All @@ -14,14 +13,19 @@ __rapido()
{
local bin cut_dir cur rcmd max_off seen_boot
local -a comps
bin="$1"

# we only want to complete the rapido script, not dirs, etc.
[ -f "$bin" ] || return 0
[ -x "$bin" ] || return 0
if [[ -f ./rapido ]]; then
# assume git clone with cut subdirectory
cut_dir="./cut"
elif [[ -x /usr/bin/rapido ]]; then
# assume distro package with bin symlink to RAPIDO_DIR
bin="$(realpath -e /usr/bin/rapido)"
cut_dir="${bin%/*}/cut"
else
return 0
fi

cut_dir="$(dirname $bin)/cut"
[ -d "${cut_dir}" ] || return 0
[ -d "$cut_dir" ] || return 0

COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
Expand Down