Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include 3rd party Javascript and CSS libs in rpm #65

Merged
merged 1 commit into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting started
### Install the server
1. Spin up a clean VM running Fedora 28, 27, RHEL 7, or CentOS 7
1. Spin up a clean VM running Fedora 29, 28, RHEL 7, or CentOS 7
2. If you're using RHEL or CentOS, you need to [enable the EPEL package repository](https://fedoraproject.org/wiki/EPEL).
3. Configure the package repository:
```
Expand Down
23 changes: 18 additions & 5 deletions rpm/buildrpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,31 @@ export GIT_BRANCH=`echo $GIT_BRANCH | sed 's#.*/##'`
echo "buildrpm: The git branch is $GIT_BRANCH"
sed -i -e "s|%{getenv:GIT_BRANCH}|$GIT_BRANCH|g" $SPEC

# Check the spec file for errors
rpmlint -i -f "$SOURCEDIR/rpmlint.conf" $SPEC || exit 1
# Check the spec file for errors.
# rpmlint uses http HEAD requests to verify the source urls.
# Some web servers are misconfigured and return 403 (forbidden) for HEAD, even though GET works.
# Here we avoid false warnings by disabling networking.
rpmlint -i -f "$SOURCEDIR/rpmlint.conf" -o "NetworkEnabled False" $SPEC || exit 1

echo "buildrpm: Downloading source archive files"
# Use spectool to download the source files
echo "buildrpm: Downloading source files"
cd $BUILDDIR/SOURCES
spectool -gf $SPEC > /dev/null 2>&1
if [[ $(ls -1 $BUILDDIR/SOURCES | wc -l) -ne $(grep Source $SPEC|grep tar.gz| wc -l) ]]; then
echo "buildrpm: Didn't manage to produce the source archive files."
if [ "$2" != "" ]; then
# If we are about to replace the main source package with local files anyway,
# then put a placeholder file for the source file.
# This is useful in case you're working on a new branch that has not yet
# been pushed to Github, because in that case the download doesn't work.
touch $BUILDDIR/SOURCES/$GIT_BRANCH.tar.gz
fi
# Count the downloaded files to see if it worked. As an additional measure.
if [[ $(ls -1 $BUILDDIR/SOURCES | wc -l) -ne $(grep Source $SPEC | grep http | wc -l) ]]; then
echo "buildrpm: Didn't manage to produce the source files."
rpmbuild --nobuild --nodeps $SPEC
exit 1
fi

# Replace the main source package with local files
if [ "$2" != "" ]; then
cd $2
echo "buildrpm: Replacing with source from $(pwd)"
Expand Down
38 changes: 36 additions & 2 deletions rpm/nivlheim.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Source0: https://github.com/usit-gd/nivlheim/archive/%{getenv:GIT_BRANCH}.tar.g
Source1: https://github.com/lib/pq/archive/master.tar.gz#/pq-master.tar.gz
Source2: https://github.com/golang/oauth2/archive/master.tar.gz#/oauth2-master.tar.gz
Source3: https://github.com/golang/net/archive/master.tar.gz#/net-master.tar.gz
Source4: https://github.com/jquery/jquery/archive/3.3.1.tar.gz
Source5: https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.12/handlebars.runtime.min.js
Source6: https://github.com/moment/moment/archive/2.22.2.tar.gz
Source7: https://github.com/jgthms/bulma/releases/download/0.7.2/bulma-0.7.2.zip
Source8: https://github.com/CodeYellowBV/tarantino/archive/v2.1.0.tar.gz
Source9: https://use.fontawesome.com/releases/v5.2.0/fontawesome-free-5.2.0-web.zip
Source10: https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE

BuildRequires: npm(handlebars)
BuildRequires: perl(Archive::Tar)
Expand Down Expand Up @@ -114,6 +121,18 @@ This package contains the server components of Nivlheim.
%setup -q -T -b 1 -n pq-master
%setup -q -T -b 2 -n oauth2-master
%setup -q -T -b 3 -n net-master
%setup -q -T -b 4 -n jquery-3.3.1
%setup -q -T -b 6 -n moment-2.22.2
%setup -q -T -b 8 -n tarantino-2.1.0
cd %{_builddir}
rm -rf bulma-0.7.2 fontawesome-free-5.2.0-web
unzip -q %{SOURCE7}
unzip -q %{SOURCE9}
mkdir -p fontawesome/css
mv fontawesome-free-5.2.0-web/webfonts fontawesome/
mv fontawesome-free-5.2.0-web/css/all.css fontawesome/css/
mv fontawesome-free-5.2.0-web/LICENSE.txt fontawesome/
chmod -R a+rX,g-w,o-w bulma-0.7.2 fontawesome
%autosetup -D -n %{name}-%{getenv:GIT_BRANCH}

# disable building of the debug package.
Expand Down Expand Up @@ -153,7 +172,7 @@ mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d
mkdir -p %{buildroot}%{_localstatedir}/nivlheim
mkdir -p %{buildroot}/var/www/nivlheim
mkdir -p %{buildroot}/var/www/cgi-bin/secure
mkdir -p %{buildroot}/var/www/html
mkdir -p %{buildroot}/var/www/html/libs
mkdir -p %{buildroot}/var/log/nivlheim
mkdir -p %{buildroot}%{_unitdir}
install -p -m 0755 client/nivlheim_client %{buildroot}%{_sbindir}/
Expand All @@ -171,8 +190,20 @@ install -p -m 0755 server/setup.sh %{buildroot}%{_localstatedir}/nivlheim/
install -p -m 0755 server/cgi/processarchive %{buildroot}/var/www/cgi-bin/
install -p -m 0644 server/nivlheim.service %{buildroot}%{_unitdir}/%{name}.service
install -p -m 0644 -D client/cronjob %{buildroot}%{_sysconfdir}/cron.d/nivlheim_client
rm -rf server/website/mockapi server/website/templates
rm -rf server/website/mockapi server/website/templates server/website/libs
cp -a server/website/* %{buildroot}%{_localstatedir}/www/html/
install -p -m 0644 ../jquery-3.3.1/dist/jquery.min.js %{buildroot}%{_localstatedir}/www/html/libs/jquery-3.3.1.min.js
install -p -m 0644 ../jquery-3.3.1/LICENSE.txt %{buildroot}%{_localstatedir}/www/html/libs/jquery-license.txt
install -p -m 0644 %{SOURCE5} %{buildroot}%{_localstatedir}/www/html/libs/handlebars.min.js
install -p -m 0644 %{SOURCE10} %{buildroot}%{_localstatedir}/www/html/libs/handlebars-license.txt
install -p -m 0644 ../moment-2.22.2/min/moment.min.js %{buildroot}%{_localstatedir}/www/html/libs/
install -p -m 0644 ../moment-2.22.2/LICENSE %{buildroot}%{_localstatedir}/www/html/libs/moment-license.txt
install -p -m 0644 ../bulma-0.7.2/css/bulma.min.css %{buildroot}%{_localstatedir}/www/html/libs/
install -p -m 0644 ../bulma-0.7.2/LICENSE %{buildroot}%{_localstatedir}/www/html/libs/bulma-license.txt
install -p -m 0644 ../tarantino-2.1.0/build/tarantino.min.js %{buildroot}%{_localstatedir}/www/html/libs/
install -p -m 0644 ../tarantino-2.1.0/LICENSE %{buildroot}%{_localstatedir}/www/html/libs/tarantino-license.txt
cp -a ../fontawesome %{buildroot}%{_localstatedir}/www/html/libs
chmod 755 %{buildroot}%{_localstatedir}/www/html/libs
install -p -m 0755 gopath/bin/service %{buildroot}%{_sbindir}/nivlheim_service
cp -a server/database/* %{buildroot}%{_localstatedir}/nivlheim/
echo %{version} > %{buildroot}%{_sysconfdir}/nivlheim/version
Expand Down Expand Up @@ -229,6 +260,9 @@ rm -rf %{buildroot}
%systemd_postun_with_restart %{name}.service

%changelog
* Tue Dec 11 2018 Øyvind Hagberg <[email protected]> - 0.11.0-20181211
- Include 3rd party javascript and css libraries in the rpm file

* Tue Aug 7 2018 Øyvind Hagberg <[email protected]> - 0.9.0-20180807
- Added sources for Go package golang.org/x/oauth2 and its dependencies

Expand Down
2 changes: 1 addition & 1 deletion server/service/api_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (vars *apiMethodHost) serveGET(w http.ResponseWriter, req *http.Request, ac
res["osEdition"] = jsonString(osEdition)
}
if fields["osFamily"] {
res["osFamily"] = jsonString(os)
res["osFamily"] = jsonString(osFamily)
}
if fields["kernel"] {
res["kernel"] = jsonString(kernel)
Expand Down
4 changes: 0 additions & 4 deletions server/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ if [ `whoami` != "root" ]; then
exit 1
fi

# download 3rd party Javascript and CSS libraries
cd /var/www/html/libs
./download_libraries.sh --prod && rm ./download_libraries.sh

# make dirs
mkdir -p /var/www/nivlheim/{db,certs,CA,queue}

Expand Down
23 changes: 4 additions & 19 deletions server/website/libs/download_libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,22 @@
# As a developer, you can run this script to download the libraries
# into the libs/ folder.


# <script src="https://code.jquery.com/jquery-3.3.1.min.js"
# integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
# crossorigin="anonymous"></script>
# <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.min.js"></script>
# <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
# <script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
# <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css">

set -e
cd `dirname $0`
echo "Downloading Javascript and CSS libraries into `pwd`"
OPTS="-sSfO --retry 10"
OPTS="-sSfOL --retry 10"

# clean
rm -rf *.js *.css *.map fontawesome*

echo "Handlebars"
if [[ "$1" == "--prod" ]]; then
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.runtime.min.js
mv handlebars.runtime.min.js handlebars.min.js
else
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.min.js
fi
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.12/handlebars.min.js
echo "jQuery"
curl $OPTS https://code.jquery.com/jquery-3.3.1.min.js
echo "Moment"
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js
echo "Bulma"
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css.map
curl $OPTS https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css
echo "Tarantino"
curl $OPTS https://raw.githubusercontent.com/CodeYellowBV/tarantino/master/build/tarantino.min.js

Expand Down