Linux 挂载安装文件

先安装后挂载

1

先用

./configure --prefix=/usr/local/YOUR_FOLDER
make && make install

安装至指定目录,方便管理

2

编写可执行程序、库等文件的挂载和卸载脚本

SRCDIR="/usr/local/libpng"
DSTDIR="/usr/local"

BIN_FILE_0=bin/libpng16-config
BIN_FILE_1=bin/pngfix
BIN_FILE_2=bin/png-fix-itxt

INC_FILE_0=include/libpng16/pngconf.h
INC_FILE_1=include/libpng16/png.h
INC_FILE_2=include/libpng16/pnglibconf.h

LIB_FILE_0=lib/libpng16.a
LIB_FILE_1=lib/libpng16.la
LIB_FILE_2=lib/libpng16.so.16.39.0

case $1 in
    "mnt")
    mkdir $DSTDIR/include/libpng16
    ln -vs $SRCDIR/$BIN_FILE_0 $DSTDIR/$BIN_FILE_0
    ln -vs $SRCDIR/$BIN_FILE_1 $DSTDIR/$BIN_FILE_1
    ln -vs $SRCDIR/$BIN_FILE_2 $DSTDIR/$BIN_FILE_2

    ln -vs $SRCDIR/$INC_FILE_0 $DSTDIR/$INC_FILE_0
    ln -vs $SRCDIR/$INC_FILE_1 $DSTDIR/$INC_FILE_1
    ln -vs $SRCDIR/$INC_FILE_2 $DSTDIR/$INC_FILE_2

    ln -vs $SRCDIR/$LIB_FILE_0 $DSTDIR/$LIB_FILE_0
    ln -vs $SRCDIR/$LIB_FILE_1 $DSTDIR/$LIB_FILE_1
    ln -vs $SRCDIR/$LIB_FILE_2 $DSTDIR/$LIB_FILE_2

    ln -vs $SRCDIR/$LIB_FILE_0 $DSTDIR/lib/libpng.a
    ln -vs $SRCDIR/$LIB_FILE_1 $DSTDIR/lib/libpng.la
    ln -vs $SRCDIR/$LIB_FILE_2 $DSTDIR/lib/libpng.so
    ln -vs $SRCDIR/$LIB_FILE_2 $DSTDIR/lib/libpng16.so
    ln -vs $SRCDIR/$LIB_FILE_2 $DSTDIR/lib/libpng16.so.16
    echo "mount done"
    ;;
    "umt")
    rm $(DSTDIR)/$(BIN_FILE_0)
    rm $(DSTDIR)/$(BIN_FILE_1)
    rm $(DSTDIR)/$(BIN_FILE_2)

    rm $(DSTDIR)/$(INC_FILE_0)
    rm $(DSTDIR)/$(INC_FILE_1)
    rm $(DSTDIR)/$(INC_FILE_2)

    rm $(DSTDIR)/$(LIB_FILE_0)
    rm $(DSTDIR)/$(LIB_FILE_1)
    rm $(DSTDIR)/$(LIB_FILE_2)
    rm -r $(DSTDIR)/include/libpng16
    rm $(DSTDIR)/lib/libpng*
    echo "unlink done"
    ;;
    *)
    echo "=== mount libpng to /usr/local ==="
    echo "mount: ./mount mnt"
    echo "unmount: ./mount umt"
    ;;
esac
posted @ 2023-05-23 15:05  Junzhao  阅读(36)  评论(0编辑  收藏  举报