-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 328b65b
Showing
11 changed files
with
1,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# temp files | ||
MYMETA.json | ||
MYMETA.yml | ||
pm_to_blib | ||
|
||
# backup files | ||
*~ | ||
*.bak | ||
*.swp | ||
Makefile.old | ||
|
||
# directory | ||
blib/ | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
v1.02 2015-08-07 | ||
* 更改了一处执行流程。 | ||
|
||
v1.01 2015-05-03 | ||
* 现在脚本被当作指令安装了。 | ||
|
||
v1.00 2014-10-10 | ||
* 修正了一处不继承环境变量时$USER 变量无效引起的错误。 | ||
* 修正了一处不正确的浮点数比较带来的错误。 | ||
* 更改了一处执行流程。 | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#关于 | ||
项目用于在Slackware64 上安装32 位运行库。 | ||
|
||
程序会自动检测Slackware 版本,您也可以手动指定版本。然而程序无法分辨Current 版本,请手动选择Current。 | ||
|
||
如果BUG 请提交[Issues][id_Issues]。 | ||
|
||
[id_Issues]: https://github.com/Arondight/slacklib32/issues "点此提交问题" | ||
|
||
#安装 | ||
``` | ||
git clone https://github.com/Arondight/slacklib32.git /tmp/slacklib32 | ||
cd /tmp/slacklib32 && sudo ./install.sh | ||
sudo slacklib32 | ||
``` | ||
|
||
#截图 | ||
![截图1](screenshots/screenshot1.png?raw=true) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env bash | ||
# ===================================================== # | ||
# 如有BUG 请提交Issues # | ||
# https://github.com/Arondight/slacklib32/issues # | ||
# # | ||
# Copyright (C) 2014-2015 秦凡东 # | ||
# ===================================================== # | ||
|
||
source /usr/local/lib/check_environment.sh | ||
source /usr/local/lib/main_window.sh | ||
source /usr/local/lib/get_arch.sh | ||
source /usr/local/lib/install_multilib.sh | ||
|
||
version='' | ||
target='' | ||
arch='' | ||
use_dialog='' | ||
work_directory='' | ||
cache_directory='' | ||
|
||
# MAIN () { | ||
# 决定是否使用dialog | ||
if type dialog >/dev/null 2>&1; then | ||
use_dialog=true | ||
else | ||
use_dialog=false | ||
fi | ||
|
||
# 设定工作目录 | ||
work_directory=$HOME/.slacklib32 | ||
if [[ ! -d $work_directory ]]; then | ||
mkdir -p "$work_directory" | ||
fi | ||
|
||
# 检查环境是否满足 | ||
check_environment $use_dialog | ||
if [[ 0 == $? ]]; then | ||
exit 1 | ||
fi | ||
|
||
while true; do | ||
# 得到Multilib 的版本号 | ||
version_file=$work_directory/version | ||
main_window $use_dialog $work_directory | ||
version=$(cat "$version_file") | ||
|
||
# 得到架构 | ||
arch_file=$work_directory/arch | ||
get_arch $use_dialog $work_directory | ||
arch=$(cat "$arch_file") | ||
|
||
# 构造缓存目录 | ||
cache_directory=/tmp/slacklib32/$version | ||
if [[ ! -e $cache_directory ]]; then | ||
mkdir -p $cache_directory | ||
fi | ||
|
||
# 安装Multilib | ||
install_multilib $use_dialog $cache_directory $version | ||
|
||
if [[ 0 == $? ]]; then | ||
break; | ||
fi | ||
done | ||
|
||
# 结尾的清理工作 | ||
rm -rf "$work_directory" | ||
|
||
exit 0 | ||
# } | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
# ===================================================== # | ||
# 如有BUG 请提交Issues # | ||
# https://github.com/Arondight/slacklib32/issues # | ||
# # | ||
# Copyright (C) 2014-2015 秦凡东 # | ||
# ===================================================== # | ||
|
||
cwd=$(dirname $(readlink -f $0)) | ||
exec_target='/usr/local/bin/slacklib32' | ||
exec_file="$cwd/bin/slacklib32.sh" | ||
lib_target='/usr/local/lib' | ||
lib_dir="$cwd/lib" | ||
lib_files=('check_environment.sh' 'get_arch.sh' 'install_multilib.sh' 'main_window.sh') | ||
answer='' | ||
|
||
if [[ 0 -ne $UID ]]; then | ||
echo "请使用root 权限运行$0。" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -e $exec_file ]]; then | ||
echo "未发现文件${exec_file},请尝试重新下载项目。" | ||
exit 1 | ||
fi | ||
|
||
if [[ -e $exec_target ]]; then | ||
read -p '发现系统内已经存在一份slacklib32,要覆盖它吗?(Y/n)' answer | ||
if [[ 'Y' != $answer ]]; then | ||
echo '确认询问未通过,slacklib32 未安装。' | ||
exit 1 | ||
fi | ||
fi | ||
|
||
cp -f "$exec_file" "$exec_target" | ||
|
||
i=0 | ||
while [[ $i < ${#lib_files[@]} ]]; do | ||
lib_files[$i]=$lib_dir/${lib_files[$i]} | ||
|
||
if [[ ! -e ${lib_files[$i]} ]]; then | ||
echo "某些脚本缺失,请尝试重新下载项目。" | ||
exit 1 | ||
fi | ||
|
||
let ++i | ||
done | ||
|
||
# now answer is yes | ||
for lib_file in ${lib_files[@]}; do | ||
cp -f "$lib_file" "$lib_target" | ||
done | ||
|
||
if [[ 0 -eq $? ]]; then | ||
echo "已经安装到$exec_target。" | ||
else | ||
exit $? | ||
fi | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# ===================================================== # | ||
# 如有BUG 请提交Issues # | ||
# https://github.com/Arondight/slacklib32/issues # | ||
# # | ||
# Copyright (C) 2014-2015 秦凡东 # | ||
# ===================================================== # | ||
|
||
# ========================= | ||
# check_environment | ||
# 检查脚本依赖环境是否满足 | ||
# 结果直接用return 语句返回 | ||
# ========================= | ||
function check_environment { | ||
local use_dialog | ||
local title='slacklib32' | ||
|
||
use_dialog=$1 | ||
shift | ||
|
||
# 无root 权限则退出 | ||
if [[ 0 -ne $UID ]]; then | ||
msgbox='请使用root 权限运行脚本。' | ||
|
||
if [[ true == $use_dialog ]]; then | ||
dialog --title "$title" --msgbox "$msgbox" 5 50 | ||
else | ||
echo "$msgbox" | ||
fi | ||
|
||
return 0 | ||
fi | ||
|
||
# 不是Slackware Linux 则退出 | ||
if [[ ! -r /etc/slackware-version ]]; then | ||
msgbox=$( | ||
cat <<EOM | ||
您的系统似乎不是Slackware。 | ||
如果的确是Slackware,请尝试重新安装aaa_base 软件包。 | ||
EOM | ||
) | ||
|
||
if [[ true == $use_dialog ]]; then | ||
dialog --title "$title" --msgbox "$msgbox" 10 50 | ||
else | ||
echo "$msgbox" | ||
fi | ||
|
||
return 0 | ||
fi | ||
|
||
# 无lftp 指令则退出 | ||
if ! type lftp >/dev/null 2>&1; then | ||
msgbox='lftp 指令未发现,请先安装lftp。' | ||
|
||
if [[ true == $use_dialog ]]; then | ||
dialog --title "$title" --msgbox "$msgbox" 5 50 | ||
else | ||
echo "$msgbox" | ||
fi | ||
|
||
return 0 | ||
fi | ||
|
||
return 1 | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# ===================================================== # | ||
# 如有BUG 请提交Issues # | ||
# https://github.com/Arondight/slacklib32/issues # | ||
# # | ||
# Copyright (C) 2014-2015 秦凡东 # | ||
# ===================================================== # | ||
|
||
# ========================= | ||
# get_arch | ||
# 获得机器的架构 | ||
# 结果存入$arch_file | ||
# ========================= | ||
function get_arch () { | ||
local arch | ||
local use_dialog | ||
local work_directory | ||
local arch_file | ||
local title='slacklib32' | ||
|
||
use_dialog=$1 | ||
shift | ||
work_directory=$1 | ||
arch_file=$work_directory/arch | ||
shift | ||
arch=$(uname -m) | ||
|
||
if ! echo $arch | grep -P '64' >/dev/null 2>&1; then | ||
msgbox='当前系统不是64 位系统。' | ||
|
||
if [[ true == $use_dialog ]]; then | ||
dialog --title "$title" --msgbox "$msgbox" 10 50 | ||
else | ||
echo "$msgbox" | ||
fi | ||
|
||
exit 1 | ||
else | ||
echo "$arch" > "$arch_file" | ||
fi | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# ===================================================== # | ||
# 如有BUG 请提交Issues # | ||
# https://github.com/Arondight/slacklib32/issues # | ||
# # | ||
# Copyright (C) 2014-2015 秦凡东 # | ||
# ===================================================== # | ||
|
||
# ========================= | ||
# install_multilib | ||
# 下载并安装Multilib | ||
# 结果以return 语句返回 | ||
# ========================= | ||
function install_multilib () { | ||
local use_dialog | ||
local version | ||
local cache_directory | ||
local delete | ||
local title='slacklib32' | ||
|
||
use_dialog=$1 | ||
shift | ||
cache_directory=$1 | ||
shift | ||
version=$1 | ||
shift | ||
|
||
# 下载Multilib 安装包 | ||
lftp -c "open http://slackware.com/~alien/multilib/; mirror -c -e $version $cache_directory;" | ||
if [[ 0 != $? ]]; then | ||
msgbox=$( | ||
cat <<EOF | ||
无法下载对应的Multilib 安装包,可能是因为: | ||
1. 无法连接到网络 | ||
2. 版本号不正确 | ||
EOF | ||
) | ||
if [[ true == $use_dialog ]]; then | ||
dialog --title "$title" --msgbox "$msgbox" 10 50 | ||
else | ||
echo "$msgbox" | ||
fi | ||
|
||
return 1 | ||
fi | ||
|
||
# 安装 | ||
find "$cache_directory" \ | ||
-name '*.t?z' \ | ||
-exec /sbin/upgradepkg --reinstall --install-new {} \; | ||
|
||
# 清理:Slackware 的/tmp 目录默认不是tmpfs 的挂载点 | ||
yesno="是否删除缓存的Multilib 安装包($cache_directory)?" | ||
if [[ true == $use_dialog ]]; then | ||
dialog --title "$title" --yesno "$yesno" 5 50; | ||
if [[ 0 == $? ]]; then | ||
delete=true | ||
else | ||
delete=false | ||
fi | ||
else | ||
read -p "$yesno(y/n)" delete | ||
delete=$(echo $delete | tr '[:lower:]' '[:upper:]') | ||
if [[ 'Y' == $delete ]]; then | ||
delete=true | ||
else | ||
delete=false | ||
fi | ||
fi | ||
if [[ true == $delete ]]; then | ||
rm --verbose --recursive --force $cache_directory | ||
fi | ||
|
||
return 0 | ||
} | ||
|
Oops, something went wrong.