feat: use patches

This commit is contained in:
Oskar Manhart 2024-09-09 11:09:42 +02:00
parent 7d5cce374c
commit 28e958e600
5 changed files with 127 additions and 22 deletions

View File

@ -0,0 +1,11 @@
--- a/WinAppsLauncher.sh
+++ b/WinAppsLauncher.sh
@@ -19,7 +19,7 @@ declare -rx EC_WIN_NOT_SPEC=6
declare -rx EC_NO_WIN_FOUND=7
# Paths
-declare -rx ICONS_PATH="./Icons"
+declare -rx ICONS_PATH="@out@/Icons"
declare -rx APPDATA_PATH="${HOME}/.local/share/winapps"
declare -rx CONFIG_PATH="${HOME}/.config/winapps"
declare -rx CONFIG_FILE="${CONFIG_PATH}/winapps.conf"

View File

@ -29,16 +29,18 @@ stdenv.mkDerivation rec {
(callPackage ../winapps { }) (callPackage ../winapps { })
]; ];
patches = [ ./WinAppsLauncher.diff ];
postPatch = ''
substituteAllInPlace WinAppsLauncher.sh
'';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out mkdir -p $out
cp -r ./Icons $out/Icons cp -r ./Icons $out/Icons
sed -E -i \
-e "$(printf "%s$out%s" 's|^declare -rx ICONS_PATH="./Icons"|declare -rx ICONS_PATH="' '/Icons"|')" \
WinAppsLauncher.sh
install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher install -m755 -D WinAppsLauncher.sh $out/bin/winapps-launcher
install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg install -Dm444 -T Icons/AppIcon.svg $out/share/pixmaps/winapps.svg

View File

@ -34,30 +34,23 @@ stdenv.mkDerivation rec {
iproute2 iproute2
]; ];
patches = [
./winapps.patch
./setup.patch
];
postPatch = ''
substituteAllInPlace bin/winapps
substituteAllInPlace setup.sh
patchShebangs install/inquirer.sh
'';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out mkdir -p $out
mkdir -p $out/src mkdir -p $out/src
patchShebangs install/inquirer.sh
sed -E -i \
-e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \
bin/winapps
sed -E -i \
-e 's/grep -q -E "\\blibvirt\\b"/grep -q -E "\\blibvirtd\\b"/' \
-e "$(printf "%s$out%s" 's|^readonly INQUIRER_PATH="./install/inquirer.sh"|readonly INQUIRER_PATH="' '/src/install/inquirer.sh"|')" \
-e "$(printf "%s$out%s" 's|^readonly SYS_SOURCE_PATH="(.*?)"|readonly SYS_SOURCE_PATH="' '/src"|')" \
-e "$(printf "%s$out%s" 's|^readonly USER_SOURCE_PATH="(.*?)"|readonly USER_SOURCE_PATH="' '/src"|')" \
-e 's/\$SUDO git -C "\$SOURCE_PATH" pull --no-rebase//g' \
-e 's|./setup.sh|winapps-setup|g' \
-e 's|\$SUDO ln -s "./bin/winapps" "\$\{BIN_PATH\}/winapps"||' \
-e 's|\$SUDO ln -s "./setup.sh" "\$\{BIN_PATH\}/winapps-setup"||' \
-e "s|\$\{BIN_PATH\}/winapps|$out/bin/winapps|" \
./setup.sh
cp -r ./ $out/src/ cp -r ./ $out/src/
install -m755 -D bin/winapps $out/bin/winapps install -m755 -D bin/winapps $out/bin/winapps

View File

