Article 54VCQ Perl script for fetching a source

Perl script for fetching a source

by
LBuhler
from LinuxQuestions.org on (#54VCQ)
Hi guys,

During a LFS installation one has to fetch, unpack and change directories a lot. I wrote this small perl script which relies on wget to make life a little easier. I'm sure similar options exist already. The nice thing about this one is that the download gets piped to stdout for unpacking, no extra disk-space required and no source tarball to delete afterwards.

Code:#!/usr/bin/perl -w
# lfsget: A simple script to download and extract a tar-compressed source file
# (C) Laurens Buhler 2020 under the terms of the GPLv3

my %archive = ("gz" => "z", "bz2" => "j", "xz" => "J", "lz" => "J",);

$ARGV[0] =~/.*tar\.(.*)$/;

(qx|wget $ARGV[0] -O - \| tar xv$archive{$1}|)[-1] =~/(.*?)\/.*/;
print $1;Save this code to lfsget.pl (for instance), then:
chmod +x lfsget.pl
sudo ln -s /path/to/lfsget.pl /usr/bin/lfsget
The command to execute this and change directories automatically is:
cd $(lfsget <url-to-tarball>)
latest?d=yIl2AUoC8zA latest?i=BmmHLpWYiYU:LFm14r2bfq8:F7zBnMy latest?i=BmmHLpWYiYU:LFm14r2bfq8:V_sGLiP latest?d=qj6IDK7rITs latest?i=BmmHLpWYiYU:LFm14r2bfq8:gIN9vFwBmmHLpWYiYU
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments