当前位置: 首页 > news >正文

Linux运维_Bash脚本_编译安装GNU-Tools

Linux运维_Bash脚本_编译安装GNU-Tools

Bash (Bourne Again Shell) 是一个解释器,负责处理 Unix 系统命令行上的命令。它是由 Brian Fox 编写的免费软件,并于 1989 年发布的免费软件,作为 Sh (Bourne Shell) 的替代品。

您可以在 Linux 和 MacOS 机器上使用 Bash,甚至可以通过适用于 Linux 的 Windows 子系统在 Windows 10 机器上使用。

使用方法

  • 下载源码包:

pkg-config-0.29.2.tar.gz

m4-1.4.18.tar.gz

autoconf-2.69.tar.gz

automake-1.15.tar.gz

libtool-2.4.6.tar.gz

gettext-0.22.4.tar.xz

flex-2.6.4.tar.gz

bison-3.7.5.tar.gz

libiconv-1.14.tar.gz

make-4.3.tar.gz

  • 放于指定路径:

这里 Bash Shell 脚本的全局变量 STORAGE 指定的存放源码包的路径 /home/goufeng 可进行修改。

  • 执行 Bash Shell 脚本:

输入 /[路径名]/[脚本名].sh 即可进行自动编译部署,过程中提示输入 (y/n) 输入 y 则进行下一步,这样分阶段确认的原因是为了确保能够看到上一个源码编译结果中可能的错误和提示。

完整脚本

