Automatically installing the latest Quarto version - quarto

I use a Quarto script to render my blog in Python. Quarto frequently updates, and I want to automatically install the latest version so I can have a script that automatically updates Quarto before rendering my blog.
How can I do this?

This is another example leveraging latest github release and gh CLI
gh --repo quarto-dev/quarto-cli release download --pattern '*.deb'
sudo dpkg -i $(ls quarto-*.deb)
rm $(ls quarto-*.deb)
This could be adapted to any repo with Github release.
Using _download.json is the safest though, especially when stable release of Quarto will be out.

For my own blog, I use the script below:
wget https://quarto.org/docs/download/_download.json
ver=$(grep -o '"version": "[^"]*' _download.json | grep -o '[^"]*$')
wget https://github.com/quarto-dev/quarto-cli/releases/download/v${ver}/quarto-${ver}-linux-amd64.deb
sudo dpkg -i quarto-${ver}-linux-amd64.deb
rm quarto-${ver}-linux-amd64.deb
rm _download.json
It takes advantage of the _download.json file in Quarto's website having the latest version.

Related

Anydesk installation by bash script using wget

I'm trying to write a bash script for automating the installation of anydesk by wget with the help of the following code:
echo -e "[ - ] Installing AnyDesk..."
wget --max-redirect 1 --trust-server-names 'https://anydesk.com/en/downloads/thank-you?dv=deb_64' -O anydesk.deb
sudo apt install ./anydesk.deb
echo -e "[ ✔ ] AnyDesk ➜ INSTALLED\n"
The problem is that https://anydesk.com/en/downloads/thank-you?dv=deb_64 returns a HTML page, not a Debian package.
How can I parse the HTML page to find the download link to the Debian package?
I examined page source of https://anydesk.com/en/downloads/thank-you?dv=deb_64 and download is triggered by JavaScript depending on User-Agent of browser, wget does not support JavaScript execution therefore you are actually getting HTML page source not actual .deb file. Use tool which support JavaScript execution to get actual file.
You can run the following command:
wget -O anydesk.deb https://download.anydesk.com/linux/anydesk_6.2.1-1_amd64.deb
this will allow you to download Anydesk, via wget.

Running ASP.NET Core app from Amazon Linux 2 on Docker - Globalization

