Skip to content

Commit

Permalink
static: Fix inclusion of XStatic-mdi (Material Design Icons)
Browse files Browse the repository at this point in the history
Fixes so pyScss 1.3.5 works.

And corrects the path, from:

     /static/horizon/lib/mdi/fonts/materialdesignicons-webfont.woff2?v=1.6.50

To:

     /static//horizon/lib/mdi/fonts/materialdesignicons-webfont.woff2?v=1.6.50

This matters for some file servers, like the uwsgi router_static.

Now we don't get all of these errors anymore:

    ERROR scss.ast Function not found: twbs-font-path:1
    ERROR scss.ast Function not found: twbs-font-path:1
    (..repeat..)
    ERROR scss.ast Function not found: function-exists:1
    ERROR scss.ast Function not found: function-exists:1
    (..repeat..)

But just one complaint about the twbs-font-path.

See: Kronuz/pyScss#375
See: https://bugs.launchpad.net/horizon/+bug/1771559
  • Loading branch information
wdoekes committed Sep 25, 2020
1 parent 6fe64ac commit 1b7c353
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ EXPOSE 8080

# Get prerequisites
COPY requirements.txt /tmp/
COPY patches /tmp/patches
COPY venvpatch /tmp/venvpatch

RUN set -x && \
build="python3-pip" && libs="" && tools="" && \
build="python3-pip" && libs="" && tools="patch" && \
ln -s /usr/bin/python3 /usr/bin/python && \
apt-get -q update && \
apt-get -qy dist-upgrade && \
apt-get install -y $build $libs $tools && \
Expand Down Expand Up @@ -37,6 +41,8 @@ RUN set -x && \
--ignore-installed \
-c https://releases.openstack.org/constraints/upper/train \
'django-redis>=4.10.0' && \
# Apply custom patches.
/tmp/venvpatch /tmp/patches --apply && \
apt-get -qy remove --purge $build $tools && \
apt-get -qy autoremove --purge && \
apt-get clean && find /var/lib/apt/lists -delete && \
Expand Down
2 changes: 1 addition & 1 deletion dockrun
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ time python3 /app/manage.py collectstatic --noinput -v0

# Must be done when settings are available because it communicates with
# the cache.
time python3 /app/manage.py compress --force 2>&1 | tail -n10 >&2
time python3 /app/manage.py compress

# Start as www-data
exec /usr/bin/uwsgi /app/uwsgi.ini
1 change: 1 addition & 0 deletions openstack_dashboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@

# And here are sane defaults we want committed in the OSSOBV version:
ALLOWED_HOSTS = ['*'] # we check this in ingress controller anyway
COMPRESS_OFFLINE = True
OPENSTACK_KEYSTONE_DEFAULT_ROLE = 'user' # user exists, but has no perms
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// a corresponding Material Design Icon.
// https://materialdesignicons.com

$mdi-font-path: $static_url + "/horizon/lib/mdi/fonts";
$mdi-font-path: $static_url + "horizon/lib/mdi/fonts";
@import "/horizon/lib/mdi/scss/materialdesignicons.scss";

