Giter VIP home page Giter VIP logo

bashreqs's Introduction

bashreqs

pipreqs for bash scripts. Not affiliated with pipreqs. Requires Python version 3.5.3 to build.

bashreqs reads a bash script, and finds which programs the bash script needs to run. It then finds which packages would need to be installed to satisfy all of those dependencies. This creates a list of dependencies which can be used to install on another computer.

After cloning, run pip3 install -r requirements.txt then python3 bashreqs.py path-to-bash-script to generate a report containing all of the Debian and Ubuntu-based packages needed to run a bash script. If the executables are not packages, then bashreqs will just list the path to the executable.

Requirements

Needs apt-get, aptitude, nm, and python3 to be installed.

How to use

Run python3 bashreqs.py <path-to-bash-script> to generate a pip-style report of the bash script's requirements.

bashreqs assumes that the script runs fine on your computer before it searches for packages (this app should be run on the developer's computer to generate the dependency requirements.) bashreqs will notify you if the bash program contains a package which is obsolete (i.e. cannot be re-installed on another computer, because it was installed from a deb file, or is no longer available in the official repos.)

Here's a report generated from https://github.com/topkecleon/telegram-bot-bash/blob/master/bashbot.sh (not affiliated with telegram-bot-bash):

# warning: /usr/bin/tmux calls execv, execvp, execl which could cause missing req
# warning: /usr/bin/git calls execv, execvp, execl, execlp, execl which could cause missing req
coreutils==8.26-3 # because of /bin/rm, /bin/cat, /usr/bin/wc, /usr/bin/mkfifo, /usr/bin/cut, /usr/bin/tail, /bin/echo
curl==7.52.1-5+deb9u3
git==1:2.11.0-3+deb9u2
grep==2.27-2 # because of /bin/egrep,
less==481-2.1
ncurses-bin==6.0+20161126-1+deb9u1 # because of /usr/bin/clear
sed==4.4-1
tmux==2.3-4

bashreqs generates warnings for executables which contain a system call that could instantiate another program. This means that the command-line arguments to a program (e.g. strace <command>) might supervise another executable, or just a string (in which case bashreq may not be able to sufficiently determine the requirements.) For example, strace echo hello has two requirements: strace and echo, but bashreq only sees strace, and so generates a warning because strace's executable contains an exec call (allowing it to run arbitrary programs, such as echo.)

Report too bloated? Want to hide common utils like echo, bash, and sed for example?

No problem. bashreqs lets you hide the top x% of packages installed on Ubuntu computers. For example, ncurses-base is installed on 99.877% of computers (from the popcon data), so it's highly unlikely that a user will need to install it, as they probably already have it installed.

Dependency-free executable

Head on over to https://github.com/Decagon/bashreqs/releases/tag/v0.1-alpha to find a Linux executable which is dependency-less (except for the shell commands which are probably pre-installed.) No Python needed.

Roadmap

  • using the flagged executables (warnings), check if they have the ability to call another program (e.g. strace can supervise another executable) so that requirements can be parsed more accurately.

  • attempt to find dependencies inside of an executable that is not managed with a package manager

  • add support for other package managers (e.g. rpm, yum, etc.)

bashreqs's People

Contributors

alexyorke avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.