chore(gnome-extensions): Add check if Gnome DE is used
This commit is contained in:
parent
8c0e8fa776
commit
774c9a8d55
1 changed files with 70 additions and 65 deletions
|
|
@ -8,71 +8,76 @@ GNOME_VER=$(gnome-shell --version | sed 's/[^0-9]*\([0-9]*\).*/\1/')
|
||||||
echo "Gnome version: v${GNOME_VER}"
|
echo "Gnome version: v${GNOME_VER}"
|
||||||
|
|
||||||
if [[ ${#GETTEXT_DOMAIN[@]} -gt 0 ]]; then
|
if [[ ${#GETTEXT_DOMAIN[@]} -gt 0 ]]; then
|
||||||
for EXTENSION in "${GETTEXT_DOMAIN[@]}"; do
|
if command -v gnome-shell &> /dev/null; then
|
||||||
URL="https://extensions.gnome.org/extension-data/${EXTENSION}.shell-extension.zip"
|
for EXTENSION in "${GETTEXT_DOMAIN[@]}"; do
|
||||||
TMP_DIR="/tmp/${EXTENSION}"
|
URL="https://extensions.gnome.org/extension-data/${EXTENSION}.shell-extension.zip"
|
||||||
ARCHIVE=$(basename "${URL}")
|
TMP_DIR="/tmp/${EXTENSION}"
|
||||||
ARCHIVE_DIR="${TMP_DIR}/${ARCHIVE}"
|
ARCHIVE=$(basename "${URL}")
|
||||||
VERSION=$(echo "${EXTENSION}" | grep -oP 'v\d+')
|
ARCHIVE_DIR="${TMP_DIR}/${ARCHIVE}"
|
||||||
echo "Installing ${EXTENSION} Gnome extension with version ${VERSION}"
|
VERSION=$(echo "${EXTENSION}" | grep -oP 'v\d+')
|
||||||
# Download archive
|
echo "Installing ${EXTENSION} Gnome extension with version ${VERSION}"
|
||||||
wget --directory-prefix="${TMP_DIR}" "${URL}"
|
# Download archive
|
||||||
# Extract archive
|
wget --directory-prefix="${TMP_DIR}" "${URL}"
|
||||||
echo "Extracting ZIP archive"
|
# Extract archive
|
||||||
unzip "${ARCHIVE_DIR}" -d "${TMP_DIR}" > /dev/null
|
echo "Extracting ZIP archive"
|
||||||
# Remove archive
|
unzip "${ARCHIVE_DIR}" -d "${TMP_DIR}" > /dev/null
|
||||||
echo "Removing archive"
|
# Remove archive
|
||||||
rm "${ARCHIVE_DIR}"
|
echo "Removing archive"
|
||||||
# Read necessary info from metadata.json
|
rm "${ARCHIVE_DIR}"
|
||||||
echo "Reading necessary info from metadata.json"
|
# Read necessary info from metadata.json
|
||||||
EXTENSION_NAME=$(yq '.name' < "${TMP_DIR}/metadata.json")
|
echo "Reading necessary info from metadata.json"
|
||||||
UUID=$(yq '.uuid' < "${TMP_DIR}/metadata.json")
|
EXTENSION_NAME=$(yq '.name' < "${TMP_DIR}/metadata.json")
|
||||||
EXT_GNOME_VER=$(yq '.shell-version[]' < "${TMP_DIR}/metadata.json")
|
UUID=$(yq '.uuid' < "${TMP_DIR}/metadata.json")
|
||||||
# If extension does not have the important key in metadata.json,
|
EXT_GNOME_VER=$(yq '.shell-version[]' < "${TMP_DIR}/metadata.json")
|
||||||
# inform the user & fail the build
|
# If extension does not have the important key in metadata.json,
|
||||||
if [[ "${UUID}" == "null" ]]; then
|
# inform the user & fail the build
|
||||||
echo "ERROR: Extension '${EXTENSION_NAME}' doesn't have 'uuid' key inside metadata.json"
|
if [[ "${UUID}" == "null" ]]; then
|
||||||
echo "You may inform the extension developer about this error, as he can fix it"
|
echo "ERROR: Extension '${EXTENSION_NAME}' doesn't have 'uuid' key inside metadata.json"
|
||||||
exit 1
|
echo "You may inform the extension developer about this error, as he can fix it"
|
||||||
fi
|
exit 1
|
||||||
if [[ "${EXT_GNOME_VER}" == "null" ]]; then
|
fi
|
||||||
echo "ERROR: Extension '${EXTENSION_NAME}' doesn't have 'shell-version' key inside metadata.json"
|
if [[ "${EXT_GNOME_VER}" == "null" ]]; then
|
||||||
echo "You may inform the extension developer about this error, as he can fix it"
|
echo "ERROR: Extension '${EXTENSION_NAME}' doesn't have 'shell-version' key inside metadata.json"
|
||||||
exit 1
|
echo "You may inform the extension developer about this error, as he can fix it"
|
||||||
fi
|
exit 1
|
||||||
# Compare if extension is compatible with current Gnome version
|
fi
|
||||||
# If extension is not compatible, inform the user & fail the build
|
# Compare if extension is compatible with current Gnome version
|
||||||
if ! [[ "${EXT_GNOME_VER}" =~ "${GNOME_VER}" ]]; then
|
# If extension is not compatible, inform the user & fail the build
|
||||||
echo "ERROR: Extension '${EXTENSION_NAME}' is not compatible with current Gnome v${GNOME_VER}!"
|
if ! [[ "${EXT_GNOME_VER}" =~ "${GNOME_VER}" ]]; then
|
||||||
exit 1
|
echo "ERROR: Extension '${EXTENSION_NAME}' is not compatible with current Gnome v${GNOME_VER}!"
|
||||||
fi
|
exit 1
|
||||||
# Install main extension files
|
fi
|
||||||
echo "Installing main extension files"
|
# Install main extension files
|
||||||
install -d -m 0755 "/usr/share/gnome-shell/extensions/${UUID}/"
|
echo "Installing main extension files"
|
||||||
find "${TMP_DIR}" -mindepth 1 -maxdepth 1 ! -path "*locale*" ! -path "*schemas*" -exec cp -r {} "/usr/share/gnome-shell/extensions/${UUID}/" \;
|
install -d -m 0755 "/usr/share/gnome-shell/extensions/${UUID}/"
|
||||||
find "/usr/share/gnome-shell/extensions/${UUID}" -type d -exec chmod 0755 {} +
|
find "${TMP_DIR}" -mindepth 1 -maxdepth 1 ! -path "*locale*" ! -path "*schemas*" -exec cp -r {} "/usr/share/gnome-shell/extensions/${UUID}/" \;
|
||||||
find "/usr/share/gnome-shell/extensions/${UUID}" -type f -exec chmod 0644 {} +
|
find "/usr/share/gnome-shell/extensions/${UUID}" -type d -exec chmod 0755 {} +
|
||||||
# Install schema
|
find "/usr/share/gnome-shell/extensions/${UUID}" -type f -exec chmod 0644 {} +
|
||||||
if [[ -d "${TMP_DIR}/schemas" ]]; then
|
# Install schema
|
||||||
echo "Installing schema extension file"
|
if [[ -d "${TMP_DIR}/schemas" ]]; then
|
||||||
install -d -m 0755 "/usr/share/glib-2.0/schemas/"
|
echo "Installing schema extension file"
|
||||||
install -D -p -m 0644 "${TMP_DIR}/schemas/"*.gschema.xml "/usr/share/glib-2.0/schemas/"
|
install -d -m 0755 "/usr/share/glib-2.0/schemas/"
|
||||||
fi
|
install -D -p -m 0644 "${TMP_DIR}/schemas/"*.gschema.xml "/usr/share/glib-2.0/schemas/"
|
||||||
# Install languages
|
fi
|
||||||
# Locale is not crucial for extensions to work, as they will fallback to gschema.xml
|
# Install languages
|
||||||
# Some of them might not have any locale at the moment
|
# Locale is not crucial for extensions to work, as they will fallback to gschema.xml
|
||||||
# So that's why I made a check for directory
|
# Some of them might not have any locale at the moment
|
||||||
if [[ -d "${TMP_DIR}/locale" ]]; then
|
# So that's why I made a check for directory
|
||||||
echo "Installing language extension files"
|
if [[ -d "${TMP_DIR}/locale" ]]; then
|
||||||
install -d -m 0755 "/usr/share/locale/"
|
echo "Installing language extension files"
|
||||||
cp -r "${TMP_DIR}/locale"/* "/usr/share/locale/"
|
install -d -m 0755 "/usr/share/locale/"
|
||||||
fi
|
cp -r "${TMP_DIR}/locale"/* "/usr/share/locale/"
|
||||||
# Delete the temporary directory
|
fi
|
||||||
echo "Cleaning up the temporary directory"
|
# Delete the temporary directory
|
||||||
rm -r "${TMP_DIR}"
|
echo "Cleaning up the temporary directory"
|
||||||
echo "Extension '${EXTENSION_NAME}' is successfully installed"
|
rm -r "${TMP_DIR}"
|
||||||
echo "----------------------------------DONE----------------------------------"
|
echo "Extension '${EXTENSION_NAME}' is successfully installed"
|
||||||
done
|
echo "----------------------------------DONE----------------------------------"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "ERROR: Your custom image is using non-Gnome desktop environment, where Gnome extensions are not supported"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: You did not specify the extension to install in module recipe file"
|
echo "ERROR: You did not specify the extension to install in module recipe file"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue