Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
packaging: adding bundled for JS libraries
Browse files Browse the repository at this point in the history
To ease up maintenance, we should add a `Provides: bundled(JS) =
VERSION` line for each JS library. This commit uses yarn to list all
dependencies.

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola committed Jan 9, 2018
1 parent d0f292c commit f08803b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packaging/suse/make_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ year=$(date +%Y)

mkdir -p build/$packagename-$branch
cp -v ../../Gemfile* build/$packagename-$branch
cp -v ../../yarn.lock build/$packagename-$branch
if ls patches/*.patch >/dev/null 2>&1 ;then
cp -v patches/*.patch build/$packagename-$branch
fi
Expand Down Expand Up @@ -120,12 +121,23 @@ pushd build/$packagename-$branch/
build_requires="$build_requires\nBuildRequires: %{rubygem $gem_name} = $gem_version"
build_requires="$build_requires$(additional_native_build_requirements $gem_name)"
done

# Extract the JS dependencies. Yarn will list dependencies in the following
# format (when in depth=0): "├─ NAME@VERSION". So, we have to replace @ by an
# empty space, and this way we'll be able to awk it away.
js_provides="# Provides extracted from the yarn.lock file."
for js in $(NODE_ENV=production yarn -s list --depth=0 | tr "@" " "); do
js_name=$(echo $js | awk '{ print $2 }')
js_version=$(echo $js | awk '{ print $3 }')
js_provides="$js_provides\nProvides: bundled($js_name) = $js_version"
done
popd

debug "Creating ${packagename}.spec based on ${packagename}.spec.in"
cp ${packagename}.spec.in ${packagename}.spec
sed -e "s/__BRANCH__/$branch/g" -i ${packagename}.spec
sed -e "s/__RUBYGEMS_BUILD_REQUIRES__/$build_requires/g" -i ${packagename}.spec
sed -e "s/__NODEJS_BUILD_PROVIDES__/$js_provides/g" -i ${packagename}.spec
sed -e "s/__DATE__/$date/g" -i ${packagename}.spec
sed -e "s/__COMMIT__/$commit/g" -i ${packagename}.spec
sed -e "s/__VERSION__/$version/g" -i ${packagename}.spec
Expand Down
2 changes: 2 additions & 0 deletions packaging/suse/portus.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ BuildRequires: %{rubygem gem2rpm}

__RUBYGEMS_BUILD_REQUIRES__

__NODEJS_BUILD_PROVIDES__

BuildRoot: %{_tmppath}/%{name}-%{version}-build

%description
Expand Down

0 comments on commit f08803b

Please sign in to comment.