I have my ASP.NET Core app running beautifully (more or less) on microsoft/aspnetcore:2.0-jessie. Now I want to try to get it to deploy to amazonlinux:2.
So far, the biggest hurdle has been libicu. I tried setting Globalization to Invariant, but this caused weird failures in, e.g., mySQL database calls.
Here's the relevant step from my Dockerfile:
RUN curl -L --http1.1 http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-RHEL6-x64.tgz --output icu.tgz \
&& tar -xf icu.tgz -C / \
&& export LD_LIBRARY_PATH=/usr/local/lib \
&& rm icu.tgz
(SourceForge was down while I was trying to work on this yesterday, which didn't improve matters.)
In any case, I still get the message of doom from .NET Core:
FailFast: Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
Any suggestions how to proceed?
Well, I revisited this yesterday. I don't know if it's because the base .tar of the Amazon Linux image has been updated, or because I was doing something wrong last time, but I installed the following packages using yum and all was well:
libunwind
libicu
dotnet-hosting-2.0.5
Note that for the dotnet package I needed first to set up Microsoft's package repository for yum, i.e.
rpm --import https://packages.microsoft.com/keys/microsoft.asc
and copying the following file to /etc/yum.repos.d/dotnetdev.repo :
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
(see Microsoft's instructions for CentOS and other Linux distros)

How to build LLVM doxygen in HTML ? I tried but failed

I want to get a copy of the doxygen web-pages of llvm, so I can work with it without the internet.
I did as follows:
$ cd LLVM_ROOT_DIR
$ mkdir out
$ cd out/
$ ../configure --enable-doxygen
$ make ENABLE_OPTIMIZED=1
But it only built llvm without documentation. I also tried
$ make BUILD_FOR_WEBSITE=1 ENABLE_OPTIMIZED=1
and
$ make ENABLE_OPTIMIZED=1 EXTRA_DIST=1
All of them did not work.
How could I build the web pages ?
Thanks a lot.
Using recent versions of LLVM, an in-source build is prohibited by configure. Luckily the documentation can be built using cmake.
$ mkdir out
$ cd out/
$ cmake -DLLVM_ENABLE_DOXYGEN=On ../
$ make doxygen-llvm
The process will take a while, but after it you should have the full documentation.
Once you enable doxygen in the configure step, you can run make doxygen-llvm on the docs/ folder in your build directory.
You can run make help to check the available options.
I collect the web-site by wget.

How to update JDK on Jenkins Server cartridge (OpenShift)?

The Jenkins Server cartridge (OpenShift) uses OpenJDK 7u55.
How to update to OpenJDK 7u60 or 8u05 or Oracle JDK (7u60 or 8u05), please?
You can do this using OpenShift's action hooks. Add a script which will check for the existence of the JDK you want to use, and download it if it doesn't exist.
For example, in .openshift/action_hooks/deploy, add this snippet:
#! /bin/bash
JDK_HOME=$OPENSHIFT_DATA_DIR/jdk1.8.0
if [[ ! -L $JDK_HOME && ! -d $JDK_HOME ]]
then
cd $OPENSHIFT_DATA_DIR
wget http://www.java.net/download/jdk8u20/archive/b17/binaries/jdk-8u20-ea-bin-b17-linux-x64-04_jun_2014.tar.gz
tar xvf *.tar.gz
rm -f *.tar.gz
ln -s jdk1.8.0_20 jdk1.8.0
fi
In Jenkins, you can then configure builds to use this JDK by configuring the PATH variable, in an "Execute Shell" action, like so:
export PATH=$OPENSHIFT_DATA_DIR/jdk1.8.0/bin:$PATH
This example retrieves 8u20. Sorry, I'm not sure of the links to use for the exact versions you mention. Also, word of warning, this download is over HTTP, without performing a check against the published MD5 checksums. If you're doing anything serious, you should edit to code snippet to perform that check.

How do you migrate a Homebrew installation to a new location?

I have a Homebrew installation in $HOME/brew, and historically it has worked well. Unfortunately, over time Homebrew has become less and less tolerant of installations outside of /usr/local. Various formulae make hard assumptions about the installation prefix, and do not work properly (i.e., were not tested) with a non-standard prefix. The brew doctor command even goes so far as to warn about this now:
Warning: Your Homebrew is not installed to /usr/local
You can install Homebrew anywhere you want, but some brews may only build
correctly if you install in /usr/local. Sorry!
As such, I would now like to migrate my Homebrew installation over to /usr/local. However, I am loath to simply mv all the files, as I suspect this will cause problems. I could not find any instructions on the Homebrew site or here on migrating an existing installation to a new prefix. Of course, I could uninstall Homebrew and then reinstall it, but I would prefer not to rebuild all my kegs.
Is there any existing script or documented practice for performing such a migration?
Or is this impossible due to hardcoded absolute paths in linked binaries?
The modern way to do this is with homebrew-bundle.
brew tap Homebrew/bundle
brew bundle dump # Creates 'Brewfile' in the current directory
# later ...
brew bundle # Installs packages listed in 'Brewfile'
I just wrote a script to achieve the goal to migrate homebrew packages to a new system, which also applies for your case (named backup-homebrew.sh):
#!/bin/bash
echo '#!/bin/bash'
echo ''
echo 'failed_items=""'
echo 'function install_package() {'
echo 'echo EXECUTING: brew install $1 $2'
echo 'brew install $1 $2'
echo '[ $? -ne 0 ] && $failed_items="$failed_items $1" # package failed to install.'
echo '}'
brew tap | while read tap; do echo "brew tap $tap"; done
brew list --formula | while read item;
do
echo "install_package $item '$(brew info $item | /usr/bin/grep 'Built from source with:' | /usr/bin/sed 's/^[ \t]*Built from source with:/ /g; s/\,/ /g')'"
done
echo '[ ! -z $failed_items ] && echo The following items were failed to install: && echo $failed_items'
You should first run this script on your original system to generate a restore script:
./backup-homebrew.sh >restore-homebrew.sh && chmod +x restore-homebrew.sh
Then, after installing Homebrew on your new system (in your case the same system), simply run restore-homebrew.sh to install all those packages you have on your original system.
The benefits of this script over the one given by #ctrueden is that this script also tries to back up the installation options you used when you installed the packages.
A more detailed description is in my blog.
As suggested by Peter Eisentraut, I indeed ended up migrating my Homebrew installation by reinstalling it. You can script things a bit to retap all your extra taps, and reinstall all your previously installed kegs, without too much manual work:
#!/bin/sh
# save list of kegs for later reinstallation
brew list > kegs.txt
# back up old Homebrew installation
mv $HOME/brew $HOME/old-brew
# install Homebrew into /usr/local
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
# retap all the taps
# NB: It is not enough to move the tap repos to their new location,
# because Homebrew will not automatically recognize the new formulae.
# There might be a configuration file we could edit, but rather than
# risk an incomplete data structure, let's just retap everything.
for tapDir in $HOME/old-brew/Library/Taps/*
do (
cd $tapDir
tap=$(git remote -v | \
grep '(fetch)' | \
sed 's/.*github.com\///' | \
sed 's/ (fetch)//')
/usr/local/bin/brew tap $tap
) done
# reinstall all the kegs
/usr/local/bin/brew install $(cat kegs.txt)
# much later... ;-)
rm -rf kegs.txt $HOME/old-brew
Of course, customized Homebrew installations will have additional wrinkles. For example, if you have committed changes to any of your Homebrew-related Git repos, you may want to import that work before reinstalling your kegs or blowing away your old installation:
cd /usr/local
for f in $(find . -name '.git')
do (
repoDir=$(dirname $f)
cd $f/..
git remote add old-brew-$f $(dirname $HOME/old-brew/$f/..)
git fetch old-brew-$f
) done
Note that I only tested the second snippet above very lightly, as I personally have not customized my Homebrew in such a way.
Another aspect of Homebrew not addressed by this approach is custom flags using during your original installation. For example, to install wine you need to install various dependencies with the --universal flag, and the script above will not reinstall them with such flags enabled. See #xuhdev's answer for a solution that does so.
Or is this impossible due to hardcoded absolute paths in linked binaries?
Indeed. You'll need to reinstall everything from scratch.

Resources