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

WIP: init jekyll upgrade #3181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions generator/_config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#auto: true
safe: false
#include: ./pages/
plugins: ./_plugins/
plugins:
- ./_plugins/category_nav.rb
- ./_plugins/CfeLiquidUtils.rb
- ./_plugins/cfengineAddons.rb
- ./_plugins/CfeUtils.rb
- ./_plugins/debug.rb
- ./_plugins/gentagspages.rb
- ./_plugins/jekyll_asset_pipeline.rb
- ./_plugins/navigation.rb
- ./_plugins/redcarpet2_markdown.rb
- ./_plugins/references.rb
- ./_plugins/sitemap_generator.rb
# baseurl: /docs/master/
git-repository: github.com/cfengine/documentation
git-branch: "3.23"
Expand Down Expand Up @@ -39,7 +50,7 @@ virtualbox:
paginate: 500

pygments: true
markdown: redcarpet2
markdown: kramdown
redcarpet:
extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "strikethrough", "superscript", "tables"]
asset_pipeline:
Expand Down
2 changes: 1 addition & 1 deletion generator/_plugins/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def read_yaml(base, name)

# only alter markdown files
md_class = ((defined? MarkdownConverter) ? MarkdownConverter : Jekyll::Converters::Markdown)
return unless converter.instance_of? md_class
return unless defined?(converter) && converter.instance_of?(md_class)

# read and cache content of _references.md
if @@refs_content.nil?
Expand Down
14 changes: 1 addition & 13 deletions generator/_scripts/_run_jekyll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,14 @@ rm -rf $WRKDIR/documentation/generator/pages/generator
find $WRKDIR/documentation/generator/pages -type f -name "*.markdown" -exec grep -l '^published: false$' {} + | xargs rm -f
cd $WRKDIR/documentation/generator

# rvm commands are insane scripts which pollut output
# so instead of set -x we just echo each command ourselves
set +x
if [ -e "/home/jenkins/.rvm/scripts/rvm" ]; then
echo "+ /home/jenkins/.rvm/scripts/rvm"
source /home/jenkins/.rvm/scripts/rvm
elif [ -e "$HOME/.rvm/scripts/rvm" ]; then
echo "+ $HOME/.rvm/scripts/rvm"
source $HOME/.rvm/scripts/rvm
else
echo "ERROR: I couldn't source rvm from '/home/jenkins/.rvm/scripts/rvm' or '\$HOME/.rvm/scripts/rvm', probably jekyll won't work"
fi

echo "Latest jekyll run :$BUILD_ID" > $WRKDIR/output.log
echo "Based on latest git commit :$GIT_COMMIT" >> $WRKDIR/output.log
echo "*********************************************************" >> $WRKDIR/output.log
echo "* CONSOLE OUTPUT *" >> $WRKDIR/output.log
echo "*********************************************************" >> $WRKDIR/output.log
set -x
jekyll
$(which jekyll) build
if [ "$?" -gt "0" ]; then
exit 1;
fi
Expand Down
115 changes: 21 additions & 94 deletions generator/build/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,116 +3,43 @@
set -ex

# All of these commands are executed by the jenkins user.

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install -y curl gnupg2 wget git

# some of packages below depend on tzdata. Installing it without DEBIAN_FRONTEND=noninteractive causes it to ask where in the world are you, interrupting the build process
# some of packages below depend on tzdata. Installing it without DEBIAN_FRONTEND=noninteractive causes it to ask where
# in the world are you, interrupting the build process
DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND apt-get install -y tzdata

# Docslave specifics
# These packages are needed as a dependency of the nokogiri ruby gem (which in turn is a dependency of the sanitize ruby gem).

sudo apt-get install -y libxslt-dev libxml2-dev

# Python is needed for our pre and post processing scripts.
sudo apt-get install -y libxslt-dev libxml2-dev ruby ruby-dev rubygems build-essential python3

echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Python is needed for our pre and post processing scripts.
sudo apt-get install -y python3

# These packages are needed to satisfy rvm requirements.
sudo apt-get install -y gawk g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev \
libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev

# hint: to figure out rvm requirements, comment this line and watch output of `rvm install ... ruby`.
# To make script stop at that command, change --autolibs argument to read-fail.
# Also you likely will want to exclude 'libssl1.0-dev' since it's and openssl 1.0 library, which is not shipped on modern distros.
sudo apt-get install -y gawk g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev
sudo apt-get install -y python3-pygments

