initial commit
This commit is contained in:
commit
0c878e279b
24
README.md
Normal file
24
README.md
Normal file
@ -0,0 +1,24 @@
|
||||
# archwiki downloader
|
||||
|
||||
[![works badge](https://cdn.jsdelivr.net/gh/nikku/works-on-my-machine@v0.2.0/badge.svg)](https://github.com/nikku/works-on-my-machine)
|
||||
|
||||
This little script downloads the awesome [Archwiki](https://wiki.archlinux.org) for offline use and installs `wiki-search` and `wiki-search-html` scripts provided by `arch-wiki-lite`.<br>
|
||||
It is meant to be used on fedora (tested on f32) but it shouldn't be too hard to edit it for another distributions.
|
||||
|
||||
### purpose
|
||||
As of now there are no native fedora packages doing this job, this script solves it for me.<br>
|
||||
Inspiration taken from the PKGBUILDs of [arch-wiki-docs](https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/arch-wiki-docs) and [arch-wiki-lite](https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/arch-wiki-lite).
|
||||
|
||||
### deps
|
||||
It comes with just a few dependencies:
|
||||
|
||||
* `python3`
|
||||
* `python3-simplemediawiki`
|
||||
* `python3-cssselect`
|
||||
* `python3-lxml`
|
||||
* `dialog`
|
||||
|
||||
...plus I used `rsync`, feel free to change it to `cp` (and update paths accordingly)
|
||||
|
||||
### license
|
||||
[WTFPL](http://wtfpl.net)
|
67
awdl
Executable file
67
awdl
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
# archwiki downloader
|
||||
# as there's no fedora pkg atm, let's do this ourselves
|
||||
# inspiration taken from PKGBUILDs of arch-wiki-docs and arch-wiki-lite
|
||||
# https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/arch-wiki-docs
|
||||
# https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/arch-wiki-lite
|
||||
#
|
||||
# deps: python3 python3-simplemediawiki python3-cssselect python3-lxml dialog
|
||||
# plus I used rsync, feel free to change it to cp (and some paths accordingly)
|
||||
#
|
||||
# author of this little script
|
||||
# -- wanderer
|
||||
# https://dotya.ml/contact/
|
||||
# license: wtfpl
|
||||
|
||||
echo -e "archwiki downloader"
|
||||
if [ $(id -u) != 0 ]; then
|
||||
echo "[x] not root, not running, sorry"
|
||||
exit 9001
|
||||
fi
|
||||
|
||||
deps=("python3" "python3-simplemediawiki" "python3-cssselect" "python3-lxml" "dialog" "rsync")
|
||||
|
||||
echo "[*] checking deps"
|
||||
for pkg in "${deps[@]}"; do
|
||||
dnf list installed $pkg > /dev/null 2>&1
|
||||
if [ $(echo $?) -eq 1 ]; then
|
||||
echo "[x] package \"$pkg\" could not be found"
|
||||
echo "[i] you can install the dependencies with the following command"
|
||||
echo "dnf install ${deps[*]}"
|
||||
echo "[*] exiting now" && exit 9001
|
||||
fi
|
||||
done
|
||||
|
||||
dest_html=/usr/share/doc/arch-wiki/html/
|
||||
dest_text=/usr/share/doc/arch-wiki/text/
|
||||
mkdir -pv $dest_html
|
||||
mkdir -pv $dest_text
|
||||
|
||||
mktemp -d && cd /tmp/$(ls -t /tmp | grep tmp. | head -1)
|
||||
workdir=$(pwd)
|
||||
mkdir -pv $workdir/build_wiki
|
||||
mkdir -pv /etc/dialog.d/
|
||||
|
||||
echo "[*] getting sources"
|
||||
curl http://kmkeen.com/arch-wiki-lite/arch-wiki-lite.tar.gz | bsdtar xfv -
|
||||
git clone https://github.com/lahwaacz/arch-wiki-docs.git
|
||||
|
||||
echo "[*] getting archwiki files"
|
||||
cd $workdir/arch-wiki-docs
|
||||
LANG=en_US.UTF-8 python3 arch-wiki-docs.py --output-directory $workdir/build_wiki --clean --safe-filenames
|
||||
rsync -auvP build_wiki/ $dest_html
|
||||
|
||||
echo "[*] generating text file"
|
||||
cd $workdir/arch-wiki-lite
|
||||
LC_ALL=en_US.UTF-8 python3 wiki_lite.py
|
||||
rsync -auvP wiki/ $dest_text
|
||||
rsync -auvP wiki-search wiki-search-html /bin/
|
||||
chmod -v 0755 /bin/wiki-search
|
||||
chmod -v 0755 /bin/wiki-search-html
|
||||
rsync -auvP wiki-search.dialog.rc /etc/dialog.d/
|
||||
|
||||
echo "[*] done, removing workdir"
|
||||
cd $workdir/../
|
||||
trap "rm -rfv $workdir" 0 1 3 15 9001
|
||||
exit $?
|
Loading…
Reference in New Issue
Block a user