@ -0,0 +1,88 @@
--- a/setup.sh
+++ b/setup.sh
@@ -38,8 +38,8 @@ readonly SYS_BIN_PATH="/usr/local/bin" # UNIX path to 'bin' dir
readonly USER_BIN_PATH="${HOME}/.local/bin" # UNIX path to 'bin' directory for a '--user' WinApps installation.
readonly USER_BIN_PATH_WIN='\\tsclient\home\.local\bin' # WINDOWS path to 'bin' directory for a '--user' WinApps installation.
# 'SOURCE'
-readonly SYS_SOURCE_PATH="${SYS_BIN_PATH}/winapps" # UNIX path to WinApps source directory for a '--system' WinApps installation.
-readonly USER_SOURCE_PATH="${USER_BIN_PATH}/winapps" # UNIX path to WinApps source directory for a '--system' WinApps installation.
+readonly SYS_SOURCE_PATH="@out@/src" # UNIX path to WinApps source directory for a '--system' WinApps installation.
+readonly USER_SOURCE_PATH="@out@/src" # UNIX path to WinApps source directory for a '--system' WinApps installation.
# 'APP'
readonly SYS_APP_PATH="/usr/share/applications" # UNIX path to 'applications' directory for a '--system' WinApps installation.
readonly USER_APP_PATH="${HOME}/.local/share/applications" # UNIX path to 'applications' directory for a '--user' WinApps installation.
@@ -69,7 +69,7 @@ readonly TEST_PATH_WIN="${USER_APPDATA_PATH_WIN}\\FreeRDP_Connection_Test" # WIN
# 'WinApps Configuration File'
readonly CONFIG_PATH="${HOME}/.config/winapps/winapps.conf" # UNIX path to the WinApps configuration file.
# 'Inquirer Bash Script'
-readonly INQUIRER_PATH="./install/inquirer.sh" # UNIX path to the 'inquirer' script, which is used to produce selection menus.
+readonly INQUIRER_PATH="@out@/src/install/inquirer.sh" # UNIX path to the 'inquirer' script, which is used to produce selection menus.
# REMOTE DESKTOP CONFIGURATION
readonly VM_NAME="RDPWindows" # Name of the Windows VM (FOR 'libvirt' ONLY).
@@ -129,13 +129,13 @@ function waTerminateScript() {
# Role: Displays usage information for the script.
function waUsage() {
echo -e "Usage:
- ${COMMAND_TEXT}./setup.sh --user${CLEAR_TEXT} # Install WinApps and selected applications in ${HOME}
- ${COMMAND_TEXT}./setup.sh --system${CLEAR_TEXT} # Install WinApps and selected applications in /usr
- ${COMMAND_TEXT}./setup.sh --user --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in ${HOME}
- ${COMMAND_TEXT}./setup.sh --system --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in /usr
- ${COMMAND_TEXT}./setup.sh --user --uninstall${CLEAR_TEXT} # Uninstall everything in ${HOME}
- ${COMMAND_TEXT}./setup.sh --system --uninstall${CLEAR_TEXT} # Uninstall everything in /usr
- ${COMMAND_TEXT}./setup.sh --help${CLEAR_TEXT} # Display this usage message."
+ ${COMMAND_TEXT}winapps-setup --user${CLEAR_TEXT} # Install WinApps and selected applications in ${HOME}
+ ${COMMAND_TEXT}winapps-setup --system${CLEAR_TEXT} # Install WinApps and selected applications in /usr
+ ${COMMAND_TEXT}winapps-setup --user --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in ${HOME}
+ ${COMMAND_TEXT}winapps-setup --system --setupAllOfficiallySupportedApps${CLEAR_TEXT} # Install WinApps and all officially supported applications in /usr
+ ${COMMAND_TEXT}winapps-setup --user --uninstall${CLEAR_TEXT} # Uninstall everything in ${HOME}
+ ${COMMAND_TEXT}winapps-setup --system --uninstall${CLEAR_TEXT} # Uninstall everything in /usr
+ ${COMMAND_TEXT}winapps-setup --help${CLEAR_TEXT} # Display this usage message."
}
# Name: 'waGetSourceCode'
@@ -158,7 +158,7 @@ function waGetSourceCode() {
$SUDO git clone --recurse-submodules --remote-submodules https://github.com/winapps-org/winapps.git "$SOURCE_PATH"
else
echo -e "${INFO_TEXT}WinApps installation already present at ${CLEAR_TEXT}${COMMAND_TEXT}${SOURCE_PATH}${CLEAR_TEXT}${INFO_TEXT}. Updating...${CLEAR_TEXT}"
- $SUDO git -C "$SOURCE_PATH" pull --no-rebase
+
fi
# Silently change the working directory.
@@ -385,7 +385,7 @@ function waCheckExistingInstall() {
# Display the suggested action(s).
echo "--------------------------------------------------------------------------------"
- echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}./setup.sh --user --uninstall${CLEAR_TEXT}."
+ echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}winapps-setup --user --uninstall${CLEAR_TEXT}."
echo "--------------------------------------------------------------------------------"
# Terminate the script.
@@ -405,7 +405,7 @@ function waCheckExistingInstall() {
# Display the suggested action(s).
echo "--------------------------------------------------------------------------------"
- echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}./setup.sh --system --uninstall${CLEAR_TEXT}."
+ echo -e "Please remove the existing WinApps installation using ${COMMAND_TEXT}winapps-setup --system --uninstall${CLEAR_TEXT}."
echo "--------------------------------------------------------------------------------"
# Terminate the script.
@@ -800,7 +800,7 @@ function waCheckGroupMembership() {
# Identify groups the current user belongs to.
USER_GROUPS=$(groups "$(whoami)")
- if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirt\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then
+ if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirtd\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then
# Complete the previous line.
echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n"
@@ -1621,8 +1621,8 @@ function waInstall() {
waFindInstalled
# Install the WinApps bash scripts.
- $SUDO ln -s "./bin/winapps" "${BIN_PATH}/winapps"
- $SUDO ln -s "./setup.sh" "${BIN_PATH}/winapps-setup"
# Configure the Windows RDP session application launcher.
waConfigureWindows

View File

@ -0,0 +1,11 @@
--- a/bin/winapps
+++ b/bin/winapps
@@ -295,7 +295,7 @@ function waCheckGroupMembership() {
# shellcheck disable=SC2155 # Silence warnings regarding masking return values through simultaneous declaration and assignment.
local USER_GROUPS=$(groups "$(whoami)")
- if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirt\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then
+ if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirtd\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then
waThrowExit "$EC_NOT_IN_GROUP"
fi
}