linux - 如何制作 ubuntu 可执行文件并在我的安装文件中运行它

标签 linux git bash ubuntu-12.04 executable

这是下面的安装文件 (sandhi-install.sh)。目前安装后只能从终端运行。我想让它独立于终端。 Making a Ubuntu executable解释了如何创建一个可执行文件,但我应该把代码放在哪里。我认为它应该在安装文件本身中,因为我们希望图标在安装完成后出现在桌面上。 我以前没有 Shell 脚本和 bash 方面的经验,如果我错过任何重要信息,我深表歉意。请询问您是否需要任何其他文件。我的目标基本上是独立于终端运行 sandhi。

#!/bin/bash

echo "Installing the required dependencies"

sudo apt-get -y install git-core autoconf automake make libtool g++ python-dev swig \
pkg-config libboost1.48-all-dev libfftw3-dev libcppunit-dev libgsl0-dev \
libusb-dev sdcc libsdl1.2-dev python-wxgtk2.8 python-numpy \
python-cheetah python-lxml doxygen python-qt4 python-qwt5-qt4 libxi-dev \
libqt4-opengl-dev libqwt5-qt4-dev libfontconfig1-dev libxrender-dev \
python-serial python-matplotlib

echo "Sciscipy installation starting"
git clone https://github.com/manojgudi/sciscipy-1.0.0.git
cd sciscipy-1.0.0/
sudo ./install

echo "Starting Sandhi installation"
cd ../
git clone http://github.com/manojgudi/sandhi.git
cd sandhi/
git submodule init
git submodule update
git pull origin master
git submodule update

mkdir build
cd build/
cmake ../
make -j 2
sudo make install
sudo ldconfig

echo "Sandhi installation complete. Go to command line and type Sandhi to start Sandhi"

最佳答案

您的脚本已经具备成为 *nix 的所有正确要素executable - 一个 shebang line以及至少看起来像解释器的有效代码(/bin/bash)。您需要做的就是授予相关用户和/或组(或每个人)对文件的执行访问权限。例如,如果您是文件的所有者:

sandhi@host$ ls -l sandhi.sh
-rw-r--r--  1 purak users 3.5K Oct 11 16:55 sandhi.sh
sandhi@host$ chmod u+x sandhi.sh

现在你可以执行它了:

sandhi@host$ ls -l sandhi.sh
-rwxr--r--  1 purak users 3.5K Oct 11 16:55 sandhi.sh
sandhi@host$ ./sandhi.sh

对于问题的其余部分,不清楚您在问什么。 Making a Ubuntu executable 的公认答案表示如果可执行文件 foo.bin 位于 /usr/local/bin(自定义可执行文件的合理目的地)桌面条目 应该是 Exec=/usr/local/bin/foo.bin

关于linux - 如何制作 ubuntu 可执行文件并在我的安装文件中运行它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26448701/

相关文章:

c - 是否可以将密码传递给需要 root 权限的进程

c - 限制 Linux 静态库中的符号

linux - Go 导致 OpenGL 与 time.Tick 但不是 time.After 发生段错误

linux - 如何在 linux 中启动 sqlplus (Oracle 12C)?

Linux 命令在 shell 上运行良好但在脚本中运行不正常

linux - 循环遍历所有具有特定扩展名的文件并对它们执行某些操作

git - 致命的 : Unable to read current working directory: No such file or directory

git - 如何在 git 日志图中显示相对提交号?

linux - git否定排除 stash 文件的 stash 目录

bash - 如何使任何 sed、awk 和 grep 命令忽略以# 开头的行?