diff --git a/README.md b/README.md index 01eb0fa..6506111 100644 --- a/README.md +++ b/README.md @@ -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: ``` diff --git a/rpm/buildrpm.sh b/rpm/buildrpm.sh index 84ed0fa..2ef5a7c 100755 --- a/rpm/buildrpm.sh +++ b/rpm/buildrpm.sh @@ -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)" diff --git a/rpm/nivlheim.spec b/rpm/nivlheim.spec index 8cb8275..f0bc6ff 100644 --- a/rpm/nivlheim.spec +++ b/rpm/nivlheim.spec @@ -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) @@ -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. @@ -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}/ @@ -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 @@ -229,6 +260,9 @@ rm -rf %{buildroot} %systemd_postun_with_restart %{name}.service %changelog +* Tue Dec 11 2018 Øyvind Hagberg - 0.11.0-20181211 +- Include 3rd party javascript and css libraries in the rpm file + * Tue Aug 7 2018 Øyvind Hagberg - 0.9.0-20180807 - Added sources for Go package golang.org/x/oauth2 and its dependencies diff --git a/server/service/api_host.go b/server/service/api_host.go index 8371f27..ded35e9 100644 --- a/server/service/api_host.go +++ b/server/service/api_host.go @@ -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) diff --git a/server/setup.sh b/server/setup.sh index 1b2e1c3..6bc310c 100644 --- a/server/setup.sh +++ b/server/setup.sh @@ -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} diff --git a/server/website/libs/download_libraries.sh b/server/website/libs/download_libraries.sh index 3777f15..3b461e2 100755 --- a/server/website/libs/download_libraries.sh +++ b/server/website/libs/download_libraries.sh @@ -8,37 +8,22 @@ # As a developer, you can run this script to download the libraries # into the libs/ folder. - -# -# -# -# -# - 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