#! /bin/bash
# Create By GF 2024-03-02 14:41# --------------------------------------------------
# Install First: 
# * None# ------------------- PKG-Config -------------------
# Need File: pkg-config-0.29.2.tar.gz
# ---------------------- Flex ----------------------
# Need File: m4-1.4.18.tar.gz
# Need File: autoconf-2.69.tar.gz
# Need File: automake-1.15.tar.gz
# Need File: libtool-2.4.6.tar.gz
# Need File: gettext-0.22.4.tar.xz
# Need File: flex-2.6.4.tar.gz
# ---------------------- Bison ---------------------
# Need File: bison-3.7.5.tar.gz
# -------------------- libiconv --------------------
# Need File: libiconv-1.14.tar.gz # -> Not Recommended for Installation
# -------------------- GNU Make --------------------
# Need File: make-4.3.tar.gz# ##################################################
STORAGE=/home/goufeng# ######################################### PKG-Config ################################################ Function: 编译安装(Compile Install) pkg-config-0.29.2
# ##################################################
function Compile_Install_pkg_config_0_29_2() {if [[ ! -f "/usr/bin/pkg-config" && ! -f "/usr/local/bin/pkg-config" && ! -d "/opt/pkg-config-0.29.2" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( pkg-config-0.29.2 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/pkg-config-0.29.2.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/pkg-config-0.29.2 && ./configure --prefix=/opt/pkg-config-0.29.2 \--with-internal-glib && \STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/pkg-config-0.29.2/bin/pkg-config /usr/local/bin/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/pkg-config-0.29.2 && return 0elseecho "[Caution] Program: ( /usr/bin/pkg-config or /usr/local/bin/pkg-config or /opt/pkg-config-0.29.2 ) Already Exists."# ------------------------------------------return 0fi
}# ############################################ Flex ################################################### Function: 编译安装(Compile Install) m4-1.4.18 (for GCC-7.5.0)
# ##################################################
function Compile_Install_m4_1_4_18_for_GCC_7_5_0() {if [[ ! -f "/usr/bin/m4" && ! -f "/usr/local/bin/m4" && ! -d "/opt/m4-1.4.18" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( m4-1.4.18 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf $STORAGE/m4-1.4.18.tar.gz && STEP_UNZIPPED=1# ------------------------------------------if [[ $STEP_UNZIPPED == 1 ]]; then# * Problem: # c-stack.c:55:26: error: missing binary operator before token "("#   - Solve: patch 方法.#            cd /opt/m4-1.4.18#            patch -p1 < /opt/0003-c-stack-stop-using-SIGSTKSZ.patch# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token "("#   - Solve: sed 方法 (Part 1).#            m4-1.4.18/lib/c-stack.c#             #if ! HAVE_STACK_T && ! defined stack_t#             typedef struct sigaltstack stack_t;#             #endif#            -#ifndef SIGSTKSZ#            -# define SIGSTKSZ 16384#            -#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384#            -/* libsigsegv 2.6 through 2.8 have a bug where some architectures use#            -   more than the Linux default of an 8k alternate stack when deciding#            -   if a fault was caused by stack overflow.  */#            -# undef SIGSTKSZ#            -# define SIGSTKSZ 16384#            -#endif#            +/* Storage for the alternate signal stack.#            +   64 KiB is not too large for Gnulib-using apps, and is large enough#            +   for all known platforms.  Smaller sizes may run into trouble.#            +   For example, libsigsegv 2.6 through 2.8 have a bug where some#            +   architectures use more than the Linux default of an 8 KiB alternate#            +   stack when deciding if a fault was caused by stack overflow.  */#            +static max_align_t alternate_signal_stack[(64 * 1024#            +                                           + sizeof (max_align_t) - 1)#            +                                          / sizeof (max_align_t)];sed -i "53,61d" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "53i\\/\* Storage for the alternate signal stack\." $STORAGE/m4-1.4.18/lib/c-stack.csed -i "54i\   64 KiB is not too large for Gnulib\-using apps\, and is large enough" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "55i\   for all known platforms\.  Smaller sizes may run into trouble\." $STORAGE/m4-1.4.18/lib/c-stack.csed -i "56i\   For example, libsigsegv 2\.6 through 2\.8 have a bug where some" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "57i\   architectures use more than the Linux default of an 8 KiB alternate" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "58i\   stack when deciding if a fault was caused by stack overflow\.  \*\/" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "59i\static max_align_t alternate_signal_stack\[\(64 \* 1024" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "60i\                                           \+ sizeof \(max_align_t\) \- 1\)" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "61i\                                          \/ sizeof \(max_align_t\)\]\;" $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token "("#   - Solve: sed 方法 (Part 2).#            m4-1.4.18/lib/c-stack.c#            -/* Storage for the alternate signal stack.  */#            -static union#            -{#            -  char buffer[SIGSTKSZ];#            -#            -  /* These other members are for proper alignment.  There's no#            -     standard way to guarantee stack alignment, but this seems enough#            -     in practice.  */#            -  long double ld;#            -  long l;#            -  void *p;#            -} alternate_signal_stack;sed -i "131,142d" $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token "("#   - Solve: sed 方法 (Part 3).#            m4-1.4.18/lib/c-stack.c#               /* Always install the overflow handler.  */#               if (stackoverflow_install_handler (overflow_handler,#            -                                     alternate_signal_stack.buffer,#            -                                     sizeof alternate_signal_stack.buffer))#            +                                     alternate_signal_stack,#            +                                     sizeof alternate_signal_stack))sed -i "196,197d" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "196i\                                     alternate_signal_stack\," $STORAGE/m4-1.4.18/lib/c-stack.csed -i "197i\                                     sizeof alternate_signal_stack\)\)" $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token "("#   - Solve: sed 方法 (Part 4).#            m4-1.4.18/lib/c-stack.c#               stack_t st;#               struct sigaction act;#               st.ss_flags = 0;#            +  st.ss_sp = alternate_signal_stack;#            +  st.ss_size = sizeof alternate_signal_stack;sed -i "270i\  st\.ss_sp \= alternate_signal_stack\;" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "271i\  st\.ss_size \= sizeof alternate_signal_stack\;" $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token "("#   - Solve: sed 方法 (Part 5).#            m4-1.4.18/lib/c-stack.c#             # if SIGALTSTACK_SS_REVERSED#               /* Irix mistakenly treats ss_sp as the upper bound, rather than#                  lower bound, of the alternate stack.  */#            -  st.ss_sp = alternate_signal_stack.buffer + SIGSTKSZ - sizeof (void *);#            -  st.ss_size = sizeof alternate_signal_stack.buffer - sizeof (void *);#            -# else#            -  st.ss_sp = alternate_signal_stack.buffer;#            -  st.ss_size = sizeof alternate_signal_stack.buffer;#            +  st.ss_size -= sizeof (void *);#            +  char *ss_sp = st.ss_sp;#            +  st.ss_sp = ss_sp + st.ss_size;#             # endifsed -i "275,279d" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "275i\  st\.ss_size \-\= sizeof \(void \*\)\;" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "276i\  char \*ss_sp \= st\.ss_sp\;" $STORAGE/m4-1.4.18/lib/c-stack.csed -i "277i\  st\.ss_sp \= ss_sp \+ st\.ss_size\;" $STORAGE/m4-1.4.18/lib/c-stack.c# ......................................# * Problem: # c-stack.c:55:26: error: missing binary operator before token "("#   - Solve: sed 方法 (Part 6).#            m4-1.4.18/lib/c-stack.h#                ACTION must be async-signal-safe.  ACTION together with its callees#            -   must not require more than SIGSTKSZ bytes of stack space.  Also,#            +   must not require more than 64 KiB bytes of stack space.  Also,#                ACTION should not call longjmp, because this implementation does#                not guarantee that it is safe to return to the original stack.sed -i "37d" $STORAGE/m4-1.4.18/lib/c-stack.hsed -i "37i\   must not require more than 64 KiB bytes of stack space\.  Also\," $STORAGE/m4-1.4.18/lib/c-stack.h# ......................................# * Problem: -freadahead.c: In function ‘freadahead’#   - Solve: sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' /opt/m4-1.4.18/lib/*.c#            echo "#define _IO_IN_BACKUP 0x100" >> /opt/m4-1.4.18/lib/stdio-impl.hcd $STORAGE/m4-1.4.18 && sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' ./lib/*.ccd $STORAGE/m4-1.4.18 && echo "#define _IO_IN_BACKUP 0x100" >> ./lib/stdio-impl.hfi# ------------------------------------------cd $STORAGE/m4-1.4.18 && ./configure --prefix=/opt/m4-1.4.18 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/m4-1.4.18/bin/m4 /usr/local/bin/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/m4-1.4.18 && return 0elseecho "[Caution] Program: ( /usr/bin/m4 or /usr/local/bin/m4 or /opt/m4-1.4.18 ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) autoconf-2.69
# ##################################################
function Compile_Install_autoconf_2_69() {if [[ ! -f "/usr/bin/autoconf" && ! -f "/usr/local/bin/autoconf" && ! -d "/opt/autoconf-2.69" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( autoconf-2.69 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf autoconf-2.69.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/autoconf-2.69 && ./configure --prefix=/opt/autoconf-2.69 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/autoconf-2.69/bin/autoconf   /usr/local/bin/ln -sf /opt/autoconf-2.69/bin/autoheader /usr/local/bin/ln -sf /opt/autoconf-2.69/bin/autom4te   /usr/local/bin/ln -sf /opt/autoconf-2.69/bin/autoreconf /usr/local/bin/ln -sf /opt/autoconf-2.69/bin/autoscan   /usr/local/bin/ln -sf /opt/autoconf-2.69/bin/autoupdate /usr/local/bin/ln -sf /opt/autoconf-2.69/bin/ifnames    /usr/local/bin/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/autoconf-2.69 && return 0elseecho "[Caution] Program: ( /usr/bin/autoconf or /usr/local/bin/autoconf or /opt/autoconf-2.69 ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) automake-1.15 (for Ubuntu)
# ##################################################
function Compile_Install_automake_1_15_for_Ubuntu() {if [[ ! -f "/usr/bin/automake" && ! -f "/usr/local/bin/automake" && ! -d "/opt/automake-1.15" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( automake-1.15 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf automake-1.15.tar.gz && STEP_UNZIPPED=1if [[ $STEP_UNZIPPED == 1 ]]; then# * Problem: Makefile:3687: recipe for target 'doc/automake-1.15.1' failed#   - Solve: sed -i 's/\$\(update_mans\) automake\-\$\(APIVERSION\)/\$\(update_mans\) automake\-\$\(APIVERSION\) \-\-no\-discard\-stderr/' /opt/automake-1.15/Makefilesed -i 's/\$\(update_mans\) automake\-\$\(APIVERSION\)/\$\(update_mans\) automake\-\$\(APIVERSION\) \-\-no\-discard\-stderr/' $STORAGE/automake-1.15/Makefile# ......................................# * Problem: Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/local/bin/automake line 3936.#   - Solve: 按照提示行数, 将第一个遇到的 { 用 [ ] 括住.#            automake-1.15/bin/automake.in#               my ($text) = @_;#            -  $text =~ s/\${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;#            +  $text =~ s/\$[{]([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;#               return $text;sed -i "3881d" $STORAGE/automake-1.15/bin/automake.insed -i "3881i\  \$text =~ s/\\\\$\[\{\]\(\[\^ \\\t\=\:\+\{\}\]\+\)\}/substitute_ac_subst_variables_worker \(\$1\)/ge;" $STORAGE/automake-1.15/bin/automake.infi# ------------------------------------------cd $STORAGE/automake-1.15 && ./configure --prefix=/opt/automake-1.15 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=0# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/automake-1.15/bin/aclocal       /usr/local/bin/ln -sf /opt/automake-1.15/bin/aclocal-1.15  /usr/local/bin/ln -sf /opt/automake-1.15/bin/automake      /usr/local/bin/ln -sf /opt/automake-1.15/bin/automake-1.15 /usr/local/bin/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/automake-1.15 && return 0elseecho "[Caution] Program: ( /usr/bin/automake or /usr/local/bin/automake or /opt/automake-1.15 ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) libtool-2.4.6
# ##################################################
function Compile_Install_libtool_2_4_6() {# ----------------------------------------------# * Problem: Makefile.am:477: error: Libtool library used but 'LIBTOOL' is undefined#            Makefile.am:477:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'#            Makefile.am:477:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.#            Makefile.am:477:   If 'LT_INIT' is in 'configure.ac', make sure#            Makefile.am:477:   its definition is in aclocal's search path.#            autoreconf: automake failed with exit status: 1#   - Solve: 原因是 automake 和 libtool 没有安装在同一目录中, 导致 aclocal 在路径中找不到 .m4 文件。#            解决方法 (1):#                1. 执行 aclocal --print-ac-dir 查看 aclocal 的路径, 例如显示 /opt/automake-1.15/share/aclocal#                2. 将 libtool 的 share/aclocal 目录中的 .m4 文件复制到 /opt/automake-1.15/share/aclocal (cp /opt/libtool-2.4.6/share/aclocal/*.m4 /opt/automake-1.15/share/aclocal/)#                3. 再次执行 autoreconf, 问题解决。#            解决方法 (2):#                1. 确保二进制 bin 文件: "aclocal" (包含在 automake 中) 和 "libtoolize" (包含在 libtool 中) 在可找到 PATH 中 (最好是同一路径下)#                2. 先执行 libtoolize, 会在当前目录自动生成要用到的 .m4 文件, 再执行 autoreconf, 问题解决。if [[ ! -f "/usr/bin/libtool" && ! -f "/usr/local/bin/libtool" && ! -d "/opt/libtool-2.4.6" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( libtool-2.4.6 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf libtool-2.4.6.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/libtool-2.4.6 && ./configure --prefix=/opt/libtool-2.4.6 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/libtool-2.4.6/bin/libtool    /usr/local/bin/ln -sf /opt/libtool-2.4.6/bin/libtoolize /usr/local/bin/# ......................................cp /opt/libtool-2.4.6/share/aclocal/*.m4 /opt/automake-1.15/share/aclocal/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/libtool-2.4.6 && return 0elseecho "[Caution] Program: ( /usr/bin/libtool or /usr/local/bin/libtool or /opt/libtool-2.4.6 ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) gettext-0.22.4 (for Linux)
# ##################################################
function Compile_Install_gettext_0_22_4_for_Linux() {# **********************************************if [[ -f "/usr/bin/gettext" && ! -f "/usr/bin/autopoint" ]]; thenmv /usr/bin/gettext /usr/bin/gettext.bakfi# **********************************************if [[ ! -f "/usr/bin/gettext" && ! -f "/usr/local/bin/gettext" && ! -d "/opt/gettext-0.22.4" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( gettext-0.22.4 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar xvJf $STORAGE/gettext-0.22.4.tar.xz && STEP_UNZIPPED=1# ------------------------------------------# Must Be "Shared (--enable-shared)" To Be Called By Other Programs.cd $STORAGE/gettext-0.22.4 && ./configure --prefix=/opt/gettext-0.22.4 \--enable-shared && \STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenrsync -av /opt/gettext-0.22.4/bin/     /usr/local/bin/rsync -av /opt/gettext-0.22.4/include/ /usr/local/include/rsync -av /opt/gettext-0.22.4/lib/     /usr/local/lib/fi# ------------------------------------------ldconfig# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/gettext-0.22.4 && return 0elseecho "[Caution] Program: ( /usr/bin/gettext or /usr/local/bin/gettext or /opt/gettext-0.22.4 ) Already Exists."# ------------------------------------------return 0fi
}# Function: 编译安装(Compile Install) flex-2.6.4 (for Ubuntu)
# ##################################################
function Compile_Install_flex_2_6_4_for_Ubuntu() {if [[ ! -f "/usr/bin/flex" && ! -f "/usr/local/bin/flex" && ! -d "/opt/flex-2.6.4" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( flex-2.6.4 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar -zxvf flex-2.6.4.tar.gz && STEP_UNZIPPED=1# ------------------------------------------# * Problem: Can't exec "autopoint": No such file or directory at /opt/autoconf-2.69/share/autoconf/Autom4te/FileUtils.pm line 345.#            autoreconf: failed to run autopoint: No such file or directory#            autoreconf: autopoint is needed because this package uses Gettext#   - Solve: autopoint 在 gettext 的 bin/ 下面, 但系统原有的 gettext 可能没有 autopoint。#            autopoint is located under the bin/ of the gettext, but the original system gettext may not have autopoint. #            备份系统原有的 gettext (mv /usr/bin/gettext /usr/bin/gettext.bak) 并重新编译安装 gettext.#            Back up the original system gettext (mv /usr/bin/gettext /usr/bin/gettext.bak) and recompile and install the gettextcd $STORAGE/flex-2.6.4 && ./autogen.sh && ./configure --prefix=/opt/flex-2.6.4 \CFLAGS=-D_GNU_SOURCE && \STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/flex-2.6.4/bin/flex /usr/local/bin/ln -sf /opt/flex-2.6.4/bin/flex /usr/local/bin/flex++# ......................................rsync -av /opt/flex-2.6.4/include/ /usr/local/include/rsync -av /opt/flex-2.6.4/lib/     /usr/local/lib/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/flex-2.6.4 && return 0elseecho "[Caution] Program: ( /usr/bin/flex or /usr/local/bin/flex or /opt/flex-2.6.4 ) Already Exists."# ------------------------------------------return 0fi
}# ############################################### Bison ############################################### Function: 编译安装(Compile Install) bison-3.7.5
# ##################################################
function Compile_Install_bison_3_7_5() {if [[ ! -f "/usr/bin/bison" && ! -f "/usr/local/bin/bison" && ! -d "/opt/bison-3.7.5" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( bison-3.7.5 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/bison-3.7.5.tar.gz && STEP_UNZIPPED=1# ------------------------------------------cd $STORAGE/bison-3.7.5 && ./configure --prefix=/opt/bison-3.7.5 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/bison-3.7.5/bin/bison /usr/local/bin/ln -sf /opt/bison-3.7.5/bin/yacc  /usr/local/bin/# ......................................rsync -av /opt/bison-3.7.5/lib/ /usr/local/lib/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/bison-3.7.5 && return 0elseecho "[Caution] Program: ( /usr/bin/bison or /usr/local/bin/bison or /opt/bison-3.7.5 ) Already Exists."# ------------------------------------------return 0fi
}# ############################################# libiconv ############################################## Function: 编译安装(Compile Install) libiconv-1.14 (for GCC-7.5.0)
# ##################################################
function Compile_Install_libiconv_1_14_for_GCC_7_5_0() {# Not Recommended for Installation# 一般不建议安装 iconv, 因为 iconv 是默认包含在 glibc 中的一部分, 多个 iconv 存在可能引起调用问题。# 相关资料 (http://en.wikipedia.org/wiki/Iconv):#     All recent Linux distributions contain a free implementation of iconv() as part of the GNU C Library which is the C library for current Linux systems.#     To use it, the GNU glibc locales need to be installed, which are provided as a separate package (usually named glibc-locale) normally installed by default.local SKIP=1if [[ ! -f "/usr/bin/iconv" && ! -f "/usr/local/bin/iconv" && ! -d "/opt/libiconv-1.14" && $SKIP == 0 ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( libiconv-1.14 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/libiconv-1.14.tar.gz && STEP_UNZIPPED=1# ------------------------------------------if [[ $STEP_UNZIPPED == 1 ]]; then# * Problem: In file included from progname.c:26:0:#            ./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function); did you mean ‘fgets’?#             _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");#   - Solve: patch 方法.#            1. 把 Patch 补丁拷贝到 libiconv-1.14/srclib (cp libiconv-glibc-2.16.patch libiconv-1.14/srclib)#            2. cd libiconv-1.14/srclib#            3. patch -p1 < libiconv-glibc-2.16.patch# ......................................# * Problem: In file included from progname.c:26:0:#            ./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function); did you mean ‘fgets’?#             _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");#   - Solve: sed 方法.#            --- srclib/stdio.in.h.orig      2011-08-07 16:42:06.000000000 +0300#            +++ srclib/stdio.in.h   2013-01-10 15:53:03.000000000 +0200#            @@ -695,7 +695,9 @@#             /* It is very rare that the developer ever has full control of stdin,#                so any use of gets warrants an unconditional warning.  Assume it is#                always declared, since it is required by C89.  */#            -_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");#            +#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)#            + _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");#            +#endif#             #endifsed -i "698d" $STORAGE/libiconv-1.14/srclib/stdio.in.hsed -i "698i\\#if defined\(__GLIBC__\) \&\& \!defined\(__UCLIBC__\) \&\& \!__GLIBC_PREREQ\(2\, 16\)" $STORAGE/libiconv-1.14/srclib/stdio.in.hsed -i "699i\ _GL_WARN_ON_USE \(gets\, \"gets is a security hole \- use fgets instead\"\)\;" $STORAGE/libiconv-1.14/srclib/stdio.in.hsed -i "670i\\#endif" $STORAGE/libiconv-1.14/srclib/stdio.in.hfi# ------------------------------------------cd $STORAGE/libiconv-1.14 && ./configure --prefix=/opt/libiconv-1.14 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/libiconv-1.14/bin/iconv /usr/local/bin/# ......................................rsync -av /opt/libiconv-1.14/include/ /usr/local/include/rsync -av /opt/libiconv-1.14/lib/     /usr/local/lib/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/libiconv-1.14 && return 0elseecho "[Caution] Program: ( /usr/bin/iconv or /usr/local/bin/iconv or /opt/libiconv-1.14 or Skipped) Already Exists."# ------------------------------------------return 0fi
}# ############################################# GNU Make ############################################## Function: 编译安装(Compile Install) GNU-Make-4.3
# ##################################################
function Compile_Install_GNU_Make_4_3() {if [[ ! -f "/usr/bin/gmake" && ! -f "/usr/local/bin/gmake" && ! -d "/opt/gnu-make-4.3" ]]; thenlocal VERIFYlocal STEP_UNZIPPED=0local STEP_CONFIGURED=0local STEP_INSTALLED=0# ------------------------------------------read -p "[Confirm] Compile and Install ( gnu-make-4.3 )? (y/n)>" VERIFYif [[ "$VERIFY" != "y" ]]; then exit 1; fi# ------------------------------------------tar zxvf $STORAGE/make-4.3.tar.gz && STEP_UNZIPPED=1# ------------------------------------------if [[ $STEP_UNZIPPED == 1 && ! -f "$STORAGE/make-4.3/src/gnumake.h" ]]; thenecho "[Caution] Source Code: ( make-4.3.tar.gz ) is Not The GNU Make Source Code."# ......................................exit 1fi# ------------------------------------------cd $STORAGE/make-4.3 && ./configure --prefix=/opt/gnu-make-4.3 && STEP_CONFIGURED=1# ------------------------------------------make && make install && STEP_INSTALLED=1# ------------------------------------------if [[ $STEP_INSTALLED == 1 ]]; thenln -sf /opt/gnu-make-4.3/bin/make /usr/local/bin/gmake# ......................................ln -sf /opt/gnu-make-4.3/include/gnumake.h /usr/local/include/fi# ------------------------------------------cd $STORAGE && rm -rf $STORAGE/make-4.3 && return 0elseecho "[Caution] Program: ( /usr/bin/gmake or /usr/local/bin/gmake or /opt/gnu-make-4.3 ) Already Exists."# ------------------------------------------return 0fi
}function main() {# ----------------- PKG-Config -----------------Compile_Install_pkg_config_0_29_2# -------------------- Flex --------------------Compile_Install_m4_1_4_18_for_GCC_7_5_0Compile_Install_autoconf_2_69Compile_Install_automake_1_15_for_UbuntuCompile_Install_libtool_2_4_6Compile_Install_gettext_0_22_4_for_LinuxCompile_Install_flex_2_6_4_for_Ubuntu# -------------------- Bison -------------------Compile_Install_bison_3_7_5# ------------------ libiconv ------------------#Compile_Install_libiconv_1_14_for_GCC_7_5_0 # -> Not Recommended for Installation# ------------------ GNU Make ------------------Compile_Install_GNU_Make_4_3
}main

总结

以上就是关于 Linux运维 Bash脚本 编译安装GNU-Tools 的全部内容。

更多内容可以访问我的代码仓库:

https://gitee.com/goufeng928/public

https://github.com/goufeng928/public

相关文章:

Linux运维_Bash脚本_编译安装GNU-Tools

Linux运维_Bash脚本_编译安装GNU-Tools Bash (Bourne Again Shell) 是一个解释器&#xff0c;负责处理 Unix 系统命令行上的命令。它是由 Brian Fox 编写的免费软件&#xff0c;并于 1989 年发布的免费软件&#xff0c;作为 Sh (Bourne Shell) 的替代品。 您可以在 Linux 和 …...

leetcode 121.买卖股票的最佳时机

声明&#xff1a;以下仅代表个人想法&#xff0c;非官方答案或最优题解&#xff01; 题目&#xff1a; 给定一个数组 prices &#xff0c;它的第 i 个元素 prices[i] 表示一支给定股票第 i 天的价格。 你只能选择 某一天 买入这只股票&#xff0c;并选择在 未来的某一个不同的…...

javaWebssh酒店客房管理系统myeclipse开发mysql数据库MVC模式java编程计算机网页设计

一、源码特点 java ssh酒店客房管理系统是一套完善的web设计系统&#xff08;系统采用ssh框架进行设计开发&#xff09;&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模式开发。开发环境为TOMCAT7.0…...

vue3基础教程(2)——创建vue3+vite项目

博主个人微信小程序已经上线&#xff1a;【中二少年工具箱】。欢迎搜索试用 正文开始 专栏简介1. 前言2.node版本检测3.创建vue项目 专栏简介 本系列文章由浅入深&#xff0c;从基础知识到实战开发&#xff0c;非常适合入门同学。 零基础读者也能成功由本系列文章入门&#x…...

部署DNS 实战篇

二、DNS 部署 环境介绍 服务器3台、系统centos 安装软件 yum install -y bind bind-utils bind-chrootbind 主包bind-utils 客户端测试工具&#xff08;host 、dig 、nslookup&#xff09;bind-chroot chroot环境 禁锢dns服务器的工作目录caching-nameserver(rhel5提供…...

2023 2024年全国职业院校技能大赛中职组网络建设与运维赛项服务器Linux部分教程解析

欢迎合作 需要资料请私 Rocky 9 包含各种常考服务(包括新题型KVM等)...

Flask g对象和插件

四、Flask进阶 1. Flask插件 I. flask-caching 安装 pip install flask-caching初始化 from flask_cache import Cache cache Cache(config(CACHE_TYPE:"simple" )) cache.init_app(appapp)使用 在视图函数上添加缓存 blue.route("/") cache.cached(tim…...

26、Qt调用.py文件中的函数

一、开发环境 Qt5.12.0 Python3.7.8 64bit 二、使用 新建一个Qt项目&#xff0c;右击项目名称&#xff0c;选择“添加库” 选择“外部库”&#xff0c;点击“下一步” 点击“浏览”&#xff0c;选择Python安装目录下的libs文件夹中的“python37.lib”文件&#xff0c;点击“下…...

计算机网络实验一 网线制作

实验目的与要求&#xff1a; 实验目的 了解以太网网线&#xff08;双绞线&#xff09;和制作方法 实验内容 了解网线和水晶头 学习网线制作方法 实验环境和要求 网线 水晶头 压线钳 剥线钳 网线测试器 方法、步骤&#xff1a; 步骤一 准备工具和材料 步骤二 剥掉双绞线的外…...

android TextView 实现富文本显示

android TextView 实现富文本显示&#xff0c;实现抖音直播间公屏消息案例 使用&#xff1a; val tvContent: TextView helper.getView(R.id.tvContent)//自己根据UI业务要求&#xff0c;可以控制 图标显示 大小val levelLabel MyImgLabel( bitmap 自己业务上的bitmap )va…...

Linux常用命令(超详细)

一、基本命令 1.1 关机和重启 关机 shutdown -h now 立刻关机 shutdown -h 5 5分钟后关机 poweroff 立刻关机 重启 shutdown -r now 立刻重启 shutdown -r 5 5分钟后重启 reboot 立刻重启 1.2 帮助命令 –help命令 shutdown --help&#xff1a; ifconfig --help&#xff1a;查看…...

软考笔记--基于架构的软件开发方法

一.体系架构的设计方法概述 基于体系结构的软件设计方法ABSD是由体系结构驱动的&#xff0c;即指有构成体系结构的商业、质量和功能需求的组合驱动的。ABSD方法有3个基础。第1个基础是功能的分解。在功能分解中&#xff0c;ABSD方法使用已有的基于模块的内聚和耦合技术。第2个…...

CSS 盒子模型(box model)

概念 所有HTML元素可以看作盒子&#xff0c;在CSS中&#xff0c;"box model"这一术语是用来设计和布局时使用CSS盒模型本质上是一个盒子&#xff0c;封装周围的HTML元素&#xff0c;它包括&#xff1a;外边距(margin)&#xff0c;边框(border)&#xff0c;内边距(pad…...

基于springboot+vue的在线考试系统

博主主页&#xff1a;猫头鹰源码 博主简介&#xff1a;Java领域优质创作者、CSDN博客专家、阿里云专家博主、公司架构师、全网粉丝5万、专注Java技术领域和毕业设计项目实战&#xff0c;欢迎高校老师\讲师\同行交流合作 ​主要内容&#xff1a;毕业设计(Javaweb项目|小程序|Pyt…...

001 概述

什么是API API&#xff08;Application Programming Interface,应用程序编程接口&#xff09;是一些预先定义的函数&#xff0c;目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力&#xff0c;而又无需访问源码&#xff0c;或理解内部工作机制的细节。为了…...

linux环境下nginx的配置文件

根据指定的域名进行反向代理转发&#xff0c;实现负载均衡 Nginx的upstream支持如下六种方式的分配算法&#xff0c;分别是&#xff1a; 轮询 默认方式 weight 权重方式 ip_hash 依据ip分配方式 least_conn 依据最少连接方式 url_hash 依据URL分配方式 fair 依据响应时间…...

AcWing:1236. 递增三元组

给定三个整数数组 A[A1,A2,…AN] B[B1,B2,…BN] C[C1,C2,…CN] 请你统计有多少个三元组 (i,j,k) 满足&#xff1a; 1≤i,j,k≤NAi<Bj<Ck 输入格式 第一行包含一个整数 N。 第二行包含 N 个整数 A1,A2,…AN。 第三行包含 N 个整数 B1,B2,…BN。 第四行包含 N 个整…...

关于并网继电器的继电器自检逻辑及实现方式

需求 对于常规的光伏并网逆变器来说&#xff0c;继电器控制至关重要。继电器一般位于逆变电感后&#xff0c;共模电感前&#xff0c;用于将逆变电压与电网电压脱开&#xff0c;一般国外有双继电器的安规强制认证要求&#xff0c;国内目前只需要单继电器要求&#xff08;后续应…...

Spring中的事务和事务的传播机制

事务是一组操作的集合&#xff0c;不可以被分割。事务会把所有的操作作为一个整体&#xff0c;这组操作要么全部成功&#xff0c;要么全部失败。 事务有三种操作&#xff1a; 开启事务&#xff1b;提交事务&#xff1b;回滚事务。 如果代码的执行逻辑是这样&#xff1a; 开…...

前端【技术类】资源学习网站整理(那些年的小网站)

学习网站整理 值得分享的视频博主&#xff1a;学习网站链接 百度首页的资源收藏里的截图&#xff08;排列顺序没有任何意义&#xff0c;随性而已~&#xff09;&#xff0c;可根据我标注的关键词百度搜索到这些网站呀&#xff0c;本篇末尾会一一列出来&#xff0c;供大家学习呀 …...

【Python】 -- 趣味代码 - 小恐龙游戏

文章目录 文章目录 00 小恐龙游戏程序设计框架代码结构和功能游戏流程总结01 小恐龙游戏程序设计02 百度网盘地址00 小恐龙游戏程序设计框架 这段代码是一个基于 Pygame 的简易跑酷游戏的完整实现,玩家控制一个角色(龙)躲避障碍物(仙人掌和乌鸦)。以下是代码的详细介绍:…...

SciencePlots——绘制论文中的图片

文章目录 安装一、风格二、1 资源 安装 # 安装最新版 pip install githttps://github.com/garrettj403/SciencePlots.git# 安装稳定版 pip install SciencePlots一、风格 简单好用的深度学习论文绘图专用工具包–Science Plot 二、 1 资源 论文绘图神器来了&#xff1a;一行…...

MongoDB学习和应用(高效的非关系型数据库)

一丶 MongoDB简介 对于社交类软件的功能&#xff0c;我们需要对它的功能特点进行分析&#xff1a; 数据量会随着用户数增大而增大读多写少价值较低非好友看不到其动态信息地理位置的查询… 针对以上特点进行分析各大存储工具&#xff1a; mysql&#xff1a;关系型数据库&am…...

PPT|230页| 制造集团企业供应链端到端的数字化解决方案:从需求到结算的全链路业务闭环构建

制造业采购供应链管理是企业运营的核心环节&#xff0c;供应链协同管理在供应链上下游企业之间建立紧密的合作关系&#xff0c;通过信息共享、资源整合、业务协同等方式&#xff0c;实现供应链的全面管理和优化&#xff0c;提高供应链的效率和透明度&#xff0c;降低供应链的成…...

【SpringBoot】100、SpringBoot中使用自定义注解+AOP实现参数自动解密

在实际项目中,用户注册、登录、修改密码等操作,都涉及到参数传输安全问题。所以我们需要在前端对账户、密码等敏感信息加密传输,在后端接收到数据后能自动解密。 1、引入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId...

Linux相关概念和易错知识点(42)(TCP的连接管理、可靠性、面临复杂网络的处理)

目录 1.TCP的连接管理机制&#xff08;1&#xff09;三次握手①握手过程②对握手过程的理解 &#xff08;2&#xff09;四次挥手&#xff08;3&#xff09;握手和挥手的触发&#xff08;4&#xff09;状态切换①挥手过程中状态的切换②握手过程中状态的切换 2.TCP的可靠性&…...

YSYX学习记录(八)

C语言&#xff0c;练习0&#xff1a; 先创建一个文件夹&#xff0c;我用的是物理机&#xff1a; 安装build-essential 练习1&#xff1a; 我注释掉了 #include <stdio.h> 出现下面错误 在你的文本编辑器中打开ex1文件&#xff0c;随机修改或删除一部分&#xff0c;之后…...

高频面试之3Zookeeper

高频面试之3Zookeeper 文章目录 高频面试之3Zookeeper3.1 常用命令3.2 选举机制3.3 Zookeeper符合法则中哪两个&#xff1f;3.4 Zookeeper脑裂3.5 Zookeeper用来干嘛了 3.1 常用命令 ls、get、create、delete、deleteall3.2 选举机制 半数机制&#xff08;过半机制&#xff0…...

高等数学(下)题型笔记(八)空间解析几何与向量代数

目录 0 前言 1 向量的点乘 1.1 基本公式 1.2 例题 2 向量的叉乘 2.1 基础知识 2.2 例题 3 空间平面方程 3.1 基础知识 3.2 例题 4 空间直线方程 4.1 基础知识 4.2 例题 5 旋转曲面及其方程 5.1 基础知识 5.2 例题 6 空间曲面的法线与切平面 6.1 基础知识 6.2…...

Cinnamon修改面板小工具图标

Cinnamon开始菜单-CSDN博客 设置模块都是做好的&#xff0c;比GNOME简单得多&#xff01; 在 applet.js 里增加 const Settings imports.ui.settings;this.settings new Settings.AppletSettings(this, HTYMenusonichy, instance_id); this.settings.bind(menu-icon, menu…...