Re: Replace a symlink to a directory with a directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday, 21 January 2020 15:47:52 CET Miro Hrončok wrote:
> On 31. 12. 19 11:24, Miro Hrončok wrote:
> 
> > Hello. I was hit by a infamous "replace a symlink to a directory with a 
> > directory" problem in https://bugzilla.redhat.com/show_bug.cgi?id=1787079
> > 
> > 
> >    /usr/lib/python3.8/site-packages/notebook/static/components/moment
> > 
> > 
> > This was a symbolic link, but now it is a directory. The error is:
> > 
> > Error: Transaction test error:
> > 
> >    file 
> > 
> > /usr/lib/python3.8/site-packages/notebook/static/components/moment/min/loc
> > ales.js from 
 install of python3-notebook-6.0.2-2.fc32.noarch conflicts
> > with file from package js-moment-2.18.1-6.fc30.noarch
> > 
> >    file 
> > 
> > /usr/lib/python3.8/site-packages/notebook/static/components/moment/min/mom
> > ent-with-locales.js 
 from install of python3-notebook-6.0.2-2.fc32.noarch
> > conflicts with file from package js-moment-2.18.1-6.fc30.noarch
> > 
> >    file 
> > 
> > /usr/lib/python3.8/site-packages/notebook/static/components/moment/moment.
> > js 
 from install of python3-notebook-6.0.2-2.fc32.noarch conflicts with
> > file from package js-moment-2.18.1-6.fc30.noarch
> > 
> >    file /usr/lib/python3.8/site-packages/notebook/static/components/moment
> >  from 
> 
> > install of python3-notebook-6.0.2-2.fc32.noarch conflicts with file from
> > package 
 python3-notebook-6.0.2-1.fc32.noarch
> > 
> > 
> > When I add:
> > 
> > $ rpm -q --scripts -p python3-notebook-6.0.2-3.fc32.noarch.rpm
> > pretrans scriptlet (using <lua>):
> > path =
> > "/usr/lib/python3.8/site-packages/notebook/static/components/moment"
 st
> > = posix.stat(path)
> > if st and st.type == "link" then
> > 
> >    os.remove(path)
> > 
> > end
> > 
> > Code: https://src.fedoraproject.org/rpms/python-notebook/pull-request/17
> > 
> > I still get:
> > 
> > Error: Transaction test error:
> > 
> >    file 
> > 
> > /usr/lib/python3.8/site-packages/notebook/static/components/moment/min/loc
> > ales.js from 
 install of python3-notebook-6.0.2-3.fc32.noarch conflicts
> > with file from package js-moment-2.18.1-6.fc30.noarch
> > 
> >    file 
> > 
> > /usr/lib/python3.8/site-packages/notebook/static/components/moment/min/mom
> > ent-with-locales.js 
 from install of python3-notebook-6.0.2-3.fc32.noarch
> > conflicts with file from package js-moment-2.18.1-6.fc30.noarch
> > 
> >    file 
> > 
> > /usr/lib/python3.8/site-packages/notebook/static/components/moment/moment.
> > js 
 from install of python3-notebook-6.0.2-3.fc32.noarch conflicts with
> > file from package js-moment-2.18.1-6.fc30.noarch
> > 
> > 
> > What am I doing wrong?
> > 
> > 
> > 
> > Note that I have tried to add this workaround instead:
> > 
> > 
> >    mv moment moment.bundled
> >    ln -vfs moment.bundled moment
> > 
> > 
> > But that clears the update path from 6.0.2-1, but breaks it from 6.0.2-2.
> > 
> > Error: Transaction test error:
> > 
> >    file /usr/lib/python3.8/site-packages/notebook/static/components/moment
> >  from 
> 
> > install of python3-notebook-6.0.2-3.fc32.noarch conflicts with file from
> > package 
 python3-notebook-6.0.2-2.fc32.noarch