# We currently use pygments for syntax highlighting. Jekyll 0.12.1 errors during install without this.
sudo apt-get install -y default-jdk

sudo apt-get install -y python3-pygments

# yui-compressor (ruby gem dependency) is written in java, so we need to install it.
sudo gem install jekyll jekyll_asset_pipeline jekyll-paginatege read_yaml closure-compiler bundler closure-compiler \
yui-compressor albino execjs redcarpet uglifier sanitize

sudo apt-get install -y default-jdk

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - && sudo apt-get install -y nodejs

$(which node) --version
$(which npm) --version
$(which jekyll) --version
$(which ruby) --version

## Install RVM and Ruby
## RVM helps us manage the ruby dependencies and ruby versions in a contained way.

# Install mpapis public key (might need `gpg2` and or `sudo`)
#keyserver=keys.gnupg.net
keyserver=keyserver.ubuntu.com
gpg2 --keyserver hkps://$keyserver --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

echo "Downloading and installing Ruby Version Manager"
# Download the installer
curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer
curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer.asc

if gpg2 --verify rvm-installer.asc; then
bash rvm-installer --autolibs=read-fail --ignore-dotfiles stable
else
echo "Ruby Version Manager signature check fail."
echo "Github is hacked, or trying to hack us, or our script is wrong. Aborting everything"
exit 1
fi

# rvm commands are insane scripts which pollut output
# so instead of set -x we just echo each command ourselves
set +x
echo "+ source ~/.rvm/scripts/rvm"
# shellcheck disable=SC1090
source ~/.rvm/scripts/rvm

echo "+ rvm_rubygems_version=none rvm install --autolibs=read-only ruby-1.9.3-p551 -C --without-openssl"
rvm_rubygems_version=none rvm install --autolibs=read-only ruby-1.9.3-p551 -C --without-openssl

gem install jekyll --version 0.12.1
gem install jekyll-asset-pipeline --version 0.1.6
gem install closure-compiler --version 1.1.8
gem install yui-compressor --version 0.9.6
gem install albino --version 1.3.3
gem install execjs --version 1.4.0
gem install redcarpet --version 2.2.2
gem install uglifier --version 1.3.0
gem install sanitize --version 2.0.3

cat > /tmp/jekyll-0.12.1-cfengine.patch <<EOF
--- page.rb 2016-09-09 14:52:17.329751803 +0000
+++ page.rb.cfengine 2016-09-09 15:00:06.813929546 +0000
@@ -129,6 +129,26 @@
# Returns nothing.
def write(dest)
path = destination(dest)
+
+ #+Caption: CFEngine Customization to Jekyll 0.12.1
+ #+BEGIN_SRC ruby
+ # Added by: Dmitry
+ if site.config['CFE_OUTPUT'] == true && site.config['CFE_DIR'] !=''
+ dest = File.join(@base, site.config['CFE_DIR'])
+ if (self.data['alias'] !=nil)
+ path = File.join(dest, CGI.unescape(self.data['alias']))
+ else
+ path = File.join(dest, CGI.unescape(self.url))
+ end
+ path = File.join(path, "index.html") if self.data['alias'] =~ /\/$/
+
+ else
+ # use standard jekyll
+ path = destination(dest)
+ end
+ #+END_SRC
+
+
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
f.write(self.output)
EOF

cd /home/jenkins/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-0.12.1/lib/jekyll/
patch -b page.rb < /tmp/jekyll-0.12.1-cfengine.patch

curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install -y nodejs
node --version
npm --version
14 changes: 0 additions & 14 deletions generator/build/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,6 @@ echo "branch: $BRANCH" >> "$WRKDIR"/documentation/generator/_config.yml
# so instead of set -x we just echo each command ourselves
set +x

# since May 14 2019, we need this to run jekyll. IDK why.
echo "+ source ~/.rvm/scripts/rvm"
# shellcheck disable=SC1090
source ~/.rvm/scripts/rvm
echo "+ rvm --default use 1.9.3-p551"
rvm --default use 1.9.3-p551
echo "+ source ~/.profile"
ls -lah ~
# shellcheck disable=SC1090
test -f ~/.profile && source ~/.profile
echo "+ source ~/.rvm/scripts/rvm"
# shellcheck disable=SC1090
source ~/.rvm/scripts/rvm

export LC_ALL=C.UTF-8

# finally, run actual jekyll
Expand Down
Loading