-
-
Save KaMeHb-UA/ba2b665b0cf19a0ab063798c23facd07 to your computer and use it in GitHub Desktop.
Simple apt-like wrapper for yaourt (install: wget https://goo.gl/ZxoPLP -O - | /bin/sh)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const args = (shorts => { | |
var res = { | |
params: {}, | |
args: [] | |
}; | |
for(var i = 2; i < process.argv.length; i++){ | |
if(process.argv[i][0] == '-'){ | |
if(process.argv[i][1] == '-'){ | |
let [arg, ...val] = process.argv[i].slice(2).split('='); | |
res.params[arg] = val.join('=') || true; | |
} else { | |
process.argv[i].slice(1).split('').forEach(shorted => { | |
res.params[(shorts[shorted] ? shorts[shorted][0] : null) || `shorted_arg_${shorted}`] = ((!shorts[shorted] || !shorts[shorted][1]) ? true : process.argv[++i]) || true; | |
}) | |
} | |
} else { | |
res.args.push(process.argv[i] || true) | |
} | |
} | |
return res; | |
})({ | |
y: ['noconfirm', false], | |
v: ['version'], | |
h: ['help'] | |
}); | |
if(args.params.version){ | |
console.log(`pkg soft-wrapper utility for yaourt by Vlad <KaMeHb> Marchenko (C) BASSTeam prod., 2015-2018, version 0.0.2-c`); | |
process.exit(0) | |
} | |
if(args.params.help){ | |
console.log(` | |
Available commands: | |
pkg install [package(s)] [-y] | |
pkg remove [package(s)] [-y] | |
To update utility, use pkg-update | |
To remove utility, use pkg-remove | |
`); | |
process.exit(0) | |
} | |
if(!args.args[1]){ | |
console.error('Error: Please, specify package'); | |
process.exit(2) | |
} | |
var spawn = (({spawn}) => { | |
var params = []; | |
for(let i in args.params){ | |
if (typeof args.params[i] == 'string') params.push(`--${i}=${args.params[i]}`); else params.push(`--${i}`) | |
} | |
return symArgs => { | |
return spawn('yaourt', [`-${symArgs}`, ...params, (a=>{var b=[],i;for(i=1;i<a.length;i++){b.push(a[i])}return b})(args.args)], {stdio: 'inherit'}) | |
} | |
})(require('child_process')); | |
switch(args.args[0]){ | |
case 'install': | |
spawn('S'); | |
break; | |
case 'remove': | |
spawn('R'); | |
break; | |
default: | |
console.error('Error: Please, specify an action'); | |
process.exit(1); | |
break | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Granting superuser rights..." | |
echo "echo 'Downloading pkg...' &&\ | |
wget https://gist.githubusercontent.com/KaMeHb-UA/ba2b665b0cf19a0ab063798c23facd07/raw/pkg -qO /usr/bin/pkg &&\ | |
echo 'Installing pkg...' &&\ | |
chmod +x /usr/bin/pkg &&\ | |
echo 'Downloading pkg-update...' &&\ | |
wget https://gist.githubusercontent.com/KaMeHb-UA/ba2b665b0cf19a0ab063798c23facd07/raw/pkg-update -qO /usr/bin/pkg-update &&\ | |
echo 'Installing pkg-update...' &&\ | |
chmod +x /usr/bin/pkg-update &&\ | |
echo 'Downloading pkg-remove...' &&\ | |
wget https://gist.githubusercontent.com/KaMeHb-UA/ba2b665b0cf19a0ab063798c23facd07/raw/pkg-remove -qO /usr/bin/pkg-remove &&\ | |
echo 'Installing pkg-remove...' &&\ | |
chmod +x /usr/bin/pkg-remove" | sudo su | |
echo "Successfully installed pkg version $(pkg -v 2>&1 | awk 'NF>1{print $NF}')" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
read -p "Are you sure to remove pkg utility? " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
v=$(pkg -v 2>&1 | awk 'NF>1{print $NF}') | |
echo "Granting superuser rights..." | |
echo "echo 'Removing updater...' &&\ | |
rm /usr/bin/pkg-update &&\ | |
echo 'Removing utility...' &&\ | |
rm /usr/bin/pkg &&\ | |
echo 'Removing self...' &&\ | |
rm /usr/bin/pkg-remove" | sudo su | |
echo "Successfuly removed pkg $v" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Downloading latest installer..." | |
wget https://gist.githubusercontent.com/KaMeHb-UA/ba2b665b0cf19a0ab063798c23facd07/raw/pkg-installer -qO - | /bin/sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment