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:


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.plThe command to execute this and change directories automatically is:
sudo ln -s /path/to/lfsget.pl /usr/bin/lfsget
cd $(lfsget <url-to-tarball>)