diff --git a/.gitignore b/.gitignore
index 2b6e120..139bf42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@
 /sage-7.5.1.tar.gz
 /sage-7.6.tar.gz
 /sage-8.0.tar.gz
+/sage-8.2.tar.gz
diff --git a/makecmds.sty b/makecmds.sty
deleted file mode 100644
index 7805257..0000000
--- a/makecmds.sty
+++ /dev/null
@@ -1,95 +0,0 @@
-%%
-%% This is file `makecmds.sty',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% makecmds.dtx  (with options: `usc')
-%% 
-%%  Copyright 2000 Peter R. Wilson
-%% 
-%%  This program is provided under the terms of the
-%%  LaTeX Project Public License distributed from CTAN
-%%  archives in directory macros/latex/base/lppl.txt.
-%% 
-%% Author: Peter Wilson (CUA)
-%%         now at: peter.r.wilson@boeing.com
-%% 
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{makecmds}[2000/05/27 v1.0 extra command making commands]
-
-\newif\ifm@kwarn
-  \m@kwarnfalse
-\DeclareOption{warn}{\m@kwarntrue}
-\ProcessOptions\relax
-
-\def\makecommand{\@star@or@long\m@ke@command}
-\def\m@ke@command#1{%
-  \ifx #1\undefined\else
-    \ifm@kwarn
-      \PackageWarning{makecmds}{Redefining command `\protect#1'}
-    \fi
-  \fi
-  \let\@ifdefinable\@rc@ifdefinable
-  \new@command#1}
-
-\def\provideenvironment{%
-  \@star@or@long\m@kprovide@environment}
-\def\m@kprovide@environment#1{%
-  \@ifundefined{#1}{%
-    \expandafter\let\csname#1\endcsname\relax
-    \expandafter\let\csname end#1\endcsname\relax
-    \new@environment{#1}}{\m@kdiscardenvargs{#1}}
-}
-\def\m@kdiscardenvargs#1{%
-  \@testopt{\m@kenva#1}0}
-\def\m@kenva#1[#2]{%
-  \@ifnextchar [{\m@kenvb#1[#2]}{\m@kthrowenv{#1}{[#2]}}}
-\def\m@kenvb#1[#2][#3]{\m@kthrowenv{#1}{[#2][#3]}}
-\def\m@kthrowenv#1#2#3#4{}
-
-\def\makeenvironment{\@star@or@long\m@ke@environment}
-\def\m@ke@environment#1{%
-  \@ifundefined{#1}{\new@environment{#1}}{%
-    \ifm@kwarn
-      \PackageWarning{makecmds}{Redefining environment `#1'}
-    \fi
-    \renew@environment{#1}}
-}
-
-\def\providelength#1{%
-  \ifx #1\undefined
-    \newlength{#1}
-  \fi
-}
-\def\makelength#1{%
-  \ifx #1\undefined
-    \newlength{#1}
-  \else
-    \ifm@kwarn
-      \PackageWarning{makecmds}{Redefining length `\protect#1'}
-    \fi
-    \newskip#1
-  \fi
-}
-
-\def\providecounter#1{%
-  \@ifundefined{c@#1}{\newcounter{#1}}{%
-    \@ifnextchar[{\m@k@gobbleendoptarg}{}}%
-}
-\def\makecounter#1{%
-  \expandafter\ifx \csname c@#1\endcsname \undefined
-  \else
-    \ifm@kwarn
-      \PackageWarning{makecmds}{Redefining counter `#1'}
-    \fi
-  \fi
-  \@definecounter{#1}%
-  \@ifnextchar[{\@newctr{#1}}{}
-}
-
-\def\m@k@gobbleendoptarg[#1]{}
-
-\endinput
-%%
-%% End of file `makecmds.sty'.
diff --git a/sagemath-4ti2.patch b/sagemath-4ti2.patch
index 1c256e6..7caaeff 100644
--- a/sagemath-4ti2.patch
+++ b/sagemath-4ti2.patch
@@ -1,7 +1,7 @@
 diff -up src/sage/sandpiles/sandpile.py.orig src/sage/sandpiles/sandpile.py
---- src/sage/sandpiles/sandpile.py.orig	2017-04-11 09:56:54.907264014 -0400
-+++ src/sage/sandpiles/sandpile.py	2017-04-11 09:57:04.274264373 -0400
-@@ -347,9 +347,6 @@ from sage.arith.all import falling_facto
+--- src/sage/sandpiles/sandpile.py.orig	2018-05-05 16:21:26.000000000 -0600
++++ src/sage/sandpiles/sandpile.py	2018-05-16 13:28:24.939025388 -0600
+@@ -342,9 +342,6 @@ from sage.arith.all import falling_facto
  from sage.rings.all import Integer, PolynomialRing, QQ, ZZ
  from sage.symbolic.all import I, pi
  
@@ -11,7 +11,7 @@ diff -up src/sage/sandpiles/sandpile.py.orig src/sage/sandpiles/sandpile.py
  class Sandpile(DiGraph):
      """
      Class for Dhar's abelian sandpile model.
-@@ -5202,7 +5199,7 @@ class SandpileDivisor(dict):
+@@ -5199,7 +5196,7 @@ class SandpileDivisor(dict):
          sign_file.close()
          # compute
          try:
diff --git a/sagemath-arb.patch b/sagemath-arb.patch
index 7649f4a..7ad3797 100644
--- a/sagemath-arb.patch
+++ b/sagemath-arb.patch
@@ -1,6 +1,6 @@
 diff -up src/sage/libs/arb/acb.pxd.orig src/sage/libs/arb/acb.pxd
---- src/sage/libs/arb/acb.pxd.orig	2016-08-08 14:02:11.176595456 -0400
-+++ src/sage/libs/arb/acb.pxd	2016-08-08 14:02:17.514595699 -0400
+--- src/sage/libs/arb/acb.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/acb.pxd	2018-05-16 13:59:18.715290712 -0600
 @@ -3,7 +3,7 @@
  from sage.libs.arb.types cimport *
  from sage.libs.flint.types cimport fmpz_t, fmpq_t
@@ -10,45 +10,9 @@ diff -up src/sage/libs/arb/acb.pxd.orig src/sage/libs/arb/acb.pxd
  
      arb_t acb_realref(acb_t x)
      arb_t acb_imagref(acb_t x)
-diff -up src/sage/libs/arb/arb.pxd.orig src/sage/libs/arb/arb.pxd
---- src/sage/libs/arb/arb.pxd.orig	2016-08-08 14:02:26.528596044 -0400
-+++ src/sage/libs/arb/arb.pxd	2016-08-08 14:02:33.554596313 -0400
-@@ -4,7 +4,7 @@ from sage.libs.arb.types cimport *
- from sage.libs.flint.types cimport fmpz_t, fmpq_t
- from sage.libs.mpfr cimport mpfr_t
- 
--cdef extern from "arb.h":
-+cdef extern from "arb/arb.h":
- 
-     arf_t arb_midref(arb_t x)
-     mag_t arb_radref(arb_t x)
-diff -up src/sage/libs/arb/arf.pxd.orig src/sage/libs/arb/arf.pxd
---- src/sage/libs/arb/arf.pxd.orig	2016-08-08 14:02:45.928596787 -0400
-+++ src/sage/libs/arb/arf.pxd	2016-08-08 14:02:53.194597065 -0400
-@@ -5,7 +5,7 @@ from sage.libs.gmp.types cimport mpz_t
- from sage.libs.flint.types cimport fmpz_t
- from sage.libs.mpfr cimport mpfr_t, mpfr_rnd_t
- 
--cdef extern from "arf.h":
-+cdef extern from "arb/arf.h":
-     void arf_init(arf_t x)
-     void arf_clear(arf_t x)
-     void arf_zero(arf_t x)
-diff -up src/sage/libs/arb/mag.pxd.orig src/sage/libs/arb/mag.pxd
---- src/sage/libs/arb/mag.pxd.orig	2016-08-08 14:03:03.208597449 -0400
-+++ src/sage/libs/arb/mag.pxd	2016-08-08 14:03:10.010597709 -0400
-@@ -3,7 +3,7 @@
- from sage.libs.arb.types cimport *
- from sage.libs.flint.types cimport fmpz_t, fmpq_t
- 
--cdef extern from "mag.h":
-+cdef extern from "arb/mag.h":
-     void mag_init(mag_t x)
-     void mag_clear(mag_t x)
-     void mag_init_set(mag_t x, const mag_t y)
 diff -up src/sage/libs/arb/acb_hypgeom.pxd.orig src/sage/libs/arb/acb_hypgeom.pxd
---- src/sage/libs/arb/acb_hypgeom.pxd.orig	2016-08-09 14:18:12.798626773 -0400
-+++ src/sage/libs/arb/acb_hypgeom.pxd	2016-08-09 14:18:18.591626994 -0400
+--- src/sage/libs/arb/acb_hypgeom.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/acb_hypgeom.pxd	2018-05-16 13:59:18.717290684 -0600
 @@ -2,7 +2,7 @@
  
  from sage.libs.arb.types cimport *
@@ -59,8 +23,8 @@ diff -up src/sage/libs/arb/acb_hypgeom.pxd.orig src/sage/libs/arb/acb_hypgeom.px
      long acb_hypgeom_pfq_choose_n(acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long prec)
      void acb_hypgeom_pfq_sum_forward(acb_t s, acb_t t, acb_srcptr a, long p, acb_srcptr b, long q, const acb_t z, long n, long prec)
 diff -up src/sage/libs/arb/acb_mat.pxd.orig src/sage/libs/arb/acb_mat.pxd
---- src/sage/libs/arb/acb_mat.pxd.orig	2016-08-09 14:18:29.126627398 -0400
-+++ src/sage/libs/arb/acb_mat.pxd	2016-08-09 14:18:33.559627568 -0400
+--- src/sage/libs/arb/acb_mat.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/acb_mat.pxd	2018-05-16 13:59:18.717290684 -0600
 @@ -1,6 +1,6 @@
  from sage.libs.arb.types cimport acb_t, acb_mat_t
  
@@ -70,8 +34,8 @@ diff -up src/sage/libs/arb/acb_mat.pxd.orig src/sage/libs/arb/acb_mat.pxd
      unsigned int acb_mat_ncols(acb_mat_t mat)
      acb_t acb_mat_entry(acb_mat_t mat, unsigned long i, unsigned long j)
 diff -up src/sage/libs/arb/acb_modular.pxd.orig src/sage/libs/arb/acb_modular.pxd
---- src/sage/libs/arb/acb_modular.pxd.orig	2016-08-09 14:18:42.526627911 -0400
-+++ src/sage/libs/arb/acb_modular.pxd	2016-08-09 14:18:46.191628051 -0400
+--- src/sage/libs/arb/acb_modular.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/acb_modular.pxd	2018-05-16 13:59:18.718290670 -0600
 @@ -3,7 +3,7 @@
  from sage.libs.arb.types cimport *
  from sage.libs.flint.types cimport fmpz_poly_t
@@ -81,19 +45,9 @@ diff -up src/sage/libs/arb/acb_modular.pxd.orig src/sage/libs/arb/acb_modular.px
      void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, long prec)
      void acb_modular_j(acb_t z, const acb_t tau, long prec)
      void acb_modular_eta(acb_t z, const acb_t tau, long prec)
-diff -up src/sage/libs/arb/bernoulli.pxd.orig src/sage/libs/arb/bernoulli.pxd
---- src/sage/libs/arb/bernoulli.pxd.orig	2016-08-09 14:19:29.102629695 -0400
-+++ src/sage/libs/arb/bernoulli.pxd	2016-08-09 14:19:33.495629863 -0400
-@@ -2,5 +2,5 @@
- 
- from ..flint.types cimport fmpq_t, ulong
- 
--cdef extern from "bernoulli.h":
-+cdef extern from "arb/bernoulli.h":
-     void bernoulli_fmpq_ui(fmpq_t b, ulong n)
 diff -up src/sage/libs/arb/acb_poly.pxd.orig src/sage/libs/arb/acb_poly.pxd
---- src/sage/libs/arb/acb_poly.pxd.orig	2017-03-29 18:10:08.675927202 -0400
-+++ src/sage/libs/arb/acb_poly.pxd	2017-03-29 18:10:13.934927403 -0400
+--- src/sage/libs/arb/acb_poly.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/acb_poly.pxd	2018-05-16 13:59:18.719290655 -0600
 @@ -3,7 +3,7 @@
  from sage.libs.arb.types cimport *
  from sage.libs.flint.types cimport fmpz_poly_t, fmpq_poly_t
@@ -103,9 +57,43 @@ diff -up src/sage/libs/arb/acb_poly.pxd.orig src/sage/libs/arb/acb_poly.pxd
      void acb_poly_init(acb_poly_t poly)
      void acb_poly_clear(acb_poly_t poly)
      void acb_poly_fit_length(acb_poly_t poly, long len)
+diff -up src/sage/libs/arb/arf.pxd.orig src/sage/libs/arb/arf.pxd
+--- src/sage/libs/arb/arf.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/arf.pxd	2018-05-16 13:59:18.716290698 -0600
+@@ -5,7 +5,7 @@ from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.mpfr.types cimport mpfr_t, mpfr_rnd_t
+ 
+-cdef extern from "arf.h":
++cdef extern from "arb/arf.h":
+     void arf_init(arf_t x)
+     void arf_clear(arf_t x)
+     void arf_zero(arf_t x)
+diff -up src/sage/libs/arb/bernoulli.pxd.orig src/sage/libs/arb/bernoulli.pxd
+--- src/sage/libs/arb/bernoulli.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/bernoulli.pxd	2018-05-16 13:59:18.718290670 -0600
+@@ -2,5 +2,5 @@
+ 
+ from ..flint.types cimport fmpq_t, ulong
+ 
+-cdef extern from "bernoulli.h":
++cdef extern from "arb/bernoulli.h":
+     void bernoulli_fmpq_ui(fmpq_t b, ulong n)
+diff -up src/sage/libs/arb/mag.pxd.orig src/sage/libs/arb/mag.pxd
+--- src/sage/libs/arb/mag.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/mag.pxd	2018-05-16 13:59:18.717290684 -0600
+@@ -3,7 +3,7 @@
+ from sage.libs.arb.types cimport *
+ from sage.libs.flint.types cimport fmpz_t, fmpq_t
+ 
+-cdef extern from "mag.h":
++cdef extern from "arb/mag.h":
+     void mag_init(mag_t x)
+     void mag_clear(mag_t x)
+     void mag_init_set(mag_t x, const mag_t y)
 diff -up src/sage/libs/arb/types.pxd.orig src/sage/libs/arb/types.pxd
---- src/sage/libs/arb/types.pxd.orig	2017-03-29 18:08:42.979923920 -0400
-+++ src/sage/libs/arb/types.pxd	2017-03-29 18:09:18.413925277 -0400
+--- src/sage/libs/arb/types.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/arb/types.pxd	2018-05-16 13:59:18.719290655 -0600
 @@ -1,4 +1,4 @@
 -cdef extern from "mag.h":
 +cdef extern from "arb/mag.h":
diff --git a/sagemath-atlas.patch b/sagemath-atlas.patch
index 0813db7..211dba2 100644
--- a/sagemath-atlas.patch
+++ b/sagemath-atlas.patch
@@ -1,6 +1,6 @@
 diff -up src/module_list.py.orig src/module_list.py
---- src/module_list.py.orig	2017-11-08 08:34:54.635233833 -0500
-+++ src/module_list.py	2017-11-08 08:36:05.888236561 -0500
+--- src/module_list.py.orig	2018-05-16 14:13:22.021406801 -0600
++++ src/module_list.py	2018-05-16 14:15:57.654208949 -0600
 @@ -12,7 +12,7 @@ SAGE_INC = '/usr/include'
  import pkgconfig
  
@@ -23,23 +23,12 @@ diff -up src/module_list.py.orig src/module_list.py
 +lapack_library_dirs = []
 +lapack_include_dirs = [ SAGE_INC + '/lapack' ]
  
- # FFLAS-FFPACK
- fflas_ffpack_pc = pkgconfig.parse('fflas-ffpack')
-@@ -44,7 +42,9 @@ givaro_cflags = pkgconfig.cflags('givaro
- # The above cblas should already be in the list thanks to #20646
- gsl_pc = pkgconfig.parse('gsl')
- gsl_libs = gsl_pc['libraries']
--gsl_library_dirs = gsl_pc['library_dirs']
-+gsl_libs.remove('gslcblas')
-+gsl_libs.extend(cblas_libs)
-+gsl_library_dirs = list(cblas_pc['library_dirs'])
- gsl_include_dirs = gsl_pc['include_dirs']
- 
  # GD image library
+ gd_pc = pkgconfig.parse('gdlib')
 diff -up src/sage/misc/cython.py.orig src/sage/misc/cython.py
---- src/sage/misc/cython.py.orig	2017-11-08 08:36:27.499237389 -0500
-+++ src/sage/misc/cython.py	2017-11-08 08:36:37.240237762 -0500
-@@ -30,7 +30,7 @@ import pkgconfig
+--- src/sage/misc/cython.py.orig	2018-05-16 13:16:29.207708998 -0600
++++ src/sage/misc/cython.py	2018-05-16 14:15:57.656208921 -0600
+@@ -40,7 +40,7 @@ from sage.misc.sage_ostools import resto
  
  
  # CBLAS can be one of multiple implementations
diff --git a/sagemath-cbc.patch b/sagemath-cbc.patch
index 27d5dd7..709f238 100644
--- a/sagemath-cbc.patch
+++ b/sagemath-cbc.patch
@@ -1,14 +1,14 @@
 diff -up src/sage/numerical/backends/coin_backend.pyx.orig src/sage/numerical/backends/coin_backend.pyx
---- src/sage/numerical/backends/coin_backend.pyx.orig	2017-11-08 08:23:51.731208448 -0500
-+++ src/sage/numerical/backends/coin_backend.pyx	2017-11-08 08:24:02.347208854 -0500
-@@ -759,8 +759,8 @@ cdef class CoinBackend(GenericBackend):
+--- src/sage/numerical/backends/coin_backend.pyx.orig	2018-05-16 13:40:23.571130540 -0600
++++ src/sage/numerical/backends/coin_backend.pyx	2018-05-16 13:41:06.750534427 -0600
+@@ -762,8 +762,8 @@ cdef class CoinBackend(GenericBackend):
          model.setLogLevel(old_logLevel)
  
          # multithreading
 -        import multiprocessing
--        model.setNumberThreads(multiprocessing.cpu_count())
+-        model.setNumberThreads(ncpus())
 +        #import multiprocessing
-+        #model.setNumberThreads(multiprocessing.cpu_count())
++        #model.setNumberThreads(ncpus())
  
          model.branchAndBound()
  
diff --git a/sagemath-extensions.patch b/sagemath-extensions.patch
index 1610fd8..6758840 100644
--- a/sagemath-extensions.patch
+++ b/sagemath-extensions.patch
@@ -1,52 +1,33 @@
 diff -up src/module_list.py.orig src/module_list.py
---- src/module_list.py.orig	2017-11-08 06:12:26.727906504 -0500
-+++ src/module_list.py	2017-11-08 06:14:29.020911187 -0500
-@@ -163,7 +163,6 @@ library_order["stdc++"] = 1000
- ###
- #############################################################
- 
--from sage_setup.optional_extension import OptionalExtension
- UNAME = os.uname()
- 
- def uname_specific(name, value, alternative):
-@@ -391,21 +390,21 @@ ext_modules = [
-               sources = ['sage/graphs/matchpoly.pyx'],
-               extra_compile_args = ['-std=c99']),
+--- src/module_list.py.orig	2018-05-05 16:21:22.000000000 -0600
++++ src/module_list.py	2018-05-18 07:46:16.531947286 -0600
+@@ -358,16 +358,16 @@ ext_modules = [
+     Extension('sage.graphs.matchpoly',
+               sources = ['sage/graphs/matchpoly.pyx']),
  
 -    OptionalExtension("sage.graphs.mcqd",
 -              ["sage/graphs/mcqd.pyx"],
 -              language = "c++",
 -              package = 'mcqd'),
--
++#    OptionalExtension("sage.graphs.mcqd",
++#              ["sage/graphs/mcqd.pyx"],
++#              language = "c++",
++#              package = 'mcqd'),
+ 
 -    OptionalExtension("sage.graphs.bliss",
 -              ["sage/graphs/bliss.pyx"],
 -              language = "c++",
 -              libraries = ['bliss'],
 -              package = 'bliss'),
--
--    OptionalExtension('sage.graphs.modular_decomposition',
--              sources = ['sage/graphs/modular_decomposition.pyx'],
--              libraries = ['modulardecomposition'],
--              package = 'modular_decomposition'),
-+#    OptionalExtension("sage.graphs.mcqd",
-+#              ["sage/graphs/mcqd.pyx"],
-+#              language = "c++",
-+#              package = 'mcqd'),
-+
 +#    OptionalExtension("sage.graphs.bliss",
 +#              ["sage/graphs/bliss.pyx"],
 +#              language = "c++",
 +#              libraries = ['bliss'],
 +#              package = 'bliss'),
-+
-+#    OptionalExtension('sage.graphs.modular_decomposition',
-+#              sources = ['sage/graphs/modular_decomposition.pyx'],
-+#              libraries = ['modulardecomposition'],
-+#              package = 'modular_decomposition'),
  
      Extension('sage.graphs.planarity',
                sources = ['sage/graphs/planarity.pyx'],
-@@ -424,10 +423,10 @@ ext_modules = [
+@@ -386,10 +386,10 @@ ext_modules = [
      Extension('sage.graphs.graph_decompositions.cutwidth',
                sources = ['sage/graphs/graph_decompositions/cutwidth.pyx']),
  
@@ -61,7 +42,7 @@ diff -up src/module_list.py.orig src/module_list.py
  
      Extension('sage.graphs.spanning_tree',
                sources = ['sage/graphs/spanning_tree.pyx']),
-@@ -514,17 +513,17 @@ ext_modules = [
+@@ -454,21 +454,20 @@ ext_modules = [
      ##
      ################################
  
@@ -85,8 +66,13 @@ diff -up src/module_list.py.orig src/module_list.py
 +    Extension("sage.libs.fes",
               ["sage/libs/fes.pyx"],
               language = "c",
-              libraries = ['fes'],
-@@ -548,23 +547,23 @@ ext_modules = [
+-             libraries = ['fes'],
+-             package = 'fes'),
++             libraries = ['fes']),
+ 
+     Extension('sage.libs.flint.flint',
+               sources = ["sage/libs/flint/flint.pyx"],
+@@ -488,22 +487,22 @@ ext_modules = [
      Extension('sage.libs.gmp.pylong',
                sources = ['sage/libs/gmp/pylong.pyx']),
  
@@ -95,39 +81,35 @@ diff -up src/module_list.py.orig src/module_list.py
 -                      libraries = ["braiding"],
 -                      package="libbraiding",
 -                      language = 'c++'),
--
--
--    OptionalExtension('sage.libs.homfly',
--                      sources = ["sage/libs/homfly.pyx"],
--                      libraries = ["homfly", "gc"],
--                      package="libhomfly"),
--
--    OptionalExtension('sage.libs.sirocco',
--                      sources = ["sage/libs/sirocco.pyx"],
--                      libraries = ["sirocco", "mpfr", "gmp"],
--                      package="sirocco",
--                      language = 'c++'),
 +#    OptionalExtension('sage.libs.braiding',
 +#                      sources = ["sage/libs/braiding.pyx"],
 +#                      libraries = ["braiding"],
 +#                      package="libbraiding",
 +#                      language = 'c++'),
-+
-+
+ 
+-    OptionalExtension('sage.libs.homfly',
+-                      sources = ["sage/libs/homfly.pyx"],
+-                      libraries = ["homfly", "gc"],
+-                      package="libhomfly"),
 +#    OptionalExtension('sage.libs.homfly',
 +#                      sources = ["sage/libs/homfly.pyx"],
 +#                      libraries = ["homfly", "gc"],
 +#                      package="libhomfly"),
-+
+ 
+-    OptionalExtension('sage.libs.sirocco',
+-                      sources = ["sage/libs/sirocco.pyx"],
+-                      libraries = ["sirocco"],
+-                      package="sirocco",
+-                      language = 'c++'),
 +#    OptionalExtension('sage.libs.sirocco',
 +#                      sources = ["sage/libs/sirocco.pyx"],
-+#                      libraries = ["sirocco", "mpfr", "gmp"],
++#                      libraries = ["sirocco"],
 +#                      package="sirocco",
 +#                      language = 'c++'),
  
      Extension('*', ['sage/libs/linbox/*.pyx']),
  
-@@ -901,10 +900,10 @@ ext_modules = [
+@@ -844,10 +843,10 @@ ext_modules = [
      Extension('sage.matrix.matrix_window',
                sources = ['sage/matrix/matrix_window.pyx']),
  
@@ -141,31 +123,30 @@ diff -up src/module_list.py.orig src/module_list.py
 +#              package = 'meataxe'),
  
      Extension('sage.matrix.misc',
-               sources = ['sage/matrix/misc.pyx'],
-@@ -1089,19 +1088,19 @@ ext_modules = [
+               sources = ['sage/matrix/misc.pyx']),
+@@ -1024,26 +1023,25 @@ ext_modules = [
      Extension("sage.numerical.backends.interactivelp_backend",
                ["sage/numerical/backends/interactivelp_backend.pyx"]),
  
 -    OptionalExtension("sage.numerical.backends.gurobi_backend",
 -              ["sage/numerical/backends/gurobi_backend.pyx"],
--              libraries = ["stdc++", "gurobi"],
+-              libraries = ["gurobi"],
 -              condition = os.path.isfile(SAGE_INC + "/gurobi_c.h") and
 -                  os.path.isfile(SAGE_LOCAL + "/lib/libgurobi.so")),
--
--    OptionalExtension("sage.numerical.backends.cplex_backend",
--              ["sage/numerical/backends/cplex_backend.pyx"],
--              libraries = ["stdc++", "cplex"],
--              condition = os.path.isfile(SAGE_INC + "/cplex.h") and
--                  os.path.isfile(SAGE_LOCAL + "/lib/libcplex.a")),
 +#    OptionalExtension("sage.numerical.backends.gurobi_backend",
 +#              ["sage/numerical/backends/gurobi_backend.pyx"],
-+#              libraries = ["stdc++", "gurobi"],
++#              libraries = ["gurobi"],
 +#              condition = os.path.isfile(SAGE_INC + "/gurobi_c.h") and
 +#                  os.path.isfile(SAGE_LOCAL + "/lib/libgurobi.so")),
-+
+ 
+-    OptionalExtension("sage.numerical.backends.cplex_backend",
+-              ["sage/numerical/backends/cplex_backend.pyx"],
+-              libraries = ["cplex"],
+-              condition = os.path.isfile(SAGE_INC + "/cplex.h") and
+-                  os.path.isfile(SAGE_LOCAL + "/lib/libcplex.a")),
 +#    OptionalExtension("sage.numerical.backends.cplex_backend",
 +#              ["sage/numerical/backends/cplex_backend.pyx"],
-+#              libraries = ["stdc++", "cplex"],
++#              libraries = ["cplex"],
 +#              condition = os.path.isfile(SAGE_INC + "/cplex.h") and
 +#                  os.path.isfile(SAGE_LOCAL + "/lib/libcplex.a")),
  
@@ -174,3 +155,11 @@ diff -up src/module_list.py.orig src/module_list.py
                ["sage/numerical/backends/coin_backend.pyx"],
                language = 'c++',
                libraries = ["Cbc", "CbcSolver", "Cgl", "Clp", "CoinUtils",
+                            "OsiCbc", "OsiClp", "Osi"] + lapack_libs,
+               library_dirs = lapack_library_dirs,
+-              include_dirs = lapack_include_dirs,
+-              package = 'cbc'),
++              include_dirs = lapack_include_dirs),
+ 
+     ################################
+     ##
diff --git a/sagemath-fes.patch b/sagemath-fes.patch
index 2e02f9f..7fbb79d 100644
--- a/sagemath-fes.patch
+++ b/sagemath-fes.patch
@@ -1,20 +1,18 @@
 diff -up src/module_list.py.orig src/module_list.py
---- src/module_list.py.orig	2017-11-08 08:27:07.539215946 -0500
-+++ src/module_list.py	2017-11-08 08:27:17.051216310 -0500
-@@ -523,11 +523,11 @@ ext_modules = [
+--- src/module_list.py.orig	2018-05-18 09:34:28.942183178 -0600
++++ src/module_list.py	2018-05-18 09:35:15.210542150 -0600
+@@ -464,10 +464,10 @@ ext_modules = [
      Extension('sage.libs.ecl',
                sources = ["sage/libs/ecl.pyx"]),
  
 -    Extension("sage.libs.fes",
 -             ["sage/libs/fes.pyx"],
 -             language = "c",
--             libraries = ['fes'],
--             package = 'fes'),
+-             libraries = ['fes']),
 +#    Extension("sage.libs.fes",
 +#             ["sage/libs/fes.pyx"],
 +#             language = "c",
-+#             libraries = ['fes'],
-+#             package = 'fes'),
++#             libraries = ['fes']),
  
      Extension('sage.libs.flint.flint',
                sources = ["sage/libs/flint/flint.pyx"],
diff --git a/sagemath-gap-hap.patch b/sagemath-gap-hap.patch
index 9eeed4f..08816e6 100644
--- a/sagemath-gap-hap.patch
+++ b/sagemath-gap-hap.patch
@@ -1,6 +1,6 @@
 diff -up src/sage/groups/perm_gps/permgroup.py.orig src/sage/groups/perm_gps/permgroup.py
---- src/sage/groups/perm_gps/permgroup.py.orig	2017-11-08 08:23:18.884207190 -0500
-+++ src/sage/groups/perm_gps/permgroup.py	2017-11-08 08:23:27.988207539 -0500
+--- src/sage/groups/perm_gps/permgroup.py.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/groups/perm_gps/permgroup.py	2018-05-16 13:38:07.049015293 -0600
 @@ -166,6 +166,10 @@ def load_hap():
          gap.load_package("hap")
      except Exception:
@@ -17,7 +17,7 @@ diff -up src/sage/groups/perm_gps/permgroup.py.orig src/sage/groups/perm_gps/per
      @wraps(f)
      def wrapped(self, n, p=0):
 -        if not is_package_installed('gap_packages'):
--            raise RuntimeError("You must install the optional gap_packages package.")
+-            raise PackageNotFoundError("gap_packages")
          load_hap()
          from sage.arith.all import is_prime
          if not (p == 0 or is_prime(p)):
diff --git a/sagemath-gcc6.patch b/sagemath-gcc6.patch
deleted file mode 100644
index 3258b5b..0000000
--- a/sagemath-gcc6.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up src/module_list.py.orig src/module_list.py
---- src/module_list.py.orig	2017-11-08 08:30:43.611224220 -0500
-+++ src/module_list.py	2017-11-08 08:30:51.131224508 -0500
-@@ -861,7 +861,7 @@ ext_modules = [
-               library_dirs = m4ri_library_dirs,
-               include_dirs = m4ri_include_dirs,
-               depends = [SAGE_INC + "/m4rie/m4rie.h"],
--              extra_compile_args = ['-std=c99'] + m4ri_extra_compile_args),
-+              extra_compile_args = ['-std=c++11'] + m4ri_extra_compile_args),
- 
-     Extension('sage.matrix.matrix_modn_dense_float',
-               sources = ['sage/matrix/matrix_modn_dense_float.pyx'],
diff --git a/sagemath-includes.patch b/sagemath-includes.patch
index 45ee224..ea0cc17 100644
--- a/sagemath-includes.patch
+++ b/sagemath-includes.patch
@@ -1,15 +1,32 @@
 diff -up src/module_list.py.orig src/module_list.py
---- src/module_list.py.orig	2017-11-08 08:30:03.588222687 -0500
-+++ src/module_list.py	2017-11-08 08:30:21.532223375 -0500
-@@ -62,6 +62,7 @@ linbox_cflags = pkgconfig.cflags('linbox
- # Singular
- singular_pc = pkgconfig.parse('Singular')
- singular_libs = singular_pc['libraries']
-+singular_incs = [SAGE_INC + '/singular', SAGE_INC + '/factory']
- singular_library_dirs = singular_pc['library_dirs']
- singular_cflags = pkgconfig.cflags('Singular').split()
+--- src/module_list.py.orig	2018-05-22 15:41:19.892745329 -0600
++++ src/module_list.py	2018-05-22 15:42:40.289863491 -0600
+@@ -45,6 +45,9 @@ zlib_libs = zlib_pc['libraries']
+ zlib_library_dirs = zlib_pc['library_dirs']
+ zlib_include_dirs = zlib_pc['include_dirs']
  
-@@ -185,7 +186,8 @@ ext_modules = [
++# Singular
++singular_incs = [SAGE_INC + '/singular', SAGE_INC + '/factory']
++
+ #########################################################
+ ### M4RI flags
+ #########################################################
+@@ -61,6 +64,14 @@ except ValueError:
+     pass
+ 
+ #########################################################
++### ARB flags
++#########################################################
++
++arb_include_dirs = [os.path.join(SAGE_INC, 'flint'),
++                    os.path.join(SAGE_INC, 'arb')]
++arb_libs = ['arb']
++
++#########################################################
+ ### Library order
+ #########################################################
+ 
+@@ -134,7 +145,8 @@ ext_modules = [
                 language='c++',
                 libraries = ["gmp", "m", "ntl"]),
  
@@ -17,9 +34,9 @@ diff -up src/module_list.py.orig src/module_list.py
 +    Extension('*', sources = ['sage/algebras/letterplace/*.pyx'],
 +              include_dirs = singular_incs),
  
-     Extension('sage.algebras.quatalg.quaternion_algebra_cython',
-                sources = ['sage/algebras/quatalg/quaternion_algebra_cython.pyx'],
-@@ -581,7 +583,8 @@ ext_modules = [
+     Extension('*', sources = ['sage/algebras/finite_dimensional_algebras/*.pyx']),
+ 
+@@ -519,7 +531,8 @@ ext_modules = [
                                                          [])),
  
      Extension('sage.libs.lrcalc.lrcalc',
@@ -27,9 +44,9 @@ diff -up src/module_list.py.orig src/module_list.py
 +              sources = ["sage/libs/lrcalc/lrcalc.pyx"],
 +              include_dirs = [os.path.join(SAGE_INC, 'lrcalc')]),
  
-     Extension('*', ['sage/libs/pari/*.pyx']),
- 
-@@ -598,7 +601,8 @@ ext_modules = [
+     OptionalExtension("sage.libs.meataxe",
+               sources = ['sage/libs/meataxe.pyx'],
+@@ -541,23 +554,28 @@ ext_modules = [
                sources = ['sage/libs/readline.pyx'],
                libraries = ['readline']),
  
@@ -39,18 +56,16 @@ diff -up src/module_list.py.orig src/module_list.py
  
      Extension('sage.libs.symmetrica.symmetrica',
                sources = ["sage/libs/symmetrica/symmetrica.pyx"],
-@@ -606,17 +610,21 @@ ext_modules = [
+               libraries = ["symmetrica"]),
  
      Extension('sage.libs.mpmath.utils',
-               sources = ["sage/libs/mpmath/utils.pyx"],
--              libraries = ['mpfr']),
-+              libraries = ['mpfr'],
+-              sources = ["sage/libs/mpmath/utils.pyx"]),
++              sources = ["sage/libs/mpmath/utils.pyx"],
 +              include_dirs = [os.path.join(SAGE_INC, "flint")]),
  
      Extension('sage.libs.mpmath.ext_impl',
-               sources = ["sage/libs/mpmath/ext_impl.pyx"],
--              libraries = ['mpfr']),
-+              libraries = ['mpfr'],
+-              sources = ["sage/libs/mpmath/ext_impl.pyx"]),
++              sources = ["sage/libs/mpmath/ext_impl.pyx"],
 +              include_dirs = [os.path.join(SAGE_INC, "flint")]),
  
      Extension('sage.libs.mpmath.ext_main',
@@ -65,25 +80,35 @@ diff -up src/module_list.py.orig src/module_list.py
  
      ###################################
      ##
-@@ -624,7 +632,8 @@ ext_modules = [
+@@ -565,7 +583,8 @@ ext_modules = [
      ##
      ###################################
  
 -    Extension('*', ["sage/libs/arb/*.pyx"]),
 +    Extension('*', ["sage/libs/arb/*.pyx"],
-+              include_dirs = [SAGE_INC + '/flint', SAGE_INC + '/arb']),
++              include_dirs = arb_include_dirs),
  
      ###################################
      ##
-@@ -805,6 +814,7 @@ ext_modules = [
+@@ -745,7 +764,8 @@ ext_modules = [
+ 
      Extension("sage.matrix.matrix_complex_ball_dense",
                ["sage/matrix/matrix_complex_ball_dense.pyx"],
-               libraries=['arb', 'mpfi', 'mpfr'],
-+              include_dirs=[SAGE_INC + '/flint', SAGE_INC + '/arb'],
-               language = "c++"),
+-              libraries=['arb']),
++              include_dirs = arb_include_dirs,
++              libraries=arb_libs),
  
      Extension('sage.matrix.matrix_complex_double_dense',
-@@ -872,6 +882,7 @@ ext_modules = [
+               sources = ['sage/matrix/matrix_complex_double_dense.pyx']),
+@@ -753,6 +773,7 @@ ext_modules = [
+     Extension('sage.matrix.matrix_cyclo_dense',
+               sources = ['sage/matrix/matrix_cyclo_dense.pyx'],
+               language = "c++",
++              include_dirs = arb_include_dirs,
+               libraries=['ntl']),
+ 
+     Extension('sage.matrix.matrix_gap',
+@@ -815,6 +836,7 @@ ext_modules = [
                sources = ['sage/matrix/matrix_modn_sparse.pyx']),
  
      Extension('sage.matrix.matrix_mpolynomial_dense',
@@ -91,23 +116,35 @@ diff -up src/module_list.py.orig src/module_list.py
                sources = ['sage/matrix/matrix_mpolynomial_dense.pyx']),
  
      Extension('sage.matrix.matrix_polynomial_dense',
-@@ -1201,6 +1212,7 @@ ext_modules = [
-     Extension("sage.rings.complex_arb",
-               ["sage/rings/complex_arb.pyx"],
-               libraries=['mpfi', 'mpfr', 'gmp'],
-+              include_dirs=[SAGE_INC + '/flint', SAGE_INC + '/arb'],
+@@ -1112,7 +1134,8 @@ ext_modules = [
                language = 'c++'),
  
+     Extension("sage.rings.complex_arb",
+-              ["sage/rings/complex_arb.pyx"]),
++              ["sage/rings/complex_arb.pyx"],
++              include_dirs = arb_include_dirs),
+ 
      Extension('sage.rings.complex_double',
-@@ -1276,6 +1288,7 @@ ext_modules = [
+               sources = ['sage/rings/complex_double.pyx'],
+@@ -1182,7 +1205,8 @@ ext_modules = [
+               sources = ['sage/rings/real_interval_absolute.pyx']),
+ 
      Extension("sage.rings.real_arb",
-               ["sage/rings/real_arb.pyx"],
-               libraries = ['mpfi', 'mpfr'],
-+              include_dirs=[SAGE_INC + '/flint', SAGE_INC + '/arb'],
-               language = 'c++'),
+-              ["sage/rings/real_arb.pyx"]),
++              ["sage/rings/real_arb.pyx"],
++              include_dirs = arb_include_dirs),
  
      Extension('sage.rings.real_lazy',
-@@ -1481,12 +1494,15 @@ ext_modules = [
+               sources = ['sage/rings/real_lazy.pyx']),
+@@ -1265,6 +1289,7 @@ ext_modules = [
+ 
+     Extension('sage.rings.number_field.number_field_element_quadratic',
+               sources = ['sage/rings/number_field/number_field_element_quadratic.pyx'],
++              include_dirs = arb_include_dirs,
+               libraries=['ntl'],
+               language = 'c++'),
+ 
+@@ -1387,12 +1412,15 @@ ext_modules = [
                sources = ['sage/rings/polynomial/multi_polynomial.pyx']),
  
      Extension('sage.rings.polynomial.multi_polynomial_ideal_libsingular',
@@ -123,20 +160,22 @@ diff -up src/module_list.py.orig src/module_list.py
                sources = ['sage/rings/polynomial/multi_polynomial_libsingular.pyx']),
  
      Extension('sage.rings.polynomial.multi_polynomial_ring_generic',
-@@ -1500,6 +1516,7 @@ ext_modules = [
+@@ -1405,7 +1433,8 @@ ext_modules = [
+               sources = ['sage/rings/polynomial/polydict.pyx']),
  
      Extension('sage.rings.polynomial.polynomial_complex_arb',
-                sources = ['sage/rings/polynomial/polynomial_complex_arb.pyx'],
-+               include_dirs=[SAGE_INC + '/flint', SAGE_INC + '/arb'],
-                language="c++"),
+-               sources = ['sage/rings/polynomial/polynomial_complex_arb.pyx']),
++               sources = ['sage/rings/polynomial/polynomial_complex_arb.pyx'],
++               include_dirs = arb_include_dirs),
  
      Extension('sage.rings.polynomial.polynomial_compiled',
+                sources = ['sage/rings/polynomial/polynomial_compiled.pyx']),
 diff -up src/setup.py.orig src/setup.py
---- src/setup.py.orig	2017-11-08 08:30:03.589222688 -0500
-+++ src/setup.py	2017-11-08 08:30:21.533223375 -0500
-@@ -89,6 +89,7 @@ except KeyError:
+--- src/setup.py.orig	2018-05-22 15:41:19.893745318 -0600
++++ src/setup.py	2018-05-22 15:41:27.805658536 -0600
+@@ -85,6 +85,7 @@ except KeyError:
+ 
  # search for dependencies and add to gcc -I<path>
- # this depends on SAGE_CYTHONIZED
  include_dirs = sage_include_directories(use_sources=True)
 +include_dirs.extend(['@@CYSIGNALS@@'])
  
diff --git a/sagemath-jmol.patch b/sagemath-jmol.patch
index a15281a..41efb18 100644
--- a/sagemath-jmol.patch
+++ b/sagemath-jmol.patch
@@ -1,7 +1,7 @@
 diff -up src/sage/interfaces/jmoldata.py.orig src/sage/interfaces/jmoldata.py
---- src/sage/interfaces/jmoldata.py.orig	2016-08-08 13:34:51.199532656 -0400
-+++ src/sage/interfaces/jmoldata.py	2016-08-08 13:36:16.474535921 -0400
-@@ -147,8 +147,6 @@ class JmolData(SageObject):
+--- src/sage/interfaces/jmoldata.py.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/interfaces/jmoldata.py	2018-05-16 13:30:58.803927423 -0600
+@@ -148,8 +148,6 @@ class JmolData(SageObject):
              sage: print(os.path.exists(testfile)) # optional -- java
              True
          """
@@ -10,16 +10,16 @@ diff -up src/sage/interfaces/jmoldata.py.orig src/sage/interfaces/jmoldata.py
          target_native = targetfile
          import sys
          if sys.platform == 'cygwin':
-@@ -173,10 +171,8 @@ class JmolData(SageObject):
+@@ -174,10 +172,8 @@ class JmolData(SageObject):
              env = dict(os.environ)
              env['LC_ALL'] = 'C'
              env['LANG'] = 'C'
 -            subprocess.call(["java", "-Xmx512m", "-Djava.awt.headless=true",
--                "-jar", jmolpath, "-iox", "-g", sizeStr,
+-                "-jar", jmolpath, "-iox", "-g", size_arg,
 -                "-J", launchscript, "-j", imagescript],
 -                stdout=jout, stderr=jout, env=env)
-+            subprocess.call(["jmol", "-n", "-g", sizeStr,
-+                "-J",launchscript, "-j", imagescript], stdout=jout)
++            subprocess.call(["jmol", "-n", "-g", size_arg,
++                "-J", launchscript, "-j", imagescript], stdout=jout)
          if not os.path.isfile(targetfile):
              raise RuntimeError("Jmol failed to create file %s, see %s for details"%(repr(targetfile), repr(scratchout)))
          os.unlink(scratchout)
diff --git a/sagemath-lcalc.patch b/sagemath-lcalc.patch
index 337c952..fb52eec 100644
--- a/sagemath-lcalc.patch
+++ b/sagemath-lcalc.patch
@@ -1,6 +1,17 @@
+diff -up src/sage/libs/lcalc/lcalc_Lfunction.pxd.orig src/sage/libs/lcalc/lcalc_Lfunction.pxd
+--- src/sage/libs/lcalc/lcalc_Lfunction.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/lcalc/lcalc_Lfunction.pxd	2018-05-22 13:31:10.717337490 -0600
+@@ -1,6 +1,6 @@
+ # Lcalc requires GNU extensions, it does not strictly conform to any
+ # C++ standard: https://trac.sagemath.org/ticket/23341
+-# distutils: extra_compile_args = -std=gnu++98
++# distutils: extra_compile_args = -std=gnu++11
+ 
+ cdef extern from "lcalc_sage.h":
+     ctypedef struct doublevec "std::vector<double>":
 diff -up src/sage/libs/lcalc/lcalc_sage.h.orig src/sage/libs/lcalc/lcalc_sage.h
---- src/sage/libs/lcalc/lcalc_sage.h.orig	2016-08-08 13:40:43.480546146 -0400
-+++ src/sage/libs/lcalc/lcalc_sage.h	2016-08-08 13:40:49.561546379 -0400
+--- src/sage/libs/lcalc/lcalc_sage.h.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/lcalc/lcalc_sage.h	2018-05-22 13:30:32.012839737 -0600
 @@ -1,4 +1,4 @@
 -#include "libLfunction/L.h"
 +#include "Lfunction/L.h"
diff --git a/sagemath-lrslib.patch b/sagemath-lrslib.patch
index b33f938..8212b43 100644
--- a/sagemath-lrslib.patch
+++ b/sagemath-lrslib.patch
@@ -1,21 +1,12 @@
 diff -up src/sage/geometry/polyhedron/base.py.orig src/sage/geometry/polyhedron/base.py
---- src/sage/geometry/polyhedron/base.py.orig	2017-11-08 08:21:45.693203621 -0500
-+++ src/sage/geometry/polyhedron/base.py	2017-11-08 08:21:56.893204050 -0500
-@@ -22,7 +22,6 @@ from sage.structure.element import Eleme
- from sage.structure.richcmp import rich_to_bool, op_NE
- 
- from sage.misc.all import cached_method, prod
--from sage.misc.package import is_package_installed
- 
- from sage.rings.all import QQ, ZZ, AA
- from sage.rings.real_double import RDF
-@@ -4188,10 +4187,6 @@ class Polyhedron_base(Element):
+--- src/sage/geometry/polyhedron/base.py.orig	2018-05-16 13:31:55.930138769 -0600
++++ src/sage/geometry/polyhedron/base.py	2018-05-16 13:35:12.219428900 -0600
+@@ -4281,9 +4281,6 @@ class Polyhedron_base(Element):
  
               David Avis's lrs program.
          """
 -        if not is_package_installed('lrslib'):
--            raise NotImplementedError('You must install the optional lrslib package '
--                                       'for this function to work')
+-            raise PackageNotFoundError('lrslib')
 -
          from sage.misc.temporary_file import tmp_filename
          from subprocess import Popen, PIPE
diff --git a/sagemath-maxima.patch b/sagemath-maxima.patch
index 105e540..94e9d9c 100644
--- a/sagemath-maxima.patch
+++ b/sagemath-maxima.patch
@@ -1,6 +1,6 @@
 diff -up src/bin/sage-maxima.lisp.orig src/bin/sage-maxima.lisp
---- src/bin/sage-maxima.lisp.orig	2017-11-08 08:16:44.346192082 -0500
-+++ src/bin/sage-maxima.lisp	2017-11-08 08:16:54.098192455 -0500
+--- src/bin/sage-maxima.lisp.orig	2018-05-05 16:21:22.000000000 -0600
++++ src/bin/sage-maxima.lisp	2018-05-16 13:25:51.499101380 -0600
 @@ -4,3 +4,8 @@
  
  (setf *prompt-prefix* "<sage-display>")
@@ -11,18 +11,18 @@ diff -up src/bin/sage-maxima.lisp.orig src/bin/sage-maxima.lisp
 +  *standard-input* (open "/dev/stdin" :direction :input)
 +  *standard-output* (open "/dev/stdout" :direction :output))
 diff -up src/sage/interfaces/maxima.py.orig src/sage/interfaces/maxima.py
---- src/sage/interfaces/maxima.py.orig	2017-11-08 08:16:38.516191858 -0500
-+++ src/sage/interfaces/maxima.py	2017-11-08 08:16:54.099192455 -0500
-@@ -555,7 +555,7 @@ class Maxima(MaximaAbstract, Expect):
+--- src/sage/interfaces/maxima.py.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/interfaces/maxima.py	2018-05-16 13:27:01.240157806 -0600
+@@ -556,7 +556,7 @@ class Maxima(MaximaAbstract, Expect):
          Expect.__init__(self,
                          name = 'maxima',
                          prompt = '\(\%i[0-9]+\) ',
 -                        command = 'maxima --userdir="%s" -p "%s"'%(SAGE_MAXIMA_DIR,STARTUP),
-+                        command = 'maxima --disable-readline --userdir="%s" -p "%s"'%(SAGE_MAXIMA_DIR,STARTUP), 
++                        command = 'maxima --disable-readline --userdir="%s" -p "%s"'%(SAGE_MAXIMA_DIR,STARTUP),
+                         env = {'TMPDIR': str(ECL_TMP)},
                          script_subdirectory = script_subdirectory,
                          restart_on_ctrlc = False,
-                         verbose_start = False,
-@@ -622,7 +622,8 @@ class Maxima(MaximaAbstract, Expect):
+@@ -624,7 +624,8 @@ class Maxima(MaximaAbstract, Expect):
  
          # Remove limit on the max heapsize (since otherwise it defaults
          # to 256MB with ECL).
diff --git a/sagemath-mpfr.patch b/sagemath-mpfr.patch
new file mode 100644
index 0000000..0e54f02
--- /dev/null
+++ b/sagemath-mpfr.patch
@@ -0,0 +1,47 @@
+diff -up src/sage/libs/mpfr/__init__.pxd.orig src/sage/libs/mpfr/__init__.pxd
+--- src/sage/libs/mpfr/__init__.pxd.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/libs/mpfr/__init__.pxd	2018-05-25 15:01:25.576043678 -0600
+@@ -96,7 +96,6 @@ cdef extern from "mpfr.h":
+     int mpfr_sqrt(mpfr_t rop, mpfr_t op, mpfr_rnd_t rnd)
+     int mpfr_sqrt_ui(mpfr_t rop, unsigned long int op, mpfr_rnd_t rnd)
+     int mpfr_cbrt(mpfr_t rop, mpfr_t op, mpfr_rnd_t rnd)
+-    int mpfr_rootn_ui(mpfr_t rop, mpfr_t op, unsigned long int k, mpfr_rnd_t rnd)
+     int mpfr_root(mpfr_t rop, mpfr_t op, unsigned long int k, mpfr_rnd_t rnd)
+     int mpfr_pow(mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd)
+     int mpfr_pow_ui(mpfr_t rop, mpfr_t op1, unsigned long int op2, mpfr_rnd_t rnd)
+diff -up src/sage/rings/complex_mpc.pyx.orig src/sage/rings/complex_mpc.pyx
+--- src/sage/rings/complex_mpc.pyx.orig	2018-05-05 16:21:25.000000000 -0600
++++ src/sage/rings/complex_mpc.pyx	2018-05-25 15:02:11.567712409 -0600
+@@ -2221,7 +2221,7 @@ cdef class MPComplexNumber(sage.structur
+         cdef RealNumber a,r
+         a = self.argument()/n
+         r = self.abs()
+-        mpfr_rootn_ui(r.value, r.value, n, rrnd)
++        mpfr_root(r.value, r.value, n, rrnd)
+ 
+         cdef MPComplexNumber z
+         z = self._new()
+diff -up src/sage/rings/complex_number.pyx.orig src/sage/rings/complex_number.pyx
+--- src/sage/rings/complex_number.pyx.orig	2018-05-05 16:21:25.000000000 -0600
++++ src/sage/rings/complex_number.pyx	2018-05-25 15:01:52.328850983 -0600
+@@ -2276,7 +2276,7 @@ cdef class ComplexNumber(sage.structure.
+         rho = abs(self)
+         arg = self.argument() / n
+         mpfr_init2(r, self._prec)
+-        mpfr_rootn_ui(r, rho.value, n, rnd)
++        mpfr_root(r, rho.value, n, rnd)
+ 
+         mpfr_sin_cos(z.__im, z.__re, arg.value, rnd)
+         mpfr_mul(z.__re, z.__re, r, rnd)
+diff -up src/sage/rings/real_mpfr.pyx.orig src/sage/rings/real_mpfr.pyx
+--- src/sage/rings/real_mpfr.pyx.orig	2018-05-05 16:21:26.000000000 -0600
++++ src/sage/rings/real_mpfr.pyx	2018-05-25 11:33:48.009144647 -0600
+@@ -5369,7 +5369,7 @@ cdef class RealNumber(sage.structure.ele
+         if algorithm == 1:
+             x = self._new()
+             sig_on()
+-            mpfr_rootn_ui(x.value, self.value, n, (<RealField_class>self._parent).rnd)
++            mpfr_root(x.value, self.value, n, (<RealField_class>self._parent).rnd)
+             sig_off()
+             return x
+ 
diff --git a/sagemath-nauty.patch b/sagemath-nauty.patch
index bdb77d6..5173c5b 100644
--- a/sagemath-nauty.patch
+++ b/sagemath-nauty.patch
@@ -1,7 +1,7 @@
 diff -up src/sage/graphs/graph_generators.py.orig src/sage/graphs/graph_generators.py
---- src/sage/graphs/graph_generators.py.orig	2017-11-08 08:22:46.174205937 -0500
-+++ src/sage/graphs/graph_generators.py	2017-11-08 08:22:54.470206255 -0500
-@@ -882,7 +882,7 @@ class GraphGenerators():
+--- src/sage/graphs/graph_generators.py.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/graphs/graph_generators.py	2018-05-16 13:35:59.299778933 -0600
+@@ -886,7 +886,7 @@ class GraphGenerators():
              >A geng -d0D3 n=4 e=0-6
          """
          import subprocess
diff --git a/sagemath-nofstring.patch b/sagemath-nofstring.patch
index 8e24b59..9008492 100644
--- a/sagemath-nofstring.patch
+++ b/sagemath-nofstring.patch
@@ -1,60 +1,60 @@
 diff -up src/sage/arith/multi_modular.pyx.orig src/sage/arith/multi_modular.pyx
---- src/sage/arith/multi_modular.pyx.orig	2017-11-08 08:29:36.259221641 -0500
-+++ src/sage/arith/multi_modular.pyx	2017-11-08 08:29:38.843221740 -0500
-@@ -172,9 +172,9 @@ cdef class MultiModularBasis_base(object
+--- src/sage/arith/multi_modular.pyx.orig	2018-05-05 16:21:22.000000000 -0600
++++ src/sage/arith/multi_modular.pyx	2018-05-18 09:39:53.247690061 -0600
+@@ -173,9 +173,9 @@ cdef class MultiModularBasis_base(object
              ArithmeticError: The inverse of 6 modulo 10 is not defined.
          """
          if l_bound < 2:
 -            raise ValueError(f"minimum value for lower bound is 2, given: {l_bound}")
-+            raise ValueError("minimum value for lower bound is 2, given: {l_bound}")
++            raise ValueError("minimum value for lower bound is 2, given: {l_bound}".format(l_bound=l_bound))
          if u_bound > MAX_MODULUS:
 -            raise ValueError(f"upper bound cannot be greater than {MAX_MODULUS}, given: {u_bound}")
-+            raise ValueError("upper bound cannot be greater than {MAX_MODULUS}, given: {u_bound}")
++            raise ValueError("upper bound cannot be greater than {MAX_MODULUS}, given: {u_bound}".format(MAX_MODULUS=MAX_MODULUS, u_bound=u_bound))
  
          self._l_bound = l_bound
          self._u_bound = u_bound
-@@ -233,7 +233,7 @@ cdef class MultiModularBasis_base(object
+@@ -234,7 +234,7 @@ cdef class MultiModularBasis_base(object
          if check:
              for p in plist:
                  if p > MAX_MODULUS:
 -                    raise OverflowError(f"given modulus {p} is larger than {MAX_MODULUS}")
-+                    raise OverflowError("given modulus {p} is larger than {MAX_MODULUS}")
++                    raise OverflowError("given modulus {p} is larger than {MAX_MODULUS}".format(p=p, MAX_MODULUS=MAX_MODULUS))
          self._realloc_to_new_count(self.n + len_plist)
  
          cdef Py_ssize_t i
 diff -up src/sage/rings/finite_rings/integer_mod.pyx.orig src/sage/rings/finite_rings/integer_mod.pyx
---- src/sage/rings/finite_rings/integer_mod.pyx.orig	2017-11-08 08:29:14.256220798 -0500
-+++ src/sage/rings/finite_rings/integer_mod.pyx	2017-11-08 08:29:38.845221740 -0500
-@@ -391,7 +391,7 @@ cdef class IntegerMod_abstract(FiniteRin
-         from integer_mod_ring import IntegerModRing
+--- src/sage/rings/finite_rings/integer_mod.pyx.orig	2018-05-05 16:21:25.000000000 -0600
++++ src/sage/rings/finite_rings/integer_mod.pyx	2018-05-18 09:41:48.412094505 -0600
+@@ -457,7 +457,7 @@ cdef class IntegerMod_abstract(FiniteRin
+         from .integer_mod_ring import IntegerModRing
          R = IntegerModRing(modulus)
          if (<Element>self)._parent._IntegerModRing_generic__order % R.order():
 -            raise ArithmeticError(f"reduction modulo {modulus!r} not defined")
-+            raise ArithmeticError("reduction modulo {modulus!r} not defined")
++            raise ArithmeticError("reduction modulo {modulus} not defined".format(modulus=repr(modulus)))
          return R(self)
  
      def is_nilpotent(self):
 diff -up src/sage/structure/parent.pyx.orig src/sage/structure/parent.pyx
---- src/sage/structure/parent.pyx.orig	2017-11-08 08:29:14.260220799 -0500
-+++ src/sage/structure/parent.pyx	2017-11-08 08:29:38.846221740 -0500
-@@ -714,7 +714,7 @@ cdef class Parent(sage.structure.categor
+--- src/sage/structure/parent.pyx.orig	2018-05-05 16:21:26.000000000 -0600
++++ src/sage/structure/parent.pyx	2018-05-18 09:42:38.685397989 -0600
+@@ -726,7 +726,7 @@ cdef class Parent(sage.structure.categor
      cdef int init_coerce(self, bint warn=True) except -1:
          if self._coerce_from_hash is None:
              if warn:
 -                raise AssertionError(f"unexpected call of init_coerce() for {type(self)}")
-+                raise AssertionError("unexpected call of init_coerce() for {type(self)}")
++                raise AssertionError("unexpected call of init_coerce() for {typ}".format(typ=type(self)))
              self._initial_coerce_list = []
              self._initial_action_list = []
              self._initial_convert_list = []
 diff -up src/sage/symbolic/ring.pyx.orig src/sage/symbolic/ring.pyx
---- src/sage/symbolic/ring.pyx.orig	2017-11-08 08:29:14.264220799 -0500
-+++ src/sage/symbolic/ring.pyx	2017-11-08 08:29:38.847221740 -0500
-@@ -376,7 +376,7 @@ cdef class SymbolicRing(CommutativeRing)
+--- src/sage/symbolic/ring.pyx.orig	2018-05-05 16:21:26.000000000 -0600
++++ src/sage/symbolic/ring.pyx	2018-05-18 09:43:07.395000229 -0600
+@@ -378,7 +378,7 @@ cdef class SymbolicRing(CommutativeRing)
              from sage.misc.all import prod
              return prod([SR(p)**e for p,e in x], SR(x.unit()))
          else:
 -            raise TypeError(f"unable to convert {x!r} to a symbolic expression")
-+            raise TypeError("unable to convert {x!r} to a symbolic expression")
++            raise TypeError("unable to convert {x} to a symbolic expression".format(x=repr(x)))
  
          return new_Expression_from_GEx(self, exp)
  
diff --git a/sagemath-ntl.patch b/sagemath-ntl.patch
deleted file mode 100644
index cc8e36f..0000000
--- a/sagemath-ntl.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-diff -up src/sage/libs/polybori/decl.pxd.orig src/sage/libs/polybori/decl.pxd
---- src/sage/libs/polybori/decl.pxd.orig	2017-03-04 13:33:54.155492361 -0500
-+++ src/sage/libs/polybori/decl.pxd	2017-03-04 13:34:09.926492965 -0500
-@@ -291,10 +291,10 @@ cdef extern from "sage/libs/polybori/pb_
-         int (* size)()
-         PBPolyEntry (* get "operator[]")(int)
- 
--    ctypedef struct PBFglmStrategy "PBWrappedPtr<FGLMStrategy>":
-+    ctypedef struct PBFglmStrategy "WrappedPointer<FGLMStrategy>":
-         PBPolyVector (* main "operator->()->main")()
- 
--    PBFglmStrategy PBFglmStrategy_Constructor "PBWrappedPtr<FGLMStrategy>" \
-+    PBFglmStrategy PBFglmStrategy_Constructor "WrappedPointer<FGLMStrategy>" \
-         (PBRing from_ring, PBRing to_ring, PBPolyVector vec)
- 
-     cdef cppclass PBGBStrategy "GroebnerStrategy":
-diff -up src/sage/libs/polybori/pb_wrap.h.orig src/sage/libs/polybori/pb_wrap.h
---- src/sage/libs/polybori/pb_wrap.h.orig	2017-03-04 13:34:07.773492882 -0500
-+++ src/sage/libs/polybori/pb_wrap.h	2017-03-04 13:34:09.928492965 -0500
-@@ -177,23 +177,23 @@ PyObject* preallocated_to_PyString(const
- 
- 
- template <class Type>
--class PBWrappedPtr:
-+class WrappedPointer:
-   public boost::shared_ptr<Type> {
--    typedef PBWrappedPtr self;
-+    typedef WrappedPointer self;
-     typedef boost::shared_ptr<Type> base;
- 
-  public:
--    PBWrappedPtr(): base() {}
--    PBWrappedPtr(const self& rhs): base(rhs) {}
-+    WrappedPointer(): base() {}
-+    WrappedPointer(const self& rhs): base(rhs) {}
- 
-     template <class T1>
--    PBWrappedPtr(const T1& arg): base(new Type(arg)) {}
-+    WrappedPointer(const T1& arg): base(new Type(arg)) {}
- 
-     template <class T1, class T2>
--    PBWrappedPtr(const T1& arg1, const T2& arg2): base(new Type(arg1, arg2)) {}
-+    WrappedPointer(const T1& arg1, const T2& arg2): base(new Type(arg1, arg2)) {}
- 
-       template <class T1, class T2, class T3>
--        PBWrappedPtr(const T1& arg1, const T2& arg2, const T3& arg3):
-+        WrappedPointer(const T1& arg1, const T2& arg2, const T3& arg3):
-         base(new Type(arg1, arg2, arg3)) {}
- 
-     operator Type&() { return base::operator*();}
diff --git a/sagemath-qepcad.patch b/sagemath-qepcad.patch
index 0c71de0..527415b 100644
--- a/sagemath-qepcad.patch
+++ b/sagemath-qepcad.patch
@@ -1,18 +1,16 @@
 diff -up src/sage/interfaces/qepcad.py.orig src/sage/interfaces/qepcad.py
---- src/sage/interfaces/qepcad.py.orig	2017-11-08 08:28:33.908219253 -0500
-+++ src/sage/interfaces/qepcad.py	2017-11-08 08:28:43.336219614 -0500
-@@ -530,8 +530,8 @@ TESTS:
+--- src/sage/interfaces/qepcad.py.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/interfaces/qepcad.py	2018-05-16 13:58:34.360913275 -0600
+@@ -530,7 +530,7 @@ TESTS:
  
  Check the qepcad configuration file::
  
--    sage: open('%s/default.qepcadrc'%SAGE_LOCAL).readlines()[-1]
--    'SINGULAR .../bin\n'
-+    sage: open('/usr/share/qepcad/default.qepcadrc').readlines()[-1]
-+    'SINGULAR /usr/bin\n'
+-    sage: with open(os.path.join(SAGE_LOCAL, 'default.qepcadrc')) as f:
++    sage: with open('/usr/share/qepcad/default.qepcadrc')) as f:
+     ....:     f.readlines()[-1]
+     'SINGULAR .../bin\n'
  
- Tests related to the not tested examples (nondeterministic order of atoms)::
- 
-@@ -607,7 +607,6 @@ from __future__ import print_function
+@@ -608,7 +608,6 @@ from __future__ import print_function
  from __future__ import absolute_import
  from six import string_types
  
@@ -20,7 +18,7 @@ diff -up src/sage/interfaces/qepcad.py.orig src/sage/interfaces/qepcad.py
  import pexpect
  import re
  import sys
-@@ -620,6 +619,8 @@ from sage.docs.instancedoc import instan
+@@ -621,6 +620,8 @@ from sage.docs.instancedoc import instan
  from .expect import Expect, ExpectFunction, AsciiArtString
  
  
@@ -29,7 +27,7 @@ diff -up src/sage/interfaces/qepcad.py.orig src/sage/interfaces/qepcad.py
  def _qepcad_atoms(formula):
      r"""
      Return the atoms of a qepcad quantifier-free formula, as a set of strings.
-@@ -649,17 +650,17 @@ def _qepcad_cmd(memcells=None):
+@@ -650,17 +651,17 @@ def _qepcad_cmd(memcells=None):
  
          sage: from sage.interfaces.qepcad import _qepcad_cmd
          sage: s = _qepcad_cmd()
@@ -50,7 +48,7 @@ diff -up src/sage/interfaces/qepcad.py.orig src/sage/interfaces/qepcad.py
  
  _command_info_cache = None
  
-@@ -684,7 +685,7 @@ def _update_command_info():
+@@ -685,7 +686,7 @@ def _update_command_info():
  
      cache = {}
  
diff --git a/sagemath-readonly.patch b/sagemath-readonly.patch
index a0a2473..0c959b9 100644
--- a/sagemath-readonly.patch
+++ b/sagemath-readonly.patch
@@ -1,7 +1,6 @@
-diff -up src/sage/all.py.orig src/sage/all.py
---- src/sage/all.py.orig	2017-11-08 08:16:05.331190588 -0500
-+++ src/sage/all.py	2017-11-08 08:16:14.195190927 -0500
-@@ -295,11 +295,11 @@ def _write_started_file():
+--- src/sage/all.py.orig	2018-05-05 16:21:22.000000000 -0600
++++ src/sage/all.py	2018-05-16 13:25:28.300415250 -0600
+@@ -290,11 +290,11 @@ def _write_started_file():
  
      Check that the file exists when Sage is running::
  
diff --git a/sagemath-rpmbuild.patch b/sagemath-rpmbuild.patch
index c8faa8a..b8bd336 100644
--- a/sagemath-rpmbuild.patch
+++ b/sagemath-rpmbuild.patch
@@ -1,6 +1,6 @@
 diff -up src/module_list.py.orig src/module_list.py
---- src/module_list.py.orig	2017-11-08 06:16:18.175915367 -0500
-+++ src/module_list.py	2017-11-08 06:16:29.412915797 -0500
+--- src/module_list.py.orig	2018-05-16 12:35:55.223524926 -0600
++++ src/module_list.py	2018-05-16 13:13:20.467262594 -0600
 @@ -3,7 +3,7 @@ from glob import glob
  from distutils.extension import Extension
  from sage.env import SAGE_LOCAL
@@ -11,33 +11,33 @@ diff -up src/module_list.py.orig src/module_list.py
  #########################################################
  ### pkg-config setup
 diff -up src/sage/misc/cython.py.orig src/sage/misc/cython.py
---- src/sage/misc/cython.py.orig	2017-11-08 06:16:39.095916168 -0500
-+++ src/sage/misc/cython.py	2017-11-08 06:17:35.580918331 -0500
-@@ -497,7 +497,7 @@ extra_compile_args = %s
- 
- ext_modules = [Extension('%s', sources=['%s.%s', %s],
-                      libraries=%s,
--                     library_dirs=[SAGE_LOCAL + '/lib/'] + %s,
-+                     library_dirs=[os.path.realpath(SAGE_LOCAL + '/lib/')] + %s,
-                      extra_compile_args = extra_compile_args,
-                      language = '%s' )]
+--- src/sage/misc/cython.py.orig	2018-05-16 13:13:20.468262581 -0600
++++ src/sage/misc/cython.py	2018-05-16 13:16:29.207708998 -0600
+@@ -601,7 +601,7 @@ def cython(filename, verbose=0, compile_
+     ext = Extension(name,
+                     sources=[pyxfile] + extra_sources,
+                     libraries=libs,
+-                    library_dirs=[os.path.join(SAGE_LOCAL, "lib")] + libdirs,
++                    library_dirs=[os.path.realpath(os.path.join(SAGE_LOCAL, "lib"))] + libdirs,
+                     extra_compile_args=extra_args,
+                     language=language)
  
 diff -up src/setup.py.orig src/setup.py
---- src/setup.py.orig	2017-11-08 06:17:50.231918892 -0500
-+++ src/setup.py	2017-11-08 06:18:48.924921139 -0500
-@@ -422,9 +422,8 @@ class sage_build_cython(Command):
+--- src/setup.py.orig	2018-05-05 16:21:27.000000000 -0600
++++ src/setup.py	2018-05-16 13:17:40.774740719 -0600
+@@ -370,9 +370,8 @@ class sage_build_cython(Command):
              # Debugging
              gdb_debug=self.debug,
-             output_dir=self.build_dir,
+             output_dir=os.path.join(self.build_lib, "sage"),
 -            # Disable Cython caching, which is currently too broken to
 -            # use reliably: http://trac.sagemath.org/ticket/17851
 -            cache=False,
-+            # Enable Cython caching (the cache is stored in ~/.cycache which is
++            # Enable Cython caching (the cache is stored in ~/.cycache)
 +            cache=True,
              )
  
-         log.info("Finished Cythonizing, time: %.2f seconds." % (time.time() - t))
-@@ -850,9 +849,6 @@ class sage_install(install):
+         # Filter out extensions with skip_build=True
+@@ -881,9 +880,6 @@ class sage_install(install):
          install.run(self)
          self.install_kernel_spec()
          log.info('Cleaning up stale installed files....')
@@ -47,7 +47,7 @@ diff -up src/setup.py.orig src/setup.py
  
      def install_kernel_spec(self):
          """
-@@ -866,40 +862,6 @@ class sage_install(install):
+@@ -897,40 +893,6 @@ class sage_install(install):
          from sage.repl.ipython_kernel.install import SageKernelSpec
          SageKernelSpec.update()
  
diff --git a/sagemath-sagedoc.patch b/sagemath-sagedoc.patch
index 13ec5d7..21da4ff 100644
--- a/sagemath-sagedoc.patch
+++ b/sagemath-sagedoc.patch
@@ -1,19 +1,7 @@
-diff -up src/doc/common/conf.py.orig src/doc/common/conf.py
---- src/doc/common/conf.py.orig	2017-11-08 08:08:07.554172292 -0500
-+++ src/doc/common/conf.py	2017-11-08 08:08:33.656173291 -0500
-@@ -220,7 +220,7 @@ if (os.environ.get('SAGE_DOC_MATHJAX', '
-     html_theme_options['mathjax_macros'] = sage_mathjax_macros()
- 
-     from pkg_resources import Requirement, working_set
--    sagenb_path = working_set.find(Requirement.parse('sagenb')).location
-+    sagenb_path = SAGE_SRC
-     mathjax_relative = os.path.join('sagenb','data','mathjax')
- 
-     # It would be really nice if sphinx would copy the entire mathjax directory,
 diff -up src/sage/doctest/control.py.orig src/sage/doctest/control.py
---- src/sage/doctest/control.py.orig	2017-11-08 08:08:44.186173695 -0500
-+++ src/sage/doctest/control.py	2017-11-08 08:09:24.904175254 -0500
-@@ -96,7 +96,6 @@ class DocTestDefaults(SageObject):
+--- src/sage/doctest/control.py.orig	2018-05-05 16:21:23.000000000 -0600
++++ src/sage/doctest/control.py	2018-05-16 13:20:01.420837824 -0600
+@@ -102,7 +102,6 @@ class DocTestDefaults(SageObject):
          self.valgrind = False
          self.massif = False
          self.cachegrind = False
@@ -21,7 +9,7 @@ diff -up src/sage/doctest/control.py.orig src/sage/doctest/control.py
          self.failed = False
          self.new = False
          self.show_skipped = False
-@@ -285,7 +284,7 @@ class DocTestController(SageObject):
+@@ -292,7 +291,7 @@ class DocTestController(SageObject):
              if options.gdb or options.debug:
                  # Interactive debuggers: "infinite" timeout
                  options.timeout = 0
@@ -30,7 +18,7 @@ diff -up src/sage/doctest/control.py.orig src/sage/doctest/control.py
                  # Non-interactive debuggers: 48 hours
                  options.timeout = int(os.getenv('SAGE_TIMEOUT_VALGRIND', 48 * 60 * 60))
              elif options.long:
-@@ -1049,13 +1048,8 @@ class DocTestController(SageObject):
+@@ -1071,13 +1070,8 @@ class DocTestController(SageObject):
              elif opt.cachegrind:
                  toolname = "cachegrind"
                  flags = os.getenv("SAGE_CACHEGRIND_FLAGS", "")
@@ -44,7 +32,7 @@ diff -up src/sage/doctest/control.py.orig src/sage/doctest/control.py
              if "%s" in flags:
                  flags %= toolname + ".%p" # replace %s with toolname
          cmd += flags + sage_cmd
-@@ -1115,10 +1109,10 @@ class DocTestController(SageObject):
+@@ -1137,10 +1131,10 @@ class DocTestController(SageObject):
              0
          """
          opt = self.options
@@ -58,9 +46,9 @@ diff -up src/sage/doctest/control.py.orig src/sage/doctest/control.py
              return self.run_val_gdb()
          else:
 diff -up src/sage/interfaces/singular.py.orig src/sage/interfaces/singular.py
---- src/sage/interfaces/singular.py.orig	2017-11-08 08:09:36.306175691 -0500
-+++ src/sage/interfaces/singular.py	2017-11-08 08:09:57.144176489 -0500
-@@ -2287,7 +2287,7 @@ def generate_docstring_dictionary():
+--- src/sage/interfaces/singular.py.orig	2018-05-05 16:21:24.000000000 -0600
++++ src/sage/interfaces/singular.py	2018-05-16 13:20:01.421837810 -0600
+@@ -2258,7 +2258,7 @@ def generate_docstring_dictionary():
      nodes.clear()
      node_names.clear()
  
@@ -70,8 +58,8 @@ diff -up src/sage/interfaces/singular.py.orig src/sage/interfaces/singular.py
      new_node = re.compile("File: singular\.hlp,  Node: ([^,]*),.*")
      new_lookup = re.compile("\* ([^:]*):*([^.]*)\..*")
 diff -up src/sage_setup/docbuild/ext/multidocs.py.orig src/sage_setup/docbuild/ext/multidocs.py
---- src/sage_setup/docbuild/ext/multidocs.py.orig	2017-11-08 08:10:07.010176866 -0500
-+++ src/sage_setup/docbuild/ext/multidocs.py	2017-11-08 08:10:30.319177759 -0500
+--- src/sage_setup/docbuild/ext/multidocs.py.orig	2018-05-05 16:21:26.000000000 -0600
++++ src/sage_setup/docbuild/ext/multidocs.py	2018-05-16 13:20:01.421837810 -0600
 @@ -82,8 +82,11 @@ def merge_environment(app, env):
              for ind in newalldoc:
                  # treat subdocument source as orphaned file and don't complain
@@ -85,11 +73,11 @@ diff -up src/sage_setup/docbuild/ext/multidocs.py.orig src/sage_setup/docbuild/e
 +                    env.metadata[ind] = {'orphan'}
              # merge the citations
              newcite = {}
-             for ind, (path, tag) in six.iteritems(docenv.domaindata["std"]["citations"]):
+             citations = docenv.domaindata["std"]["citations"]
 diff -up src/sage_setup/docbuild/__init__.py.orig src/sage_setup/docbuild/__init__.py
---- src/sage_setup/docbuild/__init__.py.orig	2017-11-08 08:10:41.962178205 -0500
-+++ src/sage_setup/docbuild/__init__.py	2017-11-08 08:11:16.448179525 -0500
-@@ -248,13 +248,14 @@ if NUM_THREADS > 1:
+--- src/sage_setup/docbuild/__init__.py.orig	2018-05-05 16:21:26.000000000 -0600
++++ src/sage_setup/docbuild/__init__.py	2018-05-16 13:20:01.422837797 -0600
+@@ -242,13 +242,14 @@ if NUM_THREADS > 1:
          # map_async handles KeyboardInterrupt correctly. Plain map and
          # apply_async does not, so don't use it.
          x = pool.map_async(target, args, 1)
diff --git a/sagemath-scripts.patch b/sagemath-scripts.patch
index 051e8fc..d91d51f 100644
--- a/sagemath-scripts.patch
+++ b/sagemath-scripts.patch
@@ -1,24 +1,7 @@
 diff -up src/bin/sage.orig src/bin/sage
---- src/bin/sage.orig	2017-11-08 06:04:08.687887432 -0500
-+++ src/bin/sage	2017-11-08 06:10:52.452902893 -0500
-@@ -1,5 +1,16 @@
- #!/usr/bin/env bash
- 
-+# Display the Sage startup banner, used in src/bin/sage
-+sage_banner() {
-+    if [ "$SAGE_BANNER" = "bare" ]; then
-+        cat "$SAGE_ROOT/VERSION.txt"
-+    elif [ "$SAGE_BANNER" != "no" ]; then
-+        # This file sage-banner is not yet available during the build
-+        # of Sage, so we ignore errors from cat.
-+        cat "$SAGE_LOCAL/bin/sage-banner" 2>/dev/null
-+    fi
-+}
-+
- help_banner() {
-     sage_banner | grep -v 'Type'
-     echo
-@@ -13,13 +24,10 @@ usage() {
+--- src/bin/sage.orig	2018-05-05 16:21:22.000000000 -0600
++++ src/bin/sage	2018-05-16 12:29:16.699989835 -0600
+@@ -13,13 +13,10 @@ usage() {
      echo "  file.[sage|py|spyx] -- run given .sage, .py or .spyx file"
      echo "  -advanced           -- list all command line options"
      echo "  -c <cmd>            -- Evaluates cmd as sage code"
@@ -32,7 +15,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -inotebook [...]    -- start the *insecure* Sage notebook (deprecated)"
      echo "  -maxima [...]       -- run Sage's Maxima with given arguments"
      echo "  -mwrank [...]       -- run Sage's mwrank with given arguments"
-@@ -27,7 +35,6 @@ usage() {
+@@ -27,7 +24,6 @@ usage() {
      echo "                         'default', 'sagenb', 'jupyter', and 'export')"
      echo "                         Current default is 'export' from sagenb to jupyter"
      echo "  -n, --notebook      -- shortcut for --notebook=default"
@@ -40,7 +23,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -python [...]       -- run the Python 2 interpreter"
      echo "  -python3 [...]      -- run the Python 3 interpreter"
      echo "  -R [...]            -- run Sage's R with given arguments"
-@@ -44,10 +51,6 @@ usage() {
+@@ -44,10 +40,6 @@ usage() {
      echo "                           --optional - controls which optional tests are run"
      echo "                           --sagenb - test all sagenb files"
      echo "                           --help - show all testing options"
@@ -51,7 +34,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -v, -version        -- display Sage version information"
      exit 0
  }
-@@ -66,11 +69,8 @@ usage_advanced() {
+@@ -66,11 +58,8 @@ usage_advanced() {
      echo "  -preparse <file.sage> -- preparse file.sage and produce corresponding file.sage.py"
      echo "  -q                  -- quiet; start with no banner"
      echo "  -root               -- print the Sage root directory"
@@ -63,7 +46,7 @@ diff -up src/bin/sage.orig src/bin/sage
  
      echo
      ####  1.......................26..................................................78
-@@ -82,8 +82,6 @@ usage_advanced() {
+@@ -82,8 +71,6 @@ usage_advanced() {
      echo "                         See the output of sage --notebook --help"
      echo "                         for more details and examples of how to pass"
      echo "                         optional arguments"
@@ -72,10 +55,10 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -inotebook [...]    -- start the *insecure* Sage notebook (deprecated)"
      echo "  -n, -notebook [...] -- start the default Sage notebook (options are the"
      echo "                         same as for the notebook command in Sage).  See the"
-@@ -102,18 +100,11 @@ usage_advanced() {
-     echo "  -gp [...]           -- run Sage's PARI/GP calculator with given arguments"
+@@ -103,18 +90,11 @@ usage_advanced() {
      echo "  -ipython [...]      -- run Sage's IPython using the default environment (not"
      echo "                         Sage), passing additional options to IPython"
+     echo "  -ipython3 [...]     -- same as above, but using Python 3"
 -    echo "  -kash [...]         -- run Sage's Kash with given arguments"
 -    command -v kash &>/dev/null || \
 -    echo "                         (not installed currently, run sage -i kash)"
@@ -91,7 +74,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -python [...]       -- run the Python interpreter"
      echo "  -R [...]            -- run Sage's R with given arguments"
      echo "  -scons [...]        -- run Sage's scons"
-@@ -125,55 +116,7 @@ usage_advanced() {
+@@ -126,55 +106,7 @@ usage_advanced() {
      echo
      ####  1.......................26..................................................78
      ####  |.....................--.|...................................................|
@@ -148,7 +131,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -startuptime [module] -- display how long each component of Sage takes to"
      echo "                         start up; optionally specify a module to get more"
      echo "                         details about that particular module"
-@@ -203,7 +146,6 @@ usage_advanced() {
+@@ -205,7 +137,6 @@ usage_advanced() {
      echo "  -coverage <files>   -- give info about doctest coverage of files"
      echo "  -coverageall        -- give summary info about doctest coverage of all"
      echo "                         files in the Sage library"
@@ -156,7 +139,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -search_src <string> -- search through all the Sage library code for string"
      echo "  -search_doc <string> -- search through the Sage documentation for string"
      echo "  -grep <string>      -- same as -search_src"
-@@ -225,16 +167,6 @@ usage_advanced() {
+@@ -227,16 +158,6 @@ usage_advanced() {
      echo
      ####  1.......................26..................................................78
      ####  |.....................--.|...................................................|
@@ -173,7 +156,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "Valgrind memory debugging:"
      echo "  -cachegrind         -- run Sage using Valgrind's cachegrind tool.  The log"
      echo "                         files are named sage-cachegrind.PID can be found in"
-@@ -248,9 +180,6 @@ usage_advanced() {
+@@ -250,9 +171,6 @@ usage_advanced() {
      echo "  -memcheck           -- run Sage using Valgrind's memcheck tool.  The log"
      echo "                         files are named sage-memcheck.PID can be found in"
      echo "                         $DOT_SAGE"
@@ -183,7 +166,7 @@ diff -up src/bin/sage.orig src/bin/sage
      echo "  -valgrind           -- this is an alias for -memcheck"
      echo
      echo "You can also use -- before a long option, e.g., 'sage --optional'."
-@@ -259,121 +188,6 @@ usage_advanced() {
+@@ -261,128 +179,6 @@ usage_advanced() {
  }
  
  
@@ -251,40 +234,47 @@ diff -up src/bin/sage.orig src/bin/sage
 -    fi
 -
 -    set -e
--
 -    cd "$SAGE_ROOT"
 -
--    # First of all, make sure that the toolchain is up-to-date
--    # (which is a dependency of every package)
--    ./sage --location
--    $MAKE all-toolchain
--    echo
--
+-    # Parse options
+-    PACKAGES=""         # Packages to install
 -    INSTALL_OPTIONS=""  # Options to sage-spkg
--    for PKG in "$@"
--    do
--        case "$PKG" in
+-    for OPT in "$@"; do
+-        case "$OPT" in
 -            -info|--info)
--                echo >&2 "Error: 'sage -i $PKG <package>' is no longer supported, use 'sage --info <package>' instead."
+-                echo >&2 "Error: 'sage -i $OPT <package>' is no longer supported, use 'sage --info <package>' instead."
 -                exit 2;;
 -            -f) FORCE_INSTALL=yes;;
--            -*) INSTALL_OPTIONS="$INSTALL_OPTIONS $PKG";;
--            *)
--                # First check that $PKG is actually a Makefile target
--                if ! grep "^$PKG: " build/make/Makefile >/dev/null; then
--                    echo >&2 "Error: package '$PKG' not found"
--                    echo >&2 "Assuming it is an old-style package... (this is deprecated: use -p instead of -i to install old-style packages)"
--                    echo >&2
--                    sleep 5
--                    ./sage -p $INSTALL_OPTIONS "$PKG"
--                else
--                    if [ x$FORCE_INSTALL = xyes ]; then
--                        $MAKE "$PKG-clean"
--                    fi
--                    $MAKE SAGE_SPKG="sage-spkg $INSTALL_OPTIONS" "$PKG"
--                fi;;
+-            -*) INSTALL_OPTIONS="$INSTALL_OPTIONS $OPT";;
+-            *) PACKAGES="$PACKAGES $OPT";;
 -        esac
 -    done
+-
+-    # First, uninstall the packages if -f was given
+-    if [ "$FORCE_INSTALL" = yes ]; then
+-        for PKG in $PACKAGES; do
+-            $MAKE "$PKG-clean" || true  # Ignore errors
+-        done
+-    fi
+-
+-    # Make sure that the toolchain is up-to-date
+-    # (which is a dependency of every package)
+-    $MAKE all-toolchain
+-
+-    ALL_TARGETS="$($MAKE list 2>/dev/null)"
+-
+-    # Now install the packages
+-    for PKG in $PACKAGES; do
+-        echo
+-        # First check that $PKG is actually a Makefile target
+-        # See https://trac.sagemath.org/ticket/25078
+-        if ! echo "$ALL_TARGETS" | grep "^${PKG}$" >/dev/null; then
+-            echo >&2 "Error: package '$PKG' not found"
+-            echo >&2 "Note: if it is an old-style package, use -p instead of -i to install it"
+-            exit 1
+-        fi
+-        $MAKE SAGE_SPKG="sage-spkg $INSTALL_OPTIONS" "$PKG"
+-    done
 -    exit 0
 -fi
 -
@@ -305,11 +295,8 @@ diff -up src/bin/sage.orig src/bin/sage
  if [ $# -gt 0 ]; then
    if [ "$1" = '-h' -o "$1" = '-?' -o "$1" = '-help' -o "$1" = '--help' ]; then
       usage
-@@ -383,25 +197,12 @@ if [ $# -gt 0 ]; then
-   fi
- fi
+@@ -394,20 +190,6 @@ fi
  
-+
  # Prepare for running Sage, either interactively or non-interactively.
  sage_setup() {
 -    # Check that we're not in a source tarball which hasn't been built yet (#13561).
@@ -324,15 +311,12 @@ diff -up src/bin/sage.orig src/bin/sage
 -        exit 1
 -    fi
 -
-     # Display the startup banner (unless SAGE_BANNER is explicitly "no")
-     sage_banner
- 
 -    maybe_sage_location
 -
      if [ ! -d "$IPYTHONDIR" ]; then
          # make sure that $DOT_SAGE exists so that ipython will happily
          # create its config directories there.  If DOT_SAGE doesn't
-@@ -412,20 +213,6 @@ sage_setup() {
+@@ -418,20 +200,6 @@ sage_setup() {
  }
  
  
@@ -353,7 +337,7 @@ diff -up src/bin/sage.orig src/bin/sage
  # Start an interactive Sage session, this function never returns.
  interactive_sage() {
      sage_setup
-@@ -530,16 +317,6 @@ if [ "$1" = '-lisp' -o "$1" = '--lisp' ]
+@@ -536,16 +304,6 @@ if [ "$1" = '-lisp' -o "$1" = '--lisp' ]
      exec ecl "$@"
  fi
  
@@ -370,7 +354,7 @@ diff -up src/bin/sage.orig src/bin/sage
  if [ "$1" = '-maxima' -o "$1" = '--maxima' ]; then
      shift
      exec maxima "$@"
-@@ -565,11 +342,6 @@ if [ "$1" = '-pip' -o "$1" = '--pip' ];
+@@ -571,11 +329,6 @@ if [ "$1" = '-pip' -o "$1" = '--pip' ];
      exec pip "$@"
  fi
  
@@ -382,8 +366,8 @@ diff -up src/bin/sage.orig src/bin/sage
  if [ "$1" = '-python' -o "$1" = '--python' ]; then
      shift
      exec python "$@"
-@@ -595,16 +367,6 @@ if [ "$1" = '-ipython' -o "$1" = '--ipyt
-     exec ipython "$@"
+@@ -606,16 +359,6 @@ if [ "$1" = '-ipython3' -o "$1" = '--ipy
+     exec ipython3 "$@"
  fi
  
 -if [ "$1" = '-git' -o "$1" = '--git' ]; then
@@ -399,7 +383,7 @@ diff -up src/bin/sage.orig src/bin/sage
  if [ "$1" = '-sh' -o "$1" = '--sh' ]; then
      # AUTHORS:
      # - Carl Witty and William Stein: initial version
-@@ -724,20 +486,6 @@ EOF
+@@ -735,20 +478,6 @@ EOF
  fi
  
  #####################################################################
@@ -420,7 +404,7 @@ diff -up src/bin/sage.orig src/bin/sage
  # File conversion
  #####################################################################
  
-@@ -760,11 +508,6 @@ fi
+@@ -771,11 +500,6 @@ fi
  # Run Sage's versions of the standard Algebra/Geometry etc. software
  #####################################################################
  
@@ -432,7 +416,7 @@ diff -up src/bin/sage.orig src/bin/sage
  if [[ "$1" =~ ^--notebook=.* || "$1" =~ ^-n=.* || "$1" =~ ^-notebook=.* ]] ; then
      sage-cleaner &>/dev/null &
      exec sage-notebook "$@"
-@@ -775,13 +518,6 @@ if [ "$1" = "-notebook" -o "$1" = '--not
+@@ -786,13 +510,6 @@ if [ "$1" = "-notebook" -o "$1" = '--not
      exec sage-notebook "$@"
  fi
  
@@ -446,8 +430,8 @@ diff -up src/bin/sage.orig src/bin/sage
  if [ "$1" = "-inotebook" -o "$1" = '--inotebook' ]; then
      shift
      sage-cleaner &>/dev/null &
-@@ -800,34 +536,15 @@ if [ "$1" = '-grepdoc' -o "$1" = "--grep
-    exit 0
+@@ -811,34 +528,15 @@ if [ "$1" = '-grepdoc' -o "$1" = "--grep
+     exit 0
  fi
  
 -if [ "$1" = '-b' ]; then
@@ -461,8 +445,8 @@ diff -up src/bin/sage.orig src/bin/sage
 -fi
 -
  if [ "$1" = '-r' ]; then
-    shift
-    interactive_sage
+     shift
+     interactive_sage
  fi
  
 -if [ "$1" = '-ba' -o "$1" = '-ba-force' -o "$1" = '--ba-force' ]; then
@@ -476,14 +460,14 @@ diff -up src/bin/sage.orig src/bin/sage
 -        build_sage
 -    fi
 +if [ "$1" = '-t' -o "$1" = '-tp' ]; then
-     SAGE_BANNER=no sage_setup
+     sage_setup
      export PYTHONIOENCODING="utf-8"  # Fix encoding for doctests
 -    if [ "$1" = '-tp' -o "$1" = '-btp' ]; then
 +    if [ "$1" = '-tp' ]; then
          shift
          exec sage-runtests -p "$@"
      else
-@@ -836,10 +553,7 @@ if [ "$1" = '-t' -o "$1" = '-bt' -o "$1"
+@@ -847,10 +545,7 @@ if [ "$1" = '-t' -o "$1" = '-bt' -o "$1"
      fi
  fi
  
@@ -493,9 +477,9 @@ diff -up src/bin/sage.orig src/bin/sage
 -    fi
 +if [ "$1" = '-tnew' ]; then
      shift
-     SAGE_BANNER=no sage_setup
+     sage_setup
      export PYTHONIOENCODING="utf-8"  # Fix encoding for doctests
-@@ -860,119 +574,6 @@ if [ "$1" = '-c' ]; then
+@@ -871,119 +566,6 @@ if [ "$1" = '-c' ]; then
      exec sage-eval "$@"
  fi
  
@@ -609,13 +593,13 @@ diff -up src/bin/sage.orig src/bin/sage
 -
 -if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then
 -    shift
--    exec python -m "sage_setup.docbuild" "$@"
+-    exec sage-python23 -m "sage_setup.docbuild" "$@"
 -fi
 -
  if [ "$1" = '-gdb' -o "$1" = "--gdb" ]; then
      shift
      sage_setup
-@@ -1023,12 +624,6 @@ if [ "$1" = '-callgrind' -o "$1" = "--ca
+@@ -1033,12 +615,6 @@ if [ "$1" = '-callgrind' -o "$1" = "--ca
      exec sage-callgrind "$@"
  fi
  
@@ -628,10 +612,9 @@ diff -up src/bin/sage.orig src/bin/sage
  if [ "$1" = '-startuptime' -o "$1" = '--startuptime' ]; then
      exec sage-startuptime.py "$@"
  fi
-diff -up src/bin/sage-runtests.orig src/bin/sage-runtests
---- src/bin/sage-runtests.orig	2017-11-08 06:11:02.679903285 -0500
-+++ src/bin/sage-runtests	2017-11-08 06:11:18.876903905 -0500
-@@ -64,10 +64,6 @@ if __name__ == "__main__":
+--- src/bin/sage-runtests.orig	2018-05-05 16:21:22.000000000 -0600
++++ src/bin/sage-runtests	2018-05-16 12:16:10.707645467 -0600
+@@ -67,10 +67,6 @@ if __name__ == "__main__":
                        help="run doctests using Valgrind's cachegrind tool.  The log "
                           "files are named sage-cachegrind.PID and can be found in " +
                           os.path.join(DOT_SAGE, "valgrind"))
@@ -642,9 +625,8 @@ diff -up src/bin/sage-runtests.orig src/bin/sage-runtests
  
      parser.add_option("-f", "--failed", action="store_true", default=False,
          help="doctest only those files that failed in the previous run")
-diff -up src/bin/sage-valgrind.orig src/bin/sage-valgrind
---- src/bin/sage-valgrind.orig	2017-11-08 06:11:27.655904241 -0500
-+++ src/bin/sage-valgrind	2017-11-08 06:11:40.964904751 -0500
+--- src/bin/sage-valgrind.orig	2018-05-05 16:21:22.000000000 -0600
++++ src/bin/sage-valgrind	2018-05-16 12:16:10.708645454 -0600
 @@ -1,16 +1,6 @@
  #!/usr/bin/env bash
  
diff --git a/sagemath-sympy.patch b/sagemath-sympy.patch
index 70d562a..8f561cc 100644
--- a/sagemath-sympy.patch
+++ b/sagemath-sympy.patch
@@ -1,7 +1,7 @@
 diff -up src/sage/env.py.orig src/sage/env.py
---- src/sage/env.py.orig	2017-11-08 08:27:50.523217592 -0500
-+++ src/sage/env.py	2017-11-08 08:27:58.147217884 -0500
-@@ -90,7 +90,7 @@ _add_variable_or_fallback('HOSTNAME',
+--- src/sage/env.py.orig	2018-05-05 16:21:23.000000000 -0600
++++ src/sage/env.py	2018-05-16 13:42:40.591238911 -0600
+@@ -117,7 +117,7 @@ _add_variable_or_fallback('HOSTNAME',
  _add_variable_or_fallback('LOCAL_IDENTIFIER','$HOSTNAME.%s'%os.getpid())
  
  # bunch of sage directories and files
@@ -10,7 +10,7 @@ diff -up src/sage/env.py.orig src/sage/env.py
  _add_variable_or_fallback('SAGE_LOCAL',      None)
  _add_variable_or_fallback('SAGE_ETC',        opj('$SAGE_LOCAL', 'etc'))
  _add_variable_or_fallback('SAGE_INC',        opj('$SAGE_LOCAL', 'include'))
-@@ -116,7 +116,7 @@ _add_variable_or_fallback('SAGE_PKGS', o
+@@ -141,7 +141,7 @@ _add_variable_or_fallback('SAGE_PKGS', o
  _add_variable_or_fallback('SAGE_EXTCODE',    opj('$SAGE_SHARE', 'sage', 'ext'))
  _add_variable_or_fallback('SAGE_LOGS',       opj('$SAGE_ROOT', 'logs', 'pkgs'))
  _add_variable_or_fallback('SAGE_SPKG_INST',  opj('$SAGE_LOCAL', 'var', 'lib', 'sage', 'installed'))
diff --git a/sagemath.spec b/sagemath.spec
index ad448b7..c2af9ca 100644
--- a/sagemath.spec
+++ b/sagemath.spec
@@ -32,24 +32,26 @@
 %global SAGE_TIMEOUT		60
 %global SAGE_TIMEOUT_LONG	180
 
+%global combinatorial_designs_pkg	combinatorial_designs-20140630
 %global conway_polynomials_pkg	conway_polynomials-0.5
 %global	elliptic_curves_pkg	elliptic_curves-0.8
 %global	flintqs_pkg		flintqs-1.0
 %global graphs_pkg		graphs-20161026
 %if %{with bundled_ipython}
-%global ipython_pkg		ipython-5.1.0
+%global ipython_pkg		ipython-5.5.0
 %endif
 %if %{with bundled_ipywidgets}
-%global ipywidgets_pkg		ipywidgets-6.0.0
+%global ipywidgets_pkg		ipywidgets-7.1.1
 %endif
 %if %{with bundled_pexpect}
 %global pexpect_pkg		pexpect-4.1.0
 %endif
-%global polytopes_db_pkg	polytopes_db-20120220
+%global polytopes_db_pkg	polytopes_db-20170220
 %global rubiks_pkg		rubiks-20070912
 %global	sagenb_pkg		sagenb-1.0.1
+%global sagenb_export_pkg	sagenb_export-3.2
 %global sagetex_pkg		sagetex-3.0
-%global Sphinx_pkg		Sphinx-1.5.3
+%global Sphinx_pkg		Sphinx-1.6.3
 
 %global SAGE_ROOT		%{_libdir}/sagemath
 %global SAGE_LOCAL		%{SAGE_ROOT}/local
@@ -61,18 +63,16 @@
 %global SAGE_SPKG_INST		%{SAGE_LOCAL}/var/lib/sage/installed
 
 Name:		sagemath
-Group:		Applications/Engineering
 Summary:	A free open-source mathematics software system
-Version:	8.0
-Release:	3%{?dist}
+Version:	8.2
+Release:	1%{?dist}
 # The file ${SAGE_ROOT}/COPYING.txt is the upstream license breakdown file
 # Additionally, every $files section has a comment with the license name
 # before files with that license
 License:	ASL 2.0 and BSD and GPL+ and GPLv2+ and LGPLv2+ and MIT and Public Domain
 URL:		http://www.sagemath.org
-Source0:	http://boxen.math.washington.edu/home/%{name}/sage-mirror/src/sage-%{version}.tar.gz
+Source0:	http://files.sagemath.org/src/sage-%{version}.tar.gz
 Source1:	gprc.expect
-Source2:	makecmds.sty
 # Follow maxima's ExclusiveArch
 ExclusiveArch: aarch64 %{arm} %{ix86} x86_64 ppc sparcv9
 
@@ -127,11 +127,11 @@ Patch12:	%{name}-lrslib.patch
 # http://pallini.di.uniroma1.it/
 Patch13:	%{name}-nauty.patch
 
-# gap hap package not (yet) available
-# http://www-gap.mcs.st-and.ac.uk/Packages/hap.html
+# gap hap package is a requires
 Patch14:	%{name}-gap-hap.patch
 
 # correct path to Lfunction include
+# update c++ standard to fix FTBFS
 Patch15:	%{name}-lcalc.patch
 
 # avoid assertion in coin backend
@@ -149,8 +149,8 @@ Patch19:	%{name}-fes.patch
 # https://bugzilla.redhat.com/show_bug.cgi?id=974769
 Patch20:	%{name}-sympy.patch
 
-# Fix a name clash with NTL
-Patch21:	%{name}-ntl.patch
+# Adapt to MPFR 3.x.  Remove this once Fedora updates to MPFR 4.x.
+Patch21:	%{name}-mpfr.patch
 
 # Correct unable to start QEPCAD within sage
 # https://bugzilla.redhat.com/show_bug.cgi?id=1243590
@@ -160,32 +160,23 @@ Patch22:	%{name}-qepcad.patch
 Patch23:	%{name}-arb.patch
 
 # No support for f" notation
-Patch25:	%{name}-nofstring.patch
+Patch24:       %{name}-nofstring.patch
 
 # Add missing include paths
-Patch26:	%{name}-includes.patch
-
-# https://trac.sagemath.org/ticket/20926
-# #error This file requires compiler and library support for the ISO C++ \
-#	2011 standard. This support must be enabled with the -std=c++11 \
-#	or -std=gnu++11 compiler options.
-Patch27:	%{name}-gcc6.patch
+Patch25:	%{name}-includes.patch
 
 # Use atlas blas
-Patch28:	%{name}-atlas.patch
+Patch26:	%{name}-atlas.patch
 
 BuildRequires:	4ti2
-BuildRequires:	apache-commons-cli
 BuildRequires:	arb-devel
 BuildRequires:	atlas-devel
+BuildRequires:	boost-devel
 BuildRequires:	brial-devel
 BuildRequires:	cddlib-tools
 BuildRequires:	cliquer-devel
 BuildRequires:	coin-or-Cbc-devel
-BuildRequires:	cryptominisat-devel
-BuildRequires:	Cython >= 0.24.1
 BuildRequires:	desktop-file-utils
-BuildRequires:	dos2unix
 BuildRequires:	dvipng
 BuildRequires:	ecl
 BuildRequires:	eclib-devel
@@ -194,25 +185,25 @@ BuildRequires:	factory-devel
 BuildRequires:	fes-devel
 %endif
 BuildRequires:	flint-devel
-BuildRequires:	gmp-ecm-devel
 BuildRequires:	gap
 BuildRequires:	GAPDoc
 BuildRequires:	gap-libs
 BuildRequires:	gap-pkg-atlasrep
-BuildRequires:	gap-pkg-ctbllib
+BuildRequires:	gap-pkg-crime
 BuildRequires:	gap-pkg-design
 BuildRequires:	gap-pkg-guava
-BuildRequires:	gap-pkg-hap
+BuildRequires:	gap-pkg-hapcryst
 BuildRequires:	gap-pkg-sonata
-BuildRequires:	gap-pkg-tomlib
+BuildRequires:	gap-pkg-toric
 BuildRequires:	gc-devel
 BuildRequires:	gcc-c++
 BuildRequires:	gd-devel
 BuildRequires:	genus2reduction
 BuildRequires:	gfan
+BuildRequires:	giac-devel
 BuildRequires:	glpk-devel
 BuildRequires:	gmp-ecm
-BuildRequires:	gnutls-devel
+BuildRequires:	gmp-ecm-devel
 BuildRequires:	gsl-devel
 BuildRequires:	ImageMagick
 BuildRequires:	iml-devel
@@ -222,7 +213,7 @@ BuildRequires:	jsmath-fonts
 BuildRequires:	jsmol
 BuildRequires:	L-function-devel
 BuildRequires:	lapack-devel
-BuildRequires:	libfac-devel
+BuildRequires:	latte-integrale
 BuildRequires:	libfplll-devel
 BuildRequires:	libgap-devel
 BuildRequires:	libmpc-devel
@@ -236,49 +227,72 @@ BuildRequires:	maxima-runtime-ecl
 BuildRequires:	mpfi-devel
 BuildRequires:	nauty
 BuildRequires:	ntl-devel
-BuildRequires:	numpy
+BuildRequires:	openssl
 BuildRequires:	palp
 BuildRequires:	pari-devel
+BuildRequires:	pari-galdata
 BuildRequires:	pari-gp
+BuildRequires:	pari-seadata
 BuildRequires:	planarity-devel
 BuildRequires:	ppl-devel
 BuildRequires:	pynac-devel
 BuildRequires:	python2-devel
-BuildRequires:	python-backports-shutil_get_terminal_size
-BuildRequires:	python-brial
-BuildRequires:	python-cypari2-devel
-BuildRequires:	python-cysignals-devel
-BuildRequires:	python-crypto
-BuildRequires:	python-cvxopt
-BuildRequires:	python-docutils
-BuildRequires:	python-flask-autoindex
-BuildRequires:	python-flask-babel
-BuildRequires:	python-flask-openid
-BuildRequires:	python-flask-silk
+%if %{with bundled_ipython}
+BuildRequires:	python2-backports-shutil_get_terminal_size
+%endif
+BuildRequires:	python2-brial
+%if %{with sphinx_hack}
+BuildRequires:	python2-configparser
+%endif
+BuildRequires:	python2-cypari2-devel
+BuildRequires:	python2-cysignals-devel
+BuildRequires:	python2-Cython
+BuildRequires:	python2-crypto
+BuildRequires:	python2-cryptominisat
+BuildRequires:	python2-cvxopt
+BuildRequires:	python2-docutils
+BuildRequires:	python2-flask-autoindex
+BuildRequires:	python2-flask-babel
+BuildRequires:	python2-flask-openid
+BuildRequires:	python2-flask-silk
+BuildRequires:	python2-fpylll
+BuildRequires:	python2-future
+BuildRequires:	python2-gmpy2
+%if %{with sphinx_hack}
+BuildRequires:	python2-html5lib
+BuildRequires:	python2-imagesize
+%endif
+BuildRequires:	python2-ipykernel
 %if %{without bundled_ipython}
-BuildRequires:	python-ipython
+BuildRequires:	python2-ipython
 %endif
-BuildRequires:	python-future
-BuildRequires:	python-ipykernel
-BuildRequires:	python-jupyter-core
-BuildRequires:	python-matplotlib
-BuildRequires:	python-networkx
-BuildRequires:	python-pathlib2
+BuildRequires:	python2-matplotlib
+BuildRequires:	python2-networkx
+BuildRequires:	python2-notebook
+%if %{with bundled_ipython}
+BuildRequires:	python2-path
+%endif
+BuildRequires:	python2-pathlib2
 %if %{without bundled_pexpect}
-BuildRequires:	python-pexpect
+BuildRequires:	python2-pexpect
 %endif
-BuildRequires:	python-pickleshare
-BuildRequires:	python-prompt_toolkit
-BuildRequires:	python-pkgconfig
-BuildRequires:	python-psutil
-BuildRequires:	python-six
-BuildRequires:	python-speaklater
-BuildRequires:	python-sphinx
-BuildRequires:	python-traitlets
-BuildRequires:	python-twisted
-BuildRequires:	python-twisted-mail
-BuildRequires:	python-twisted-web
-BuildRequires:	python-ZODB3
+BuildRequires:	python2-pickleshare
+BuildRequires:	python2-pillow-devel
+BuildRequires:	python2-prompt_toolkit
+BuildRequires:	python2-pkgconfig
+BuildRequires:	python2-psutil
+BuildRequires:	python2-ptyprocess
+BuildRequires:	python2-scipy
+BuildRequires:	python2-setuptools
+%if %{with bundled_ipython}
+BuildRequires:	python2-simplegeneric
+%endif
+BuildRequires:	python2-six
+BuildRequires:	python2-speaklater
+BuildRequires:	python2-sphinx
+BuildRequires:	python2-sympy
+BuildRequires:	python2-twisted
+BuildRequires:	python2-ZODB3
 BuildRequires:	qepcad-B
 BuildRequires:	R
 BuildRequires:	ratpoints-devel
@@ -290,10 +304,10 @@ BuildRequires:	Singular-devel
 BuildRequires:	stix-math-fonts
 BuildRequires:	symmetrica-devel
 BuildRequires:	sympow
-BuildRequires:	sympy
 BuildRequires:	tachyon
 BuildRequires:	texlive
 BuildRequires:	tex(anyfontsize.sty)
+BuildRequires:	tex(makecmds.sty)
 BuildRequires:	vecmath
 # For _jsdir macro
 BuildRequires:	web-assets-devel
@@ -302,66 +316,88 @@ BuildRequires:	xorg-x11-server-Xvfb
 BuildRequires:	zn_poly-devel
 
 Requires:	4ti2
-Requires:	apache-commons-cli
 Requires:	cddlib-tools
-Requires:	Cython
 Requires:	ecl
 Requires:	gap
 Requires:	GAPDoc
 Requires:	gap-libs
 Requires:	gap-pkg-atlasrep
-Requires:	gap-pkg-ctbllib
+Requires:	gap-pkg-crime
 Requires:	gap-pkg-design
 Requires:	gap-pkg-guava
-Requires:	gap-pkg-hap
+Requires:	gap-pkg-hapcryst
 Requires:	gap-pkg-sonata
-Requires:	gap-pkg-tomlib
+Requires:	gap-pkg-toric
 Requires:	genus2reduction
 Requires:	gfan
 Requires:	gmp-ecm
 Requires:	jmol
 Requires:	jsmol
 Requires:	jsmath-fonts
+Requires:	latte-integrale
 Requires:	lrslib-utils
 Requires:	mathjax
 Requires:	maxima-gui
 Requires:	maxima-runtime-ecl
 Requires:	nauty
 Requires:	palp
+Requires:	pari-galdata
 Requires:	pari-gp
-Requires:	python-backports-shutil_get_terminal_size
-Requires:	python-brial
-Requires:	python-cysignals
-Requires:	python-crypto
-Requires:	python-cvxopt
-Requires:	python-docutils
-Requires:	python-flask-autoindex
-Requires:	python-flask-babel
-Requires:	python-flask-openid
-Requires:	python-flask-silk
-Requires:	python-future
+Requires:	pari-seadata
+%if %{with bundled_ipython}
+Requires:	python2-backports-shutil_get_terminal_size
+%endif
+Requires:	python2-brial
+%if %{with sphinx_hack}
+Requires:	python2-configparser
+%endif
+Requires:	python2-cypari2
+Requires:	python2-cysignals
+Requires:	python2-crypto
+Requires:	python2-cryptominisat
+Requires:	python2-cvxopt
+Requires:	python2-Cython
+Requires:	python2-docutils
+Requires:	python2-flask-autoindex
+Requires:	python2-flask-babel
+Requires:	python2-flask-openid
+Requires:	python2-flask-silk
+Requires:	python2-fpylll
+Requires:	python2-future
+Requires:	python2-gmpy2
+%if %{with sphinx_hack}
+Requires:	python2-html5lib
+Requires:	python2-imagesize
+%endif
+Requires:	python2-ipykernel
 %if %{without bundled_ipython}
-Requires:	python-ipython
+Requires:	python2-ipython
 %endif
-Requires:	python-ipykernel
-Requires:	python-jupyter-core
-Requires:	python-matplotlib
-Requires:	python-networkx
-Requires:	python-pathlib2
+Requires:	python2-matplotlib
+Requires:	python2-networkx
+Requires:	python2-notebook
+%if %{with bundled_ipython}
+Requires:	python2-path
+%endif
+Requires:	python2-pathlib2
 %if %{without bundled_pexpect}
-Requires:	python-pexpect
+Requires:	python2-pexpect
 %endif
-Requires:	python-pickleshare
-Requires:	python-prompt_toolkit
-Requires:	python-psutil
-Requires:	python-six
-Requires:	python-speaklater
-Requires:	python-sphinx
-Requires:	python-traitlets
-Requires:	python-twisted
-Requires:	python-twisted-mail
-Requires:	python-twisted-web
-Requires:	python-ZODB3
+Requires:	python2-pickleshare
+Requires:	python2-pillow
+Requires:	python2-prompt_toolkit
+Requires:	python2-psutil
+Requires:	python2-ptyprocess
+Requires:	python2-scipy
+%if %{with bundled_ipython}
+BuildRequires:	python2-simplegeneric
+%endif
+Requires:	python2-six
+Requires:	python2-speaklater
+Requires:	python2-sphinx
+Requires:	python2-sympy
+Requires:	python2-twisted
+Requires:	python2-ZODB3
 Requires:	qepcad-B
 Requires:	R
 Requires:	rpy
@@ -376,7 +412,6 @@ Requires:	%{name}-sagetex
 Requires:	Singular
 Requires:	stix-math-fonts
 Requires:	sympow
-Requires:	sympy
 Requires:	tachyon
 Requires:	texlive
 Requires:	vecmath
@@ -389,7 +424,6 @@ packages into a common Python-based interface.
 #------------------------------------------------------------------------
 %package	core
 Summary:	Open Source Mathematics Software
-Group:		Applications/Engineering
 Requires:	%{name}%{?_isa} = %{version}-%{release}
 Obsoletes:	%{name}-devel < 6.8-1
 
@@ -399,8 +433,8 @@ This package contains the core sagemath python modules.
 #------------------------------------------------------------------------
 %package	data
 Summary:	Databases and scripts for %{name}
-Group:		Applications/Engineering
 Requires:	%{name} = %{version}-%{release}
+Requires:	%{name}-data-combinatorial_designs = %{version}-%{release}
 Requires:	%{name}-data-conway_polynomials = %{version}-%{release}
 Requires:	%{name}-data-elliptic_curves = %{version}-%{release}
 Requires:	%{name}-data-etc = %{version}-%{release}
@@ -411,10 +445,19 @@ BuildArch:	noarch
 %description	data
 Collection of databases and interface customization scripts for sagemath.
 
+#------------------------------------------------------------------------
+%package	data-combinatorial_designs
+Summary:	Table of MOLS from the Handbook of Combinatorial Designs
+Requires:	%{name}-data = %{version}-%{release}
+BuildArch:	noarch
+
+%description	data-combinatorial_designs
+The table of MOLS (10000 integers) from the Handbook of Combinatorial
+Designs, 2nd edition.
+
 #------------------------------------------------------------------------
 %package	data-conway_polynomials
 Summary:	Conway Polynomials Database
-Group:		Applications/Engineering
 Requires:	%{name}-data = %{version}-%{release}
 BuildArch:	noarch
 
@@ -424,7 +467,6 @@ Small database of Conway polynomials for sagemath.
 #------------------------------------------------------------------------
 %package	data-elliptic_curves
 Summary:	Databases of elliptic curves
-Group:		Applications/Engineering
 Requires:	%{name}-data = %{version}-%{release}
 BuildArch:	noarch
 
@@ -440,7 +482,6 @@ Includes two databases:
 #------------------------------------------------------------------------
 %package	data-etc
 Summary:	Extcode for Sagemath
-Group:		Applications/Engineering
 Requires:	%{name}-data = %{version}-%{release}
 Obsoletes:      %{name}-data-extcode < %{version}
 BuildArch:	noarch
@@ -451,7 +492,6 @@ Collection of scripts and interfaces to sagemath.
 #------------------------------------------------------------------------
 %package	data-graphs
 Summary:	Sagemath database of graphs
-Group:		Applications/Engineering
 Requires:	%{name}-data = %{version}-%{release}
 BuildArch:	noarch
 
@@ -462,7 +502,6 @@ Grout. Since April 2012 it also contains the ISGCI graph database.
 #------------------------------------------------------------------------
 %package	data-polytopes_db
 Summary:	Lists of 2- and 3-dimensional reflexive polytopes
-Group:		Applications/Engineering
 Requires:	%{name}-data = %{version}-%{release}
 BuildArch:	noarch
 
@@ -479,7 +518,6 @@ ReflexivePolytope and ReflexivePolytopes commands.
 #------------------------------------------------------------------------
 %package	doc
 Summary:	Documentation infrastructure files for %{name}
-Group:		Documentation
 
 %description	doc
 This package contains the documentation infrastructure for %{name}.
@@ -487,7 +525,6 @@ This package contains the documentation infrastructure for %{name}.
 #------------------------------------------------------------------------
 %package	doc-ca
 Summary:	Catalan documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-ca
@@ -496,7 +533,6 @@ This package contains the Catalan %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-de
 Summary:	German documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-de
@@ -505,7 +541,6 @@ This package contains the German %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-en
 Summary:	English documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-en
@@ -514,7 +549,6 @@ This package contains the English %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-fr
 Summary:	French documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-fr
@@ -523,7 +557,6 @@ This package contains the French %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-hu
 Summary:	Hungarian documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-hu
@@ -532,7 +565,6 @@ This package contains the Hungarian %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-it
 Summary:	Italian documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-it
@@ -541,7 +573,6 @@ This package contains the Italian %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-pt
 Summary:	Portuguese documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-pt
@@ -550,7 +581,6 @@ This package contains the Portuguese %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-ru
 Summary:	Russian documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-ru
@@ -559,7 +589,6 @@ This package contains the Russian %{name} documentation.
 #------------------------------------------------------------------------
 %package	doc-tr
 Summary:	Turkish documentation files for %{name}
-Group:		Documentation
 Requires:	%{name}-doc = %{version}-%{release}
 
 %description	doc-tr
@@ -570,17 +599,26 @@ This package contains the Turkish %{name} documentation.
 #------------------------------------------------------------------------
 %package	notebook
 Summary:	The Sage Notebook
-Group:		Applications/Engineering
 Requires:	%{name}%{?_isa} = %{version}-%{release}
 
 %description	notebook
 The Sage Notebook is a web-based graphical user interface for
 mathematical software.
 
+#------------------------------------------------------------------------
+%package	notebook-export
+Summary:	The Sage Notebook Exporter
+Requires:	%{name}%{?_isa} = %{version}-%{release}
+Requires:	%{name}-notebook = %{version}-%{release}
+BuildArch:	noarch
+
+%description	notebook-export
+The Sage Notebook Exporter converts SageNB notebooks to other formats,
+in particular IPython/Jupyter notebooks.
+
 #------------------------------------------------------------------------
 %package	rubiks
 Summary:	Several programs for working with Rubik's cubes
-Group:		Applications/Engineering
 Requires:	%{name}%{?_isa} = %{version}-%{release}
 
 %description	rubiks
@@ -604,8 +642,16 @@ Eric Dietz (GPL) http://www.wrongway.org/?rubiksource
 #------------------------------------------------------------------------
 %package	sagetex
 Summary:	Sagemath into LaTeX documents
-Group:		Applications/Engineering
 Requires:	%{name}%{?_isa} = %{version}-%{release}
+Requires:	tex(color.sty)
+Requires:	tex(fancyvrb.sty)
+Requires:	tex(graphicx.sty)
+Requires:	tex(ifpdf.sty)
+Requires:	tex(ifthen.sty)
+Requires:	tex(ifxetex.sty)
+Requires:	tex(listings.sty)
+Requires:	tex(makecmds.sty)
+Requires:	tex(verbatim.sty)
 
 %description	sagetex
 This is the SageTeX package. It allows you to embed code, results of
@@ -616,6 +662,11 @@ computations, and plots from the Sage mathematics software suite
 %prep
 %setup -q -n sage-%{version}
 
+pushd build/pkgs/combinatorial_designs
+    tar jxf ../../../upstream/%{combinatorial_designs_pkg}.tar.bz2
+    mv %{combinatorial_designs_pkg} src
+popd
+
 pushd build/pkgs/conway_polynomials
     tar jxf ../../../upstream/%{conway_polynomials_pkg}.tar.bz2
     mv %{conway_polynomials_pkg} src
@@ -682,9 +733,17 @@ pushd build/pkgs/sagenb
     mv %{sagenb_pkg} src
 popd
 
+pushd build/pkgs/sagenb_export
+    tar zxf ../../../upstream/%{sagenb_export_pkg}.tar.gz
+    mv %{sagenb_export_pkg} src
+popd
+
 pushd build/pkgs/sagetex
     tar zxf ../../../upstream/%{sagetex_pkg}.tar.gz
     mv %{sagetex_pkg} src
+    # Fix the style file install path
+    texmfdir=$(cut -d/ -f3- <<< "%{_texmf_main}")
+    sed -i "s,share/texmf,$texmfdir," src/setup.py
 popd
 
 %if %{with docs}
@@ -729,16 +788,15 @@ popd
 %patch21
 %patch22
 %patch23
+%patch24
 %patch25
 %patch26
-%patch27
-%patch28
 
 sed -e 's|@@SAGE_ROOT@@|%{SAGE_ROOT}|' \
     -e 's|@@SAGE_DOC@@|%{SAGE_DOC}|' \
     -i src/sage/env.py
 
-sed -e 's|@@CYSIGNALS@@|%{python_sitearch}/cysignals|' \
+sed -e 's|@@CYSIGNALS@@|%{python2_sitearch}/cysignals|' \
     -i src/setup.py
 
 sed -e "s|, 'flask-oldsessions>=0.10'||" \
@@ -760,6 +818,14 @@ sed -e "s,SINGULARPATH=\",&%{_datadir}/singular/LIB:," \
     -e "s,\(SINGULAR_EXECUTABLE=\"\).*\",\1%{_libdir}/Singular/Singular\"," \
     -i src/bin/sage-env
 
+# fix shebangs
+sed -i 's,#!%{_bindir}/env python,#!%{_bindir}/python2,' \
+  $(grep -Frl '#!%{_bindir}/env python')
+sed -i 's,#!%{_bindir}/env sage-python23,#!%{_bindir}/python2,' \
+  $(grep -Frl '#!%{_bindir}/env sage-python23')
+sed -i 's,#!%{_bindir}/env ,#!%{_bindir}/,' $(grep -Frl '#!%{_bindir}/env')
+sed -i 's,#!%{_bindir}/python$,&2,' $(grep -Frl '#!%{_bindir}/python')
+
 ########################################################################
 %build
 export CC=%{__cc}
@@ -788,7 +854,8 @@ ln -sf %{_includedir} $SAGE_LOCAL/include
 ln -sf %{_datadir} $SAGE_LOCAL/share
 
 export PATH=%{buildroot}%{_bindir}:$PATH
-export PYTHONPATH=%{buildroot}%{python_sitearch}:$PYTHONPATH
+export PYTHON=%{_bindir}/python2
+export PYTHONPATH=%{buildroot}%{python2_sitearch}:$PYTHONPATH
 
 #------------------------------------------------------------------------
 # Save and update environment to generate bundled interfaces
@@ -812,9 +879,9 @@ popd
 %endif
 
 %if %{with cython_hack}
-    cp -far %{python_sitearch}/Cython %{_builddir}%{python_sitearch}
+    cp -far %{python2_sitearch}/Cython %{_builddir}%{python2_sitearch}
     BASE=$PWD/build/pkgs/cython/patches/
-    pushd %{_builddir}%{python_sitearch}
+    pushd %{_builddir}%{python2_sitearch}
 	for PATCH in pxi_sys_path.patch
 	do
 	    patch -p1 < $BASE/$PATCH
@@ -827,6 +894,8 @@ popd
 # Restore environment used to generate bundled interfaces
 export PATH=$save_PATH
 export SAGE_LOCAL=$save_LOCAL
+mkdir -p %{buildroot}%{SAGE_SPKG_INST}
+mkdir -p %{buildroot}%{_libdir}/sagemath/build/pkgs
 
 pushd src
     %__python2 -u ./setup.py build
@@ -837,6 +906,10 @@ pushd build/pkgs/sagenb/src
     %__python2 ./setup.py build
 popd
 
+pushd build/pkgs/sagenb_export/src
+    %__python2 ./setup.py build
+popd
+
 #------------------------------------------------------------------------
 pushd build/pkgs/flintqs/src
     %configure
@@ -881,8 +954,9 @@ export DOT_SAGE=/tmp/sage$$
 mkdir -p $DOT_SAGE/tmp
 
 export PATH=%{buildroot}%{_bindir}:$PATH
-export PYTHONPATH=%{buildroot}%{python_sitearch}:$PYTHONPATH
-export PYTHONPATH=%{_builddir}%{python_sitearch}:$PYTHONPATH
+export PYTHON=%{_bindir}/python2
+export PYTHONPATH=%{buildroot}%{python2_sitearch}:$PYTHONPATH
+export PYTHONPATH=%{_builddir}%{python2_sitearch}:$PYTHONPATH
 
 #------------------------------------------------------------------------
 mkdir -p %{buildroot}%{_bindir}
@@ -917,11 +991,10 @@ popd
 #------------------------------------------------------------------------
 pushd src
 %if %{without install_hack}
-    # FIXME tries to rebuild everything
-    %__python2 -u setup.py install --root=%{buildroot}
+    %py2_install
 %else
-    mkdir -p %{buildroot}%{python_sitearch}
-    cp -far build/lib.linux-*/sage %{buildroot}%{python_sitearch}
+    mkdir -p %{buildroot}%{python2_sitearch}
+    cp -far build/lib.linux-*/sage %{buildroot}%{python2_sitearch}
 %endif
 %if %{with docs}
     # install documentation sources
@@ -932,18 +1005,23 @@ popd
 
 #------------------------------------------------------------------------
 pushd build/pkgs/sagenb/src
-    rm -f %{buildroot}%{python_sitearch}/sagenb/data/sage3d/sage3d
-    %__python2 setup.py install --root=%{buildroot} --install-purelib=%{python_sitearch}
+    rm -f %{buildroot}%{python2_sitearch}/sagenb/data/sage3d/sage3d
+    %py2_install "--install-purelib=%{python2_sitearch}"
     # jsmol
     ln -sf %{_jsdir}/jsmol $SAGE_SHARE/jsmol
     # sage3d
     rm -f %{buildroot}%{_bindir}/sage3d
 %if %{with sage3d}
-    ln -sf %{SAGE_LOCAL}/bin/sage3d %{buildroot}%{python_sitearch}/sagenb/data/sage3d/sage3d
+    ln -sf %{SAGE_LOCAL}/bin/sage3d %{buildroot}%{python2_sitearch}/sagenb/data/sage3d/sage3d
 %endif
-    ln -sf %{python_sitearch}/sagenb %{buildroot}%{SAGE_SRC}/sagenb
+    ln -sf %{python2_sitearch}/sagenb %{buildroot}%{SAGE_SRC}/sagenb
     # use system mathjax
-    ln -sf %{_jsdir}/mathjax %{buildroot}%{python_sitearch}/sagenb/data/mathjax
+    ln -sf %{_jsdir}/mathjax %{buildroot}%{python2_sitearch}/sagenb/data/mathjax
+popd
+
+#------------------------------------------------------------------------
+pushd build/pkgs/sagenb_export/src
+    %py2_install
 popd
 
 #------------------------------------------------------------------------
@@ -1031,9 +1109,14 @@ pushd $SAGE_LOCAL/bin/
     done
 popd
 
+#------------------------------------------------------------------------
+pushd build/pkgs/combinatorial_designs
+    bash ./spkg-install
+popd
+
 #------------------------------------------------------------------------
 pushd build/pkgs/conway_polynomials
-    %__python2 ./spkg-install
+    %__python2 ./spkg-install.py
 popd
 
 #------------------------------------------------------------------------
@@ -1044,7 +1127,7 @@ pushd build/pkgs/elliptic_curves
 	tar jxf ../../../upstream/%{elliptic_curves_pkg}.tar.bz2
 	mv %{elliptic_curves_pkg} src
     fi
-    %__python2 ./spkg-install
+    %__python2 ./spkg-install.py
 popd
 
 #------------------------------------------------------------------------
@@ -1061,10 +1144,8 @@ popd
 
 #------------------------------------------------------------------------
 pushd build/pkgs/sagetex/src
-    %__python2 setup.py install --root=%{buildroot} --install-purelib=%{python_sitearch}
-    install -p -m 0644 -D %{SOURCE2} \
-	%{buildroot}%{_datadir}/texmf/tex/latex/sagetex/makecmds.sty
-    mv %{buildroot}%{_datadir}/texmf/tex/latex/sagetex/CONTRIBUTORS \
+    %py2_install "--install-purelib=%{python2_sitearch}"
+    mv %{buildroot}%{_texmf_main}/tex/latex/sagetex/CONTRIBUTORS \
 	 %{buildroot}%{_docdir}/sagetex
     for file in PKG-INFO README; do
 	install -p -m 0644 $file %{buildroot}%{_docdir}/sagetex/$file
@@ -1073,13 +1154,13 @@ popd
 
 #------------------------------------------------------------------------
 %if %{with bundled_ipython}
-mv %{_builddir}%{python_sitelib}/IPython %{buildroot}%{SAGE_PYTHONPATH}
+mv %{_builddir}%{python2_sitelib}/IPython %{buildroot}%{SAGE_PYTHONPATH}
 mv %{_builddir}%{_bindir}/ip* %{buildroot}%{SAGE_LOCAL}/bin
 %endif
 
 #------------------------------------------------------------------------
 %if %{with bundled_ipywidgets}
-mv %{_builddir}%{python_sitelib}/ipywidgets %{buildroot}%{SAGE_PYTHONPATH}
+mv %{_builddir}%{python2_sitelib}/ipywidgets %{buildroot}%{SAGE_PYTHONPATH}
 %endif
 
 #------------------------------------------------------------------------
@@ -1105,14 +1186,13 @@ module load surf-geometry-%{_arch}
 export PATH=$SAGE_LOCAL/bin:\$PATH
 export SINGULAR_DATA_DIR=%{_datadir}
 export SINGULAR_BIN_DIR=%{_libdir}/Singular
-export SINGULAR_SO=%{_libdir}/libSingular-4.1.0.so
+export SINGULAR_SO=%{_libdir}/libSingular-4.1.1.so
 ##export PYTHONPATH="$SAGE_PYTHONPATH:\$SAGE_LOCAL/bin"
 export SAGE_CBLAS=blas
 export SAGE_FORTRAN=%{_bindir}/gfortran
 export SAGE_FORTRAN_LIB=\`gfortran --print-file-name=libgfortran.so\`
 export SYMPOW_DIR="\$DOT_SAGE/sympow"
-export LC_MESSAGES=C
-export LC_NUMERIC=C
+export LC_ALL=C.UTF-8
 export LD_LIBRARY_PATH=\$SAGE_ROOT/lib:\$LD_LIBRARY_PATH
 # Required for sage -gdb
 export SAGE_DEBUG=no
@@ -1137,17 +1217,17 @@ chmod +x %{buildroot}%{SAGE_LOCAL}/bin/sage3d
 # o install .pxi and .pxd files
 pushd src
     for f in `find sage \( -name \*.pxi -o -name \*.pxd -o -name \*.pyx \)`; do
-	install -p -D -m 0644 $f %{buildroot}%{python_sitearch}/$f
+	install -p -D -m 0644 $f %{buildroot}%{python2_sitearch}/$f
     done
     # need this or will not "find" the files in the directory, and
     # fail to link with gmp
-    touch %{buildroot}%{python_sitearch}/sage/libs/gmp/__init__.py
+    touch %{buildroot}%{python2_sitearch}/sage/libs/gmp/__init__.py
 popd
 
 %if %{with docs}
 #------------------------------------------------------------------------
 %if %{with bundled_pexpect}
-cp -fa $SAGE_PYTHONPATH/pexpect %{buildroot}%{python_sitearch}
+cp -fa $SAGE_PYTHONPATH/pexpect %{buildroot}%{python2_sitearch}
 %endif
 
 # Build documentation, using %#{buildroot} environment
@@ -1158,12 +1238,12 @@ pushd src/doc
     export SINGULARPATH=%{_datadir}/singular/LIB
     export SINGULAR_BIN_DIR=%{_libdir}/Singular
     export LD_LIBRARY_PATH=%{_libdir}/atlas:$LD_LIBRARY_PATH
-    export PYTHONPATH=$SAGE_SETUP:%{buildroot}%{python_sitearch}:$SAGE_PYTHONPATH:$SAGE_DOC
+    export PYTHONPATH=$SAGE_SETUP:%{buildroot}%{python2_sitearch}:$SAGE_PYTHONPATH:$SAGE_DOC
 
 %if %{with sphinx_hack}
     pushd ../../build/pkgs/sphinx/src
-        %__python2 setup.py build
-        %__python2 setup.py install --root %{buildroot} --install-purelib=%{python_sitearch}
+        %py2_build
+        %py2_install "--install-purelib=%{python2_sitearch}"
         rm -f %{buildroot}%{_bindir}/sphinx*
     popd
 %endif
@@ -1193,12 +1273,12 @@ sed -i 's|%{buildroot}||g' $SAGE_DOC/test.log
 %endif
 
 %if %{with bundled_pexpect}
-    rm -f %{buildroot}%{python_sitearch}/pexpect
+    rm -f %{buildroot}%{python2_sitearch}/pexpect
 %endif
 
 %if %{with sphinx_hack}
-    rm -fr %{buildroot}%{python_sitearch}/sphinx \
-	%{buildroot}%{python_sitearch}/Sphinx*
+    rm -fr %{buildroot}%{python2_sitearch}/sphinx \
+	%{buildroot}%{python2_sitearch}/Sphinx*
 %endif
 
 # More wrong buildroot references
@@ -1216,8 +1296,8 @@ perl -pi -e 's|%{buildroot}||g;s|^##||g;' %{buildroot}%{_bindir}/sage
 export SAGE_SRC=%{buildroot}%{SAGE_SRC}
 rm -fr $SAGE_SRC/sage $SAGE_ETC/sage $SAGE_ROOT/doc $SAGE_SRC/doc
 rm -fr $SAGE_ROOT/share $SAGE_ROOT/devel
-ln -sf %{python_sitearch}/sage $SAGE_SRC/sage
-ln -sf %{python_sitearch} $SAGE_ETC/sage
+ln -sf %{python2_sitearch}/sage $SAGE_SRC/sage
+ln -sf %{python2_sitearch} $SAGE_ETC/sage
 ln -sf %{SAGE_DOC} $SAGE_ROOT/doc
 %if %{with docs}
 ln -sf %{SAGE_DOC} $SAGE_SRC/doc
@@ -1259,17 +1339,16 @@ done
 chmod -x %{buildroot}%{SAGE_DOC}/en/prep/media/Rplot001.png
 
 # Documentation is not rebuilt (also corrects rpmlint warning of hidden file)
-find %{buildroot}%{SAGE_DOC} -name .buildinfo -exec rm {} \;
+find %{buildroot}%{SAGE_DOC} -name .buildinfo -exec rm {} \+
 rm -fr %{buildroot}%{SAGE_DOC}/output/inventory
-find %{buildroot}%{SAGE_DOC} -type d -name _sources | xargs rm -fr
-find %{buildroot}%{SAGE_DOC} -name 'core.*' -exec rm {} \;
+find %{buildroot}%{SAGE_DOC} -type d -name _sources -exec rm -fr {} \+
 %endif
 
 # remove .po files
-rm %{buildroot}%{python_sitearch}/sagenb/translations/*/LC_MESSAGES/*.po
+rm %{buildroot}%{python2_sitearch}/sagenb/translations/*/LC_MESSAGES/*.po
 
 %if %{without sage3d}
-rm -r %{buildroot}%{python_sitearch}/sagenb/data/sage3d
+rm -r %{buildroot}%{python2_sitearch}/sagenb/data/sage3d
 %endif
 
 # remove build directory in buildroot
@@ -1278,7 +1357,7 @@ rm -r %{buildroot}%{python_sitearch}/sagenb/data/sage3d
 
 %if %{without install_hack}
 # remove sage_setup
-rm -r %{buildroot}%{python_sitearch}/sage_setup
+rm -r %{buildroot}%{python2_sitearch}/sage_setup
 %endif
 
 # pretend sagemath spkgs are installed to reduce number of errors
@@ -1330,7 +1409,7 @@ rm -fr $DOT_SAGE
 ########################################################################
 %pretrans	-p /usr/bin/lua
 posix = require('posix')
-path = "%{python_sitearch}/sagenb/data/mathjax"
+path = "%{python2_sitearch}/sagenb/data/mathjax"
 st = posix.stat(path)
 if st and st.type == "directory" then
   status = os.rename(path, path .. ".rpmmoved")
@@ -1344,13 +1423,7 @@ if st and st.type == "directory" then
   end
 end
 
-%post		core
-/sbin/ldconfig
-exit 0
-
-%postun		core
-/sbin/ldconfig
-exit 0
+%ldconfig_scriptlets core
 
 %if %{with docs}
 # Upgrade correction for change from directory to symlink
@@ -1369,15 +1442,9 @@ fi
 exit 0
 %endif
 
-%post		sagetex
-%{_bindir}/mktexlsr
-exit 0
+%post		sagetex -p %{_bindir}/mktexlsr
 
-%postun		sagetex
-if [ $1 -eq 0 ] ; then
-    %{_bindir}/mktexlsr
-fi
-exit 0
+%postun		sagetex -p %{_bindir}/mktexlsr
 
 ########################################################################
 %files
@@ -1416,9 +1483,9 @@ exit 0
 #------------------------------------------------------------------------
 %files		core
 # GPLv2+
-%{python_sitearch}/sage
+%{python2_sitearch}/sage
 %if %{without install_hack}
-%{python_sitearch}/sage-*.egg-info
+%{python2_sitearch}/sage-*.egg-info
 %endif
 %if %{with bundled_ipython}
 %{SAGE_PYTHONPATH}/IPython
@@ -1434,6 +1501,11 @@ exit 0
 %{SAGE_ETC}/sage
 %{SAGE_ETC}/gprc.expect
 
+#------------------------------------------------------------------------
+%files		data-combinatorial_designs
+# Public Domain
+%{SAGE_SHARE}/combinatorial_designs
+
 #------------------------------------------------------------------------
 %files		data-conway_polynomials
 # GPLv2+
@@ -1534,69 +1606,75 @@ exit 0
 %{SAGE_ETC}/notebook-ipython
 # GPLv2+
 %{SAGE_SRC}/sagenb
-%dir %{python_sitearch}/sagenb
-%{python_sitearch}/sagenb/*.py*
-%{python_sitearch}/sagenb-*.egg-info
-%dir %{python_sitearch}/sagenb/data
+%dir %{python2_sitearch}/sagenb
+%{python2_sitearch}/sagenb/*.py*
+%{python2_sitearch}/sagenb-*.egg-info
+%dir %{python2_sitearch}/sagenb/data
 # BSD
-%{python_sitearch}/sagenb/data/codemirror
+%{python2_sitearch}/sagenb/data/codemirror
 # MIT
-%{python_sitearch}/sagenb/data/graph_editor
+%{python2_sitearch}/sagenb/data/graph_editor
 # ASL 2.0
-%{python_sitearch}/sagenb/data/highlight
+%{python2_sitearch}/sagenb/data/highlight
 # LGPLv2+
 %{SAGE_SHARE}/jsmol
 # (MIT or GPLv2) and (MIT and BSD and GPL)
-%{python_sitearch}/sagenb/data/jquery
+%{python2_sitearch}/sagenb/data/jquery
 # (MIT or GPLv2) and (MIT and BSD and GPL)
-%{python_sitearch}/sagenb/data/jqueryui
+%{python2_sitearch}/sagenb/data/jqueryui
 # Public Domain
-%{python_sitearch}/sagenb/data/json
+%{python2_sitearch}/sagenb/data/json
 # Symbolic link to $_jsdir/mathjax
-%{python_sitearch}/sagenb/data/mathjax
-%ghost %{python_sitearch}/sagenb/data/mathjax.rpmmoved
+%{python2_sitearch}/sagenb/data/mathjax
+%ghost %{python2_sitearch}/sagenb/data/mathjax.rpmmoved
 # Empty (do not run doctests flag file)
-%{python_sitearch}/sagenb/data/nodoctest.py*
+%{python2_sitearch}/sagenb/data/nodoctest.py*
 # BSD
-%{python_sitearch}/sagenb/data/openid-realselector
+%{python2_sitearch}/sagenb/data/openid-realselector
 # GPLv2+
-%{python_sitearch}/sagenb/data/sage
+%{python2_sitearch}/sagenb/data/sage
 %if %{with sage3d}
 # GPLv2+
-%{python_sitearch}/sagenb/data/sage3d
+%{python2_sitearch}/sagenb/data/sage3d
 %endif
 # LGPLv2+
-%{python_sitearch}/sagenb/data/tiny_mce
+%{python2_sitearch}/sagenb/data/tiny_mce
 # LGPLv2+
-%{python_sitearch}/sagenb/data/zorn
+%{python2_sitearch}/sagenb/data/zorn
 # GPLv2+
-%{python_sitearch}/sagenb/flask_version
+%{python2_sitearch}/sagenb/flask_version
 # GPLv2+
-%{python_sitearch}/sagenb/interfaces
+%{python2_sitearch}/sagenb/interfaces
 # GPLv2+
-%{python_sitearch}/sagenb/misc
+%{python2_sitearch}/sagenb/misc
 # GPLv2+
-%{python_sitearch}/sagenb/notebook
+%{python2_sitearch}/sagenb/notebook
 # GPLv2+
-%{python_sitearch}/sagenb/simple
+%{python2_sitearch}/sagenb/simple
 # GPLv2+
-%{python_sitearch}/sagenb/storage
+%{python2_sitearch}/sagenb/storage
 # GPLv2+
-%dir %{python_sitearch}/sagenb/testing
-%{python_sitearch}/sagenb/testing/*.py*
-%{python_sitearch}/sagenb/testing/tests
+%dir %{python2_sitearch}/sagenb/testing
+%{python2_sitearch}/sagenb/testing/*.py*
+%{python2_sitearch}/sagenb/testing/tests
 # ASL 2.0
-%{python_sitearch}/sagenb/testing/selenium
+%{python2_sitearch}/sagenb/testing/selenium
 # GPLv2+
-%dir %{python_sitearch}/sagenb/translations
-%lang(cs_CZ) %{python_sitearch}/sagenb/translations/cs_CZ
-%lang(de_AT) %{python_sitearch}/sagenb/translations/de_AT
-%lang(de_AT) %{python_sitearch}/sagenb/translations/en_US
-%lang(de_AT) %{python_sitearch}/sagenb/translations/es_ES
-%lang(de_AT) %{python_sitearch}/sagenb/translations/fr_FR
-%lang(pt_BR) %{python_sitearch}/sagenb/translations/pt_BR
-%lang(ru_RU) %{python_sitearch}/sagenb/translations/ru_RU
-%lang(uk_UA) %{python_sitearch}/sagenb/translations/uk_UA
+%dir %{python2_sitearch}/sagenb/translations
+%lang(cs_CZ) %{python2_sitearch}/sagenb/translations/cs_CZ
+%lang(de_AT) %{python2_sitearch}/sagenb/translations/de_AT
+%lang(de_AT) %{python2_sitearch}/sagenb/translations/en_US
+%lang(de_AT) %{python2_sitearch}/sagenb/translations/es_ES
+%lang(de_AT) %{python2_sitearch}/sagenb/translations/fr_FR
+%lang(pt_BR) %{python2_sitearch}/sagenb/translations/pt_BR
+%lang(ru_RU) %{python2_sitearch}/sagenb/translations/ru_RU
+%lang(uk_UA) %{python2_sitearch}/sagenb/translations/uk_UA
+
+#------------------------------------------------------------------------
+%files		notebook-export
+# GPL+
+%{python2_sitelib}/sagenb_export
+%{python2_sitelib}/sagenb_export-*.egg-info
 
 #------------------------------------------------------------------------
 %files		rubiks
@@ -1613,12 +1691,19 @@ exit 0
 #------------------------------------------------------------------------
 %files		sagetex
 # GPLv2+
-%{python_sitearch}/sagetex*
-%{_datadir}/texmf/tex/latex/sagetex
+%{python2_sitearch}/sagetex*
+%{_texmf_main}/tex/latex/sagetex
 %doc %{_docdir}/sagetex
 
 ########################################################################
 %changelog
+* Fri May 18 2018 Jerry James <loganjerry@gmailc.om> - 8.2-1
+- Update to sagemath 8.2
+- Create the sagemath-data-combinatorial_designs subpackage
+- Create the sagemath-notebook-export subpackage
+- Unbundle the LaTeX makecmds style
+- Install LaTeX style files in a more canonical place
+
 * Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 8.0-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
 
diff --git a/sources b/sources
index 0bf7da2..0ed0dd8 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (sage-8.0.tar.gz) = f0a7aaf9fc157b031ceba2d298d74a56bb38f6be5ae4350f91058a24360273f2599c1d50dfe8941e7c462d0a1bf436090da859256fc8e687097e6c419345c493
+SHA512 (sage-8.2.tar.gz) = 32afa401d0c0a825e9507a445de9a5abb19b3f2444c70ae0e5d7fea0fe319f6a43a94e5eee032fd85c21b87487a42d0c70177766dfa6ea1ea42d3a22e1395663
diff --git a/testjava.sh b/testjava.sh
old mode 100755
new mode 100644