> > 
> > 
> > And I would need to add the other (uglier) scriptlet to replace a
> > directory with 
 a symbolic link :(
> 
> 
> 
> Does anybody know what's wrong with this? I am clueless. Thanks.
> 
> 
> -- 
> Miro Hrončok
> --
> Phone: +420777974800
> IRC: mhroncok
> _______________________________________________
> packaging mailing list -- packaging@xxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe send an email to packaging-leave@xxxxxxxxxxxxxxxxxxxxxxx
> Fedora Code of Conduct:
> https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List
> Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List
> Archives:
> https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject
> .org

Workaround:

=====================================================================
%global pypi_name notebook

Name:           python-%{pypi_name}
%global _docdir_fmt %{name}

# Updating this package? Update the list of bundled things bellow
Version:        6.0.2

# a tag like rc1, set to %%{nil} if stable
%global tag %{nil}

# upstream version, like 1.2.3rc1
%global uversion %{version}%{tag}

Release:        3%{tag}%{?dist}
Summary:        A web-based notebook environment for interactive computing
License:        BSD
URL:            http://jupyter.org
Source0:        %pypi_source %{pypi_name} %{uversion}

# Patch to use the TeX fonts from the MathJax package rather than STIXWeb
# See BZ: 1581899, 1580129
Patch0:         0001-Use-MathJax-TeX-fonts-rather-than-STIXWeb.patch

BuildArch:      noarch

BuildRequires:  python3-setuptools
BuildRequires:  python3-devel

BuildRequires:  git-core

# rebuilding js and css
BuildRequires:  /usr/bin/node

# Tests:
BuildRequires:  pandoc

BuildRequires:  python3-dateutil
BuildRequires:  python3-ipykernel >= 4.8
BuildRequires:  python3-ipython_genutils
BuildRequires:  python3-jupyter-client >= 5.2.0
BuildRequires:  python3-jupyter-core >= 4.4.0
BuildRequires:  python3-nbconvert
BuildRequires:  python3-nbformat
BuildRequires:  python3-nose
BuildRequires:  python3-nose-exclude
BuildRequires:  python3-nose_warnings_filters
BuildRequires:  python3-pandocfilters
BuildRequires:  python3-prometheus_client
BuildRequires:  python3-send2trash
BuildRequires:  python3-terminado >= 0.8.1
BuildRequires:  python3-testpath
BuildRequires:  python3-tornado
BuildRequires:  python3-traitlets >= 4.2.1

# Docs:
BuildRequires:  python3-nbsphinx
BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx_rtd_theme
BuildRequires:  python3-sphinxcontrib-github-alt
BuildRequires:  python3-ipython-sphinx


%?python_enable_dependency_generator

%global _description \
The Jupyter Notebook is a web application that allows you to create and \
share documents that contain live code, equations, visualizations, and \
explanatory text. The Notebook has support for multiple programming \
languages, sharing, and interactive widgets.

%description %_description

%package -n     python3-%{pypi_name}
Summary:        A web-based notebook environment for interactive computing
%{?python_provide:%python_provide python3-%{pypi_name}}
%{?python_provide:%python_provide python3-jupyter-%{pypi_name}}
%{?python_provide:%python_provide python3-ipython-%{pypi_name}}
Provides:       python3-jupyter-%{pypi_name} = %{version}-%{release}
Provides:       python3-ipython-%{pypi_name} = %{version}-%{release}
Obsoletes:      python3-ipython-%{pypi_name} < 4
Provides:       %{pypi_name} = %{version}-%{release}
Provides:       jupyter-%{pypi_name} = %{version}-%{release}

Requires:       fontawesome-fonts
Requires:       fontawesome-fonts-web
Requires:       mathjax >= 2.6
Requires:       js-backbone >= 1.2
Requires:       js-marked >= 0.3
Requires:       js-underscore >= 1.8.3

# Versions from bower.json
Provides:       bundled(bootstrap) = 3.4
Provides:       bundled(bootstrap-tour) = 0.9.0
Provides:       bundled(codemirror) = 5.48.4
Provides:       bundled(create-react-class) = 15.6.3
Provides:       bundled(es6-promise) = 1.0
Provides:       bundled(google-caja) = 5669
Provides:       bundled(jed) = 1.1.1
Provides:       bundled(jquery) = 3.4.1
Provides:       bundled(jquery-typeahead) = 2.0.0
Provides:       bundled(jquery-ui) = 1.12
Provides:       bundled(moment) = 2.19.3
Provides:       bundled(react) = 16.0.0
Provides:       bundled(requirejs) = 2.2
Provides:       bundled(requirejs-text) = 2.0.15
Provides:       bundled(requirejs-plugins) = 1.0.3
Provides:       bundled(text-encoding) = 0.1
Provides:       bundled(xterm.js) = 2.9.2
# See https://bugzilla.redhat.com/show_bug.cgi?id=1580129
#Provides:       bundled(mathjax) = 2.7.4

%description -n python3-%{pypi_name} %_description

%package -n python-%{pypi_name}-doc
Summary:        notebook documentation
%description -n python-%{pypi_name}-doc
Documentation for notebook

%prep
%autosetup -n %{pypi_name}-%{uversion} -S git

%build
%py3_build

# generate html docs
sphinx-build-3 -D intersphinx_timeout=1 docs/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}


