-
Notifications
You must be signed in to change notification settings - Fork 9
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
Install VSCodium and make host .application file #86
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,14 @@ else | |
echo "Please set \${WKDEV_SDK} to point to the root of the wkdev-sdk checkout." | ||
exit 1 | ||
fi | ||
if [[ -z ${WKDEV_SDK_HOST} ]]; then | ||
echo "Please set \${WKDEV_SDK_HOST} to point to the the wkdev-sdk checkout (from the host perspective). This is used when creating .desktop entries." | ||
exit 1 | ||
fi | ||
if [[ ! -d /host/${HOME} ]]; then | ||
echo "Host and container home must have the same path: /host/${HOME}" | ||
exit 1 | ||
fi | ||
source "${WKDEV_SDK}/utilities/prerequisites.sh" | ||
|
||
init_application "${0}" "Configures Visual Studio Code." container-only | ||
|
@@ -17,8 +25,10 @@ verify_executables_exist curl | |
argsparse_allow_no_argument true | ||
argsparse_use_option "=yes" "Assume yes for all prompts." | ||
argsparse_use_option "no-extensions" "Don't install extensions." | ||
argsparse_use_option "no-proprietary" "Use VSCodium instead of VSCode." | ||
|
||
install_vscode() { | ||
CODE_EXEC=code | ||
|
||
_log_ "" | ||
_log_ "Installing Visual Studio Code..." | ||
|
@@ -40,7 +50,7 @@ install_vscode() { | |
exit 1 | ||
fi | ||
|
||
if ! sudo apt install /tmp/code.deb; then | ||
if ! sudo apt install -y /tmp/code.deb; then | ||
_log_ "Failed to install Visual Studio Code." | ||
rm /tmp/code.deb | ||
exit 1 | ||
|
@@ -51,15 +61,50 @@ install_vscode() { | |
_log_ "Visual Studio Code has been installed." | ||
} | ||
|
||
install_vscodium() { | ||
CODE_EXEC=codium | ||
|
||
_log_ "" | ||
_log_ "Installing Visual Studio Code (oss)..." | ||
_log_ "" | ||
|
||
if which codium > /dev/null; then | ||
_log_ "Visual Studio Code (oss) is already installed." | ||
return | ||
fi | ||
|
||
wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg \ | ||
| gpg --dearmor \ | ||
| sudo dd of=/usr/share/keyrings/vscodium-archive-keyring.gpg | ||
|
||
echo 'deb [ signed-by=/usr/share/keyrings/vscodium-archive-keyring.gpg ] https://download.vscodium.com/debs vscodium main' \ | ||
| sudo tee /etc/apt/sources.list.d/vscodium.list | ||
|
||
if ! sudo apt update; then | ||
_log_ "Failed to install Visual Studio Code (oss) repo." | ||
exit 1 | ||
fi | ||
|
||
if ! sudo apt install -y codium; then | ||
_log_ "Failed to install Visual Studio Code (oss)." | ||
exit 1 | ||
fi | ||
|
||
_log_ "" | ||
_log_ "Visual Studio Code (oss) has been installed." | ||
} | ||
|
||
install_extension() { | ||
|
||
sudo chown "${USER}" "${HOME}/.config" | ||
|
||
local extension_name="${1}" | ||
local description="${2}" | ||
local ask="${3:-false}" | ||
local response | ||
local installed_extensions | ||
|
||
readarray installed_extensions < <(code --list-extensions) | ||
readarray installed_extensions < <($CODE_EXEC --list-extensions) | ||
|
||
if [[ "${installed_extensions[*]}" =~ "${extension_name}" ]]; then | ||
_log_ "VSCode extension already installed: ${extension_name}" | ||
|
@@ -75,7 +120,7 @@ install_extension() { | |
_log_ "Installing VSCode extension: ${extension_name} (${description})..." | ||
fi | ||
|
||
if ! code --install-extension "${extension_name}" &>/dev/null; then | ||
if ! ${CODE_EXEC} --install-extension "${extension_name}" &>/dev/null; then | ||
_log_ "Failed to install VSCode extension: ${extension_name}" | ||
exit 1 | ||
fi | ||
|
@@ -96,15 +141,118 @@ install_extensions() { | |
install_extension ms-python.python "Python support" true | ||
} | ||
|
||
# These are VERY helpful for WebKit development, but we won't override existing settings if the user already has them. | ||
default_settings() { | ||
if argsparse_is_option_set "no-proprietary"; then | ||
VSCODE_CONFIG_PATH=${HOME}/.config/VSCodium/User/ | ||
else | ||
VSCODE_CONFIG_PATH=${HOME}/.config/Code/User/ | ||
fi | ||
if [[ ! -e "${VSCODE_CONFIG_PATH}/settings.json" ]]; then | ||
mkdir -p "${VSCODE_CONFIG_PATH}" | ||
tee "${VSCODE_CONFIG_PATH}/settings.json" << HERE | ||
{ | ||
"clangd.arguments": [ | ||
"-header-insertion=never" | ||
], | ||
"editor.renderWhitespace": "trailing", | ||
"workbench.colorCustomizations": { | ||
"editorWhitespace.foreground": "#FF0000", | ||
"editorWhitespace.background": "#FF0000" | ||
}, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these are pretty arbitrary. I like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The clangd and fg/bg colours are important for our style guidelines, but I removed the rest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh you just mean to more easily visualize whitespace. I've never needed that and don't think I'd want it by default. I'll check how it looks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh shoot, it doesn't look like that for me. It is only supposed to display trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some other setting is involved. It would be best to keep these PRs small, I'd remove this change here and it can be discussed on its own. |
||
HERE | ||
echo "Installed default VSCode settings to ${VSCODE_CONFIG_PATH}." | ||
else | ||
echo "There was already a VSCode settings.json (${VSCODE_CONFIG_PATH}), skipping." | ||
fi | ||
} | ||
|
||
install_xdg() { | ||
tee "/host/${HOME}/.local/share/applications/code-wkdev.desktop" << HERE | ||
[Desktop Entry] | ||
Name=VSCode WKDev | ||
Comment=Code Editing. Redefined. | ||
GenericName=Text Editor | ||
Exec="${WKDEV_SDK_HOST}/scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC %F | ||
Icon=vscode-wkdev | ||
Type=Application | ||
StartupNotify=false | ||
StartupWMClass=VSCode | ||
Categories=TextEditor;Development;IDE; | ||
MimeType=text/plain;inode/directory;application/x-codium-workspace; | ||
Keywords=vscode;code;vscode; | ||
Actions=new-empty-window; | ||
|
||
[Desktop Action new-empty-window] | ||
Name=New Empty Window | ||
Exec="${WKDEV_SDK_HOST}/scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC --new-window %F | ||
Icon=vscode-wkdev | ||
HERE | ||
chmod +x "/host/${HOME}/.local/share/applications/code-wkdev.desktop" | ||
echo "Installed VSCode host launcher" | ||
} | ||
|
||
install_xdg_oss() { | ||
tee "/host/${HOME}/.local/share/applications/codium-wkdev.desktop" << HERE | ||
[Desktop Entry] | ||
Name=VSCodium WKDev | ||
Comment=Code Editing. Redefined. | ||
GenericName=Text Editor | ||
Exec="${WKDEV_SDK_HOST}/scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC %F | ||
Icon=vscodium-wkdev | ||
Type=Application | ||
StartupNotify=false | ||
StartupWMClass=VSCodium | ||
justinmichaud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Categories=TextEditor;Development;IDE; | ||
MimeType=text/plain;inode/directory;application/x-codium-workspace; | ||
Keywords=vscodium;codium;vscode; | ||
Actions=new-empty-window; | ||
|
||
justinmichaud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[Desktop Action new-empty-window] | ||
Name=New Empty Window | ||
Exec="${WKDEV_SDK_HOST}/scripts/host-only/wkdev-enter" --exec --no-interactive -- $CODE_EXEC --new-window %F | ||
Icon=vscodium-wkdev | ||
HERE | ||
chmod +x "/host/${HOME}/.local/share/applications/codium-wkdev.desktop" | ||
echo "Installed VSCodium host launcher" | ||
} | ||
|
||
install_icon() { | ||
mkdir -p "/host/${HOME}/.local/share/icons/hicolor/256x256/apps/" | ||
cp /usr/share/pixmaps/vscode.png "/host/${HOME}/.local/share/icons/hicolor/256x256/apps/vscode-wkdev.png" | ||
echo "Installed VSCode host icon." | ||
} | ||
|
||
install_icon_oss() { | ||
mkdir -p "/host/${HOME}/.local/share/icons/hicolor/256x256/apps/" | ||
cp /usr/share/pixmaps/vscodium.png "/host/${HOME}/.local/share/icons/hicolor/256x256/apps/vscodium-wkdev.png" | ||
echo "Installed VSCodium host icon." | ||
} | ||
|
||
run() { | ||
|
||
argsparse_parse_options "${@}" | ||
|
||
install_vscode | ||
if argsparse_is_option_set "no-proprietary"; then | ||
install_vscodium | ||
else | ||
install_vscode | ||
fi | ||
|
||
if ! argsparse_is_option_set "no-extensions"; then | ||
install_extensions | ||
fi | ||
|
||
if argsparse_is_option_set "no-proprietary"; then | ||
install_xdg_oss | ||
install_icon_oss | ||
else | ||
install_xdg | ||
install_icon | ||
fi | ||
|
||
default_settings | ||
} | ||
|
||
run "${@}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would .config be owned by a different user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this was an idiosyncrasy of my setup, let's remove it and see if it comes up again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed if you run this script from your firstrun script. It seems it runs as root. I guess I can change my firstrun script to run as the container user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I said makes no sense, since we use $USER here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like systemd makes the config path? At the very least, some files in ~/.config/systemd appear to be owned by root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It very explicitly runs as your user:
webkit-container-sdk/scripts/container-only/.wkdev-init
Line 215 in 2a490d8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While
podman
supports systemd, we don't use it, and I'd expect systemd knows nothing at all about the containers home.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is confusing to me, although .config is definitely owned by root. In particular, so is .config/systemd, which seems to come from nowhere. Do you have any ideas how I can start debugging this?