.fa {
Expand Down
20 changes: 20 additions & 0 deletions patches/xstatic-mdi--launchpad-1771559.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
https://bugs.launchpad.net/horizon/+bug/1771559

--- a/xstatic/pkg/mdi/data/scss/_functions.scss 2019-10-29 16:27:09.640420707 +0100
+++ b/xstatic/pkg/mdi/data/scss/_functions.scss 2019-10-29 16:27:24.256440797 +0100
@@ -1,14 +1,5 @@
@function char($character-code) {
- @if function-exists("selector-append") {
- @return unquote("\"\\#{$character-code}\"");
- }
-
- @if "\\#{'x'}" == "\\x" {
- @return str-slice("\x", 1, 1) + $character-code;
- }
- @else {
- @return #{"\"\\"}#{$character-code + "\""};
- }
+ @return unquote("\"\\#{$character-code}\"");
}

@function mdi($name) {
151 changes: 151 additions & 0 deletions venvpatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/bin/sh
# venvpatch (part of ossobv/vcutil) // wdoekes/2014-2015 // Public Domain
#
# Automatically applies one or more patches to the current python environment.
#
# Use this to apply a set of patches to a python virtualenv and optionally the
# system packages. Group the patches you want to apply in a single directory
# and venvpatch will apply all unapplied ones at once. Specify --apply to
# actually do it.
#
# Usage:
#
# venvpatch PATH_WITH_PATCH_FILES [--apply]
# venvpatch SINGLE_PATCH_FILE [--apply]
#
# Common python project deployment workflow goes like this:
#
# - Create a virtual environment:
# $ mkvirtualenv PROJECT
# - Install the requirements:
# $ pip install -r requirements.txt
# - Apply a set of patches to the requirements:
# $ cdsitepackages
# $ patch -p1 < /path/to/project/patches/somepatch.patch
# $ patch -p0 < /path/to/project/patches/anotherpatch.patch
#
# The venvpatch utility will take care of:
#
# - Applying multiple patch files at once.
# - Checking whether a patch is applied already, and ignoring it otherwise.
# - Autodetecting -p0 and -p1.
# - Autodetecting the destination path, be it in the virtualenv site-packages
# or in the system-global-packages.
#
# In the following example, the first patch has been applied already:
#
# # ls ./docs/patches/1.4/
# issue16211+14029-query-expression-extra-operators-1.4.patch
# pisa3-reportlab-version.patch
#
# # venvpatch ./docs/patches/1.4/
# source = /srv/django-projects/test/docs/patches/1.4/
# [X] issue16211+14029-query-expression-extra-operators-1.4.patch => \
# /srv/virtualenvs/test/lib/python2.7/site-packages
# [ ] pisa3-reportlab-version.patch => /usr/lib/pymodules/python2.7
#
# # venvpatch ./docs/patches/1.4/ --apply
# source = /srv/django-projects/test/docs/patches/1.4/
# [X] issue16211+14029-query-expression-extra-operators-1.4.patch => \
# /srv/virtualenvs/test/lib/python2.7/site-packages
# [N] pisa3-reportlab-version.patch => /usr/lib/pymodules/python2.7
# patching file sx/pisa3/pisa_util.py
#
# A re-run of venvpatch would now show [X] next to both patches. In case of
# errors, an [E] would be shown.
#
patchpath="$1"
test -z "$patchpath" &&
echo "venvpatch: Need SOURCE_PATCH_PATH as first argument" >&2 &&
exit 1
apply="$2"


# Init globals.
local_packages=$(
python -c 'import distutils;print(distutils.sysconfig.get_python_lib())' \
2>/dev/null)
other_packages=$(python -c 'import sys; print(" ".join(sys.path))')
cwd=$(pwd)/
patchpath=$(echo "$patchpath" | sed -e 's#^\([^/]\)#'$cwd'\1#')

# Fetch patch arguments.
patchver=$(patch --version | sed -e '1!d;s/.* //')
if test $(printf '%s\n2.7\n' $patchver | sort -V | head -n1) = 2.7; then
patchargs="--follow-symlinks --forward"
else
patchargs="--forward"
fi


# Echo source path so manual intervention is eased.
if test -f "$patchpath"; then
echo "source = $(dirname "$patchpath")"
else
echo "source = $patchpath"
fi


# Collect possible patches, and loop over them:
ret=0
find "$patchpath" -maxdepth 1 -type f -name '*.patch' | sort |
while read patch; do
patch_basename=$(basename "$patch")

# Get the first file to be patched.
path1=$(grep ^+++ "$patch" | head -n1 | awk '{print $2}')

# Does it begin with a/ or b/ ? Then we should check the second path
# element instead.
# NOTE: $dir may turn out to be a plain file.
if echo "$path1" | grep -q '^[ab]/'; then
dir=$(echo "$path1" | sed -e 's#^[ab]/\([^/]*\)/.*#\1#')
level=1
else
dir=$(echo "$path1" | sed -e 's#^\([^/]*\)/.*#\1#')
level=0
fi

# Where do we patch? In VIRTUAL_ENV or in global?
dest=
for path in $local_packages $other_packages; do
if test -d "$path/$dir" || test -r "$path/$dir"; then
dest="$path"
break
fi
done
if test -z "$dest"; then
cat >&2 <<EOF
venvpatch: No sensible patch location found for '$dir' in $patch
venvpatch: Forgot to enable virtualenv?
EOF
exit 1
fi

# Very well. Let's see what a dry-run does. And if --apply is
# passed as arg2, let's rock.
cd "$dest"
output=$(patch -p$level -i$patch --dry-run $patchargs \
</dev/null 2>&1)
if test $? -eq 0; then
if test "$apply" = "--apply"; then
echo " [N] $patch_basename => $dest"
patch -p$level -i$patch $patchargs || exit 1
else
echo " [ ] $patch_basename => $dest"
fi
elif echo "$output" | grep -q ^Reversed; then
echo " [X] $patch_basename => $dest"
else
echo " [E] $patch_basename => $dest"
echo " Output: "
echo "$output" | sed -e 's/^/ /'
echo " Permission issue? Try:"
echo " sudo env PATH=\$PATH $0 $patch"
ret=1
fi

test $ret = 0 # set status code
done

# vim: set ts=8 sw=4 sts=4 et ai tw=79:

0 comments on commit 1b7c353

Please sign in to comment.