%install
%py3_install

# https://github.com/jupyter/notebook/issues/2373
rm -f %{buildroot}%{_bindir}/less-watch

# unbundle stuff
pushd %{buildroot}%{python3_sitelib}/%{pypi_name}/static/components

  rm -r font-awesome/fonts
  ln -vfs %{_datadir}/fonts/fontawesome font-awesome/fonts

  #temporarily kept bundled to workaround #1580129
  rm -r MathJax
  ln -vfs %{_datadir}/javascript/mathjax MathJax

  rm -r backbone
  ln -vfs %{_datadir}/javascript/backbone backbone

  rm -r marked/lib
  ln -vfs %{_datadir}/javascript/marked marked/lib

  rm -r underscore
  ln -vfs %{_datadir}/javascript/underscore underscore

popd

mv %{buildroot}%{python3_sitelib}/%{pypi_name}/static/components/moment %
{buildroot}%{python3_sitelib}/%{pypi_name}/static/components/moment2


%check
# Workaround: OSError: [Errno 18] Invalid cross-device link: b'/tmp/...' -> 
b'/builddir/.local/share/Trash/files/...'
mkdir .tmp
export TMPDIR=$(pwd)/.tmp

nosetests-3 -v --exclude-dir notebook/tests/selenium


# This was previously unbundled, but no more
# See https://docs.fedoraproject.org/en-US/packaging-guidelines/
Directory_Replacement/
%pretrans -n python3-%{pypi_name} -p <lua>
path = "%{python3_sitelib}/%{pypi_name}/static/components/moment"
st = posix.stat(path)
if st and st.type == "link" then
  os.remove(path)
end

%posttrans -n python3-%{pypi_name} -p <lua>
originalpath = "%{python3_sitelib}/%{pypi_name}/static/components/moment"
path = "%{python3_sitelib}/%{pypi_name}/static/components/moment2"
st = posix.stat(path)
if st and st.type == "directory" then
  os.rename(path, originalpath)
end

%files -n python3-%{pypi_name}
%doc README.md
%license LICENSE
%{_bindir}/jupyter-bundlerextension
%{_bindir}/jupyter-nbextension
%{_bindir}/jupyter-serverextension
%{_bindir}/jupyter-notebook
%{python3_sitelib}/%{pypi_name}-%{uversion}-py*.egg-info
%{python3_sitelib}/%{pypi_name}/
%ghost %{python3_sitelib}/%{pypi_name}/static/components/moment

%files -n python-%{pypi_name}-doc
%doc html
%license LICENSE


%changelog
=====================================================================

You will get message like this at update/uninstall but there are not fatal:

warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2/moment.js: remove failed: No such file or directory
warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2/min/moment.min.js: remove failed: No such file or directory
warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2/min/moment-with-locales.min.js: remove failed: No such file or 
directory
warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2/min/moment-with-locales.js: remove failed: No such file or directory
warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2/min/locales.min.js: remove failed: No such file or directory
warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2/min/locales.js: remove failed: No such file or directory
warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2/min: remove failed: No such file or directory
warning: file /usr/lib/python3.8/site-packages/notebook/static/components/
moment2: remove failed: No such file or directory


This work because we are triggering the beingRemoved and have RPMTAG_PRETRANS 
path of the code which cause rConflicts to be 0:

	if (beingRemoved) {
	    rConflicts = handleRemovalConflict(fi, fx, otherFi, ofx);
	    if (rConflicts && rpmteHaveTransScript(p, RPMTAG_PRETRANS)) {
		if (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
		    rConflicts = 0;
	    }
	}

Still I think the issue should be reported upstream.

Don't forget the %ghost directive so that the correct path is effectively 
handled by rpm on future removal/upgrade.




_______________________________________________
packaging mailing list -- packaging@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to packaging-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/packaging@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite Forum]     [KDE Users]

  Powered by Linux