diff --git a/package.json b/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9341ddcde234e847c838bf83619930de49dc97d0 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "license-checker": "^25.0.1" + } +} diff --git a/prepare_vendor.sh b/prepare_vendor.sh new file mode 100755 index 0000000000000000000000000000000000000000..9a4b622924b60cd3c51fe26775b3c48c345aaf12 --- /dev/null +++ b/prepare_vendor.sh @@ -0,0 +1,102 @@ +#!/bin/bash +yum -y install nodejs-yarn spectool rpm-build + +PKG_URL=$(spectool *.spec --source 0 | sed -e 's/Source0:[ ]*//g') +PKG_TARBALL=$(basename $PKG_URL) +PKG_NAME=$(rpmspec -q --queryformat="%{NAME}" *.spec --srpm | sed 's/^python-//') +PKG_VERSION=$(rpmspec -q --queryformat="%{VERSION}" *.spec --srpm) +PKG_SRCDIR="${PKG_NAME}-${PKG_VERSION}" +PKG_DIR="$PWD" +PKG_TMPDIR=$(mktemp --tmpdir -d ${PKG_NAME}-XXXXXXXX) +PKG_PATH="$PKG_TMPDIR/$PKG_SRCDIR/" + +echo "URL: $PKG_URL" +echo "TARBALL: $PKG_TARBALL" +echo "NAME: $PKG_NAME" +echo "VERSION: $PKG_VERSION" +echo "PATH: $PKG_PATH" + +cleanup_tmpdir() { + popd 2>/dev/null + rm -rf $PKG_TMPDIR + rm -rf /tmp/yarn--* +} +trap cleanup_tmpdir SIGINT + +cleanup_and_exit() { + cleanup_tmpdir + if test "$1" = 0 -o -z "$1" ; then + exit 0 + else + exit $1 + fi +} + +if [ ! -w "$PKG_TARBALL" ]; then + wget "$PKG_URL" +fi + + +mkdir -p $PKG_TMPDIR +tar -xf $PKG_TARBALL -C $PKG_TMPDIR + +cd $PKG_PATH + +export YARN_CACHE_FOLDER="$PWD/.package-cache" +echo ">>>>>> Install npm modules" +rm package-lock.json +yarn install +if [ $? -ne 0 ]; then + echo "ERROR: yarn install failed" + cleanup_and_exit 1 +fi + +echo ">>>>>> Cleanup object dirs" +find node_modules/ -type d -name "*.o.d" -execdir rm {} + +find node_modules/ -type d -name "__pycache__" -execdir rm {} + + +echo ">>>>>> Cleanup object files" +find node_modules/ -name "*.node" -execdir rm {} + + +find node_modules/ -name "*.dll" | grep -Fv signal-client | xargs rm -f +find node_modules/ -name "*.dylib" -delete +find node_modules/ -name "*.so" -delete +find node_modules/ -name "*.o" -delete +find node_modules/ -name "*.a" -delete +find node_modules/ -name "*.snyk-*.flag" -delete + +echo ">>>>>> Cleanup build info" +find node_modules/ -name "builderror.log" -delete +find node_modules/ -name "yarn-error.log" -delete +find node_modules/ -name "yarn.lock" -delete +find node_modules/ -name ".deps" -type d -execdir rm {} + +find node_modules/ -name "Makefile" -delete +find node_modules/ -name "*.target.mk" -delete +find node_modules/ -name "config.gypi" -delete +find node_modules/ -name "package.json" -exec sed -i "s#$PKG_PATH#/tmp#g" {} \; + +echo ">>>>>> Cleanup yarn tarballs" +find node_modules/ -name ".yarn-tarball.tgz" -delete + +echo ">>>>>> Cleanup source maps" +find node_modules/ -name "*.js.map" -delete +find node_modules/ -name "*.ts.map" -delete +find node_modules/ -name "*.mjs.map" -delete +find node_modules/ -name "*.cjs.map" -delete +find node_modules/ -name "*.css.map" -delete +find node_modules/ -name "*.min.map" -delete + +echo ">>>>>> Package vendor files" +rm -f $PKG_DIR/${PKG_NAME}-${PKG_VERSION}-vendor.tar.xz +XZ_OPT="-9e -T$(nproc)" tar cJf $PKG_DIR/${PKG_NAME}-${PKG_VERSION}-vendor.tar.xz .package-cache +if [ $? -ne 0 ]; then + cleanup_and_exit 1 +fi + +yarn add license-checker +yarn license-checker --summary | sed "s#$PKG_PATH#/tmp#g" > $PKG_DIR/${PKG_NAME}-${PKG_VERSION}-vendor-licenses.txt + +cd - + +rm -rf .package-cache +cleanup_and_exit 0 diff --git a/python-sphinx_book_theme.spec b/python-sphinx_book_theme.spec new file mode 100644 index 0000000000000000000000000000000000000000..b6df6cebc79c45f3c6d02ae90359d373c247c2bc --- /dev/null +++ b/python-sphinx_book_theme.spec @@ -0,0 +1,77 @@ +%global _empty_manifest_terminate_build 0 +%global pypi_name sphinx_book_theme + +%global _description %{expand: +A Sphinx theme with a clean design, support for interactive content, and a modern book-like look and feel.} +Name: python-%{pypi_name} +Version: 1.1.3 +Release: 1 +Summary: A clean book theme for scientific explanations and documentation with Sphinx +License: BSD +URL: https://github.com/executablebooks/sphinx-book-theme +Source0: %{url}/archive/v%{version}/%{pypi_name}-%{version}.tar.gz +# Source1 and Source2 created with ./prepare_vendor.sh +Source1: %{pypi_name}-%{version}-vendor.tar.xz +Source2: %{pypi_name}-%{version}-vendor-licenses.txt + +BuildArch: noarch +BuildRequires: nodejs-devel +BuildRequires: nodejs-yarn +BuildRequires: npm +BuildRequires: python3-devel +BuildRequires: python3-pip +BuildRequires: python3-wheel +BuildRequires: python3-setuptools +BuildRequires: python3-setuptools_scm +BuildRequires: python3-sphinx-theme-builder +BuildRequires: python3-pyproject-metadata +BuildRequires: python3-nodeenv +BuildRequires: python3-sphinx +BuildRequires: python3-pydata-sphinx-theme + +%description %_description + +%package -n python3-%{pypi_name} +Summary: A clean book theme for scientific explanations and documentation with Sphinx +%{?python_provide:%python_provide python3-%{pypi_name}} + +%description -n python3-%{pypi_name} %_description + +%package help +Summary: Help documents for %{name} + +%description help +Help documents for the %{name} API + +%prep +%autosetup -n sphinx-book-theme-%{version} -p1 -a1 +cp -p %{SOURCE2} . + +# Don't ship version control files +find . -name .gitignore -delete + +# Substitute the installed nodejs version for the requested version +sed -i 's,^\(node-version = \)".*",\1"%{nodejs_version}",' pyproject.toml + +%build +export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 +export YARN_CACHE_FOLDER="$PWD/.package-cache" +yarn install +nodeenv --node=system --prebuilt --clean-src $PWD/.nodeenv +%pyproject_build + +%install +%pyproject_install + +%files -n python3-%{pypi_name} +%license LICENSE +%doc README.md ARCHITECTURE.md CHANGELOG.md CONTRIBUTING.md +%{python3_sitelib}/sphinx_book_theme +%{python3_sitelib}/sphinx_book_theme-*.dist-info/ + +%files help +%doc docs + +%changelog +* Mon Nov 4 2024 Dongxing Wang - 1.1.3-1 +- Package init diff --git a/sphinx_book_theme-1.1.3-vendor-licenses.txt b/sphinx_book_theme-1.1.3-vendor-licenses.txt new file mode 100644 index 0000000000000000000000000000000000000000..6bf4a799a33aa3a220a4104566d16c285483808e --- /dev/null +++ b/sphinx_book_theme-1.1.3-vendor-licenses.txt @@ -0,0 +1,12 @@ +yarn run v1.22.19 +$ /opt/appFac/python-sphinx-book-theme/node_modules/.bin/license-checker --summary +├─ MIT: 32 +├─ ISC: 19 +├─ Apache-2.0: 2 +├─ BSD-3-Clause: 1 +├─ BSD-2-Clause: 1 +├─ CC-BY-3.0: 1 +├─ CC0-1.0: 1 +└─ (MIT AND CC-BY-3.0): 1 + +Done in 1.18s. diff --git a/sphinx_book_theme-1.1.3-vendor.tar.xz b/sphinx_book_theme-1.1.3-vendor.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..1cd8f8617b331b641078593c1a1b30de949395f7 Binary files /dev/null and b/sphinx_book_theme-1.1.3-vendor.tar.xz differ diff --git a/sphinx_book_theme-1.1.3.tar.gz b/sphinx_book_theme-1.1.3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..aed59849395eaa40f7805d5f259f0b411147fb62 Binary files /dev/null and b/sphinx_book_theme-1.1.3.tar.gz differ