mirror of
https://gitdl.cn/https://github.com/chakralinux/lib32.git
synced 2025-01-23 17:33:34 +08:00
initial sync* scripts;
This commit is contained in:
parent
9e374ec31c
commit
420b4f351f
114
check-files.sh
Executable file
114
check-files.sh
Executable file
@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#
|
||||
# setup
|
||||
#
|
||||
_script_name="Check files"
|
||||
_build_arch="$_arch"
|
||||
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
|
||||
_needed_functions="config_handling helpers messages"
|
||||
# load functions
|
||||
for subroutine in ${_needed_functions}
|
||||
do
|
||||
source _buildscripts/functions/${subroutine}
|
||||
done
|
||||
|
||||
#
|
||||
# startup
|
||||
#
|
||||
title "${_script_name} - $_cur_repo"
|
||||
|
||||
check_configs
|
||||
load_configs
|
||||
|
||||
check_rsync
|
||||
check_accounts
|
||||
|
||||
question() {
|
||||
local mesg=$1; shift
|
||||
echo -e -n "\033[1;32m::\033[1;0m\033[1;0m ${mesg}\033[1;0m"
|
||||
}
|
||||
|
||||
sync_down()
|
||||
{
|
||||
title2 "syncing down"
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
rsync -avh --progress $_rsync_user@$_rsync_server::$_rsync_dir/* _repo/remote/
|
||||
}
|
||||
|
||||
remove_packages()
|
||||
{
|
||||
# remove the package(s) from _repo/remote
|
||||
title2 "removing the packages(s) from _repo/remote"
|
||||
pushd _repo/remote &>/dev/null
|
||||
rm -rf $remove_list
|
||||
popd &>/dev/null
|
||||
}
|
||||
|
||||
sync_down
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
|
||||
# Get the file list in the server
|
||||
repo_files=`rsync -avh --list-only $_rsync_user@$_rsync_server::$_rsync_dir/* | cut -d ":" -f 3 | cut -d " " -f 2`
|
||||
|
||||
# Get the file list in _repo/remote
|
||||
local_files=`ls -a _repo/remote/* | cut -d "/" -f 3`
|
||||
|
||||
|
||||
remove_list=""
|
||||
for parse_file in $local_files
|
||||
do
|
||||
file_exist="false"
|
||||
for compare_file in $repo_files
|
||||
do
|
||||
if [ "$parse_file" = "$compare_file" ] ; then
|
||||
file_exist="true"
|
||||
fi
|
||||
done
|
||||
if [ "$file_exist" = "false" ] ; then
|
||||
remove_list="$remove_list $parse_file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$remove_list" != "" ] ; then
|
||||
title2 "The following packages in _repo/remote don't exist in the sever:"
|
||||
newline
|
||||
echo "$remove_list"
|
||||
newline
|
||||
question "Do you want to remove the package(s)? (y/n)"
|
||||
while true; do
|
||||
read yn
|
||||
case $yn in
|
||||
y* | Y* )
|
||||
newline ;
|
||||
remove_packages;
|
||||
break
|
||||
;;
|
||||
[nN]* )
|
||||
newline ;
|
||||
title "The files will be keeped..." ;
|
||||
newline ;
|
||||
break
|
||||
;;
|
||||
* )
|
||||
echo "Enter yes or no"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
title "All done"
|
||||
newline
|
141
rmpkg.sh
Executable file
141
rmpkg.sh
Executable file
@ -0,0 +1,141 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#
|
||||
# (c) 2010 - Manuel Tortosa <manutortosa[at]chakra-project[dot]org>
|
||||
|
||||
#
|
||||
# Global setup
|
||||
#
|
||||
_script_name="Remove Package(s)"
|
||||
_build_arch="$_arch"
|
||||
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
|
||||
_needed_functions="config_handling helpers messages"
|
||||
|
||||
GET_PKGS=`echo $1`
|
||||
|
||||
# Load functions
|
||||
for subroutine in ${_needed_functions}
|
||||
do
|
||||
source _buildscripts/functions/${subroutine}
|
||||
done
|
||||
|
||||
question() {
|
||||
local mesg=$1; shift
|
||||
echo -e -n "\033[1;32m::\033[1;0m\033[1;0m ${mesg}\033[1;0m"
|
||||
}
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
sync_down()
|
||||
{
|
||||
# download all the packages from the repo
|
||||
title2 "syncing down, please wait..."
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
rsync -avh --progress $_rsync_user@$_rsync_server::$_rsync_dir/* _repo/remote/
|
||||
}
|
||||
|
||||
remove_packages()
|
||||
{
|
||||
# remove the package(s) from _repo/remote
|
||||
title2 "removing the packages(s) from _repo/remote"
|
||||
pushd _repo/remote &>/dev/null
|
||||
rm -rf $PKGS_TO_REMOVE
|
||||
popd &>/dev/null
|
||||
}
|
||||
|
||||
sync_up()
|
||||
{
|
||||
# create new pacman database
|
||||
title2 "creating pacman database, please wait..."
|
||||
rm -rf _repo/remote/*.db.tar.gz &>/dev/null
|
||||
pushd _repo/remote/ &>/dev/null
|
||||
repo-add $_cur_repo.db.tar.gz *.pkg.* &>/dev/null
|
||||
popd &>/dev/null
|
||||
|
||||
# sync local -> server, removing the packages
|
||||
title2 "syncing up"
|
||||
rsync -avh --progress --delay-updates --delete-after _repo/remote/ $_rsync_user@$_rsync_server::$_rsync_dir
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# startup
|
||||
#
|
||||
clear
|
||||
title "${_script_name} - $_cur_repo-$_build_arch"
|
||||
|
||||
if [ "$GET_PKGS" = "" ] ; then
|
||||
error "You need to especify a target to remove,"
|
||||
error "single names like \"attica\" or wildcards (*) are allowed."
|
||||
newline
|
||||
exit 1
|
||||
fi
|
||||
|
||||
check_configs
|
||||
load_configs
|
||||
|
||||
check_rsync
|
||||
check_accounts
|
||||
|
||||
# First get the actual packages from the repo
|
||||
sync_down
|
||||
|
||||
# Generate the list of packages to remove
|
||||
newline
|
||||
GET_PKGS=$GET_PKGS-*
|
||||
PKGS_TO_REMOVE=`ls _repo/remote/$GET_PKGS | cut -d "/" -f3`
|
||||
|
||||
if [ "$PKGS_TO_REMOVE" = "" ] ; then
|
||||
error "exiting..."
|
||||
exit
|
||||
fi
|
||||
|
||||
title2 "The following packages will be removed:"
|
||||
newline
|
||||
echo "$PKGS_TO_REMOVE"
|
||||
|
||||
newline
|
||||
question "Do you really want to remove the package(s)? (y/n)"
|
||||
while true; do
|
||||
read yn
|
||||
case $yn in
|
||||
y* | Y* )
|
||||
newline ;
|
||||
remove_packages ;
|
||||
sync_up ;
|
||||
newline ;
|
||||
title "All done" ;
|
||||
newline ;
|
||||
break
|
||||
;;
|
||||
|
||||
[nN]* )
|
||||
newline ;
|
||||
title "Removal avorted, exiting..." ;
|
||||
newline ;
|
||||
break
|
||||
;;
|
||||
|
||||
q* )
|
||||
exit
|
||||
;;
|
||||
|
||||
* )
|
||||
echo "Enter yes or no"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
140
sync-complete.sh
Executable file
140
sync-complete.sh
Executable file
@ -0,0 +1,140 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#
|
||||
# setup
|
||||
#
|
||||
_script_name="sync complete"
|
||||
_build_arch="$_arch"
|
||||
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
|
||||
_needed_functions="config_handling helpers messages"
|
||||
# load functions
|
||||
for subroutine in ${_needed_functions}
|
||||
do
|
||||
source _buildscripts/functions/${subroutine}
|
||||
done
|
||||
|
||||
question() {
|
||||
local mesg=$1; shift
|
||||
echo -e -n "\033[1;32m::\033[1;0m\033[1;0m ${mesg}\033[1;0m"
|
||||
}
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
|
||||
remove_packages()
|
||||
{
|
||||
# remove the package(s) from _repo/remote
|
||||
title2 "removing the packages(s) from _repo/remote"
|
||||
pushd _repo/remote &>/dev/null
|
||||
rm -rf $remove_list
|
||||
popd &>/dev/null
|
||||
}
|
||||
|
||||
check_files()
|
||||
{
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
# Get the file list in the server
|
||||
repo_files=`rsync -avh --list-only $_rsync_user@$_rsync_server::$_rsync_dir/* | cut -d ":" -f 3 | cut -d " " -f 2`
|
||||
# Get the file list in _repo/remote
|
||||
local_files=`ls -a _repo/remote/* | cut -d "/" -f 3`
|
||||
remove_list=""
|
||||
for parse_file in $local_files
|
||||
do
|
||||
file_exist="false"
|
||||
for compare_file in $repo_files
|
||||
do
|
||||
if [ "$parse_file" = "$compare_file" ] ; then
|
||||
file_exist="true"
|
||||
fi
|
||||
done
|
||||
if [ "$file_exist" = "false" ] ; then
|
||||
remove_list="$remove_list $parse_file"
|
||||
fi
|
||||
done
|
||||
if [ "$remove_list" != "" ] ; then
|
||||
title2 "The following packages in _repo/remote don't exist in the sever:"
|
||||
newline
|
||||
echo "$remove_list"
|
||||
newline
|
||||
question "Do you want to remove the package(s)? (y/n)"
|
||||
while true; do
|
||||
read yn
|
||||
case $yn in
|
||||
y* | Y* )
|
||||
newline ;
|
||||
remove_packages;
|
||||
break
|
||||
;;
|
||||
[nN]* )
|
||||
newline ;
|
||||
title "The files will be keeped..." ;
|
||||
newline ;
|
||||
break
|
||||
;;
|
||||
* )
|
||||
echo "Enter yes or no"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
sync_complete()
|
||||
{
|
||||
title2 "syncing down"
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
rsync -avh --progress $_rsync_user@$_rsync_server::$_rsync_dir/* _repo/remote/
|
||||
|
||||
title2 "Searching removed files"
|
||||
check_files
|
||||
|
||||
# move new packages from $ROOT/repos/$REPO/build into thr repo dir
|
||||
title2 "adding new packages"
|
||||
mv -v _repo/local/*.pkg.* _repo/remote/
|
||||
|
||||
# run repo-clean on it
|
||||
title2 "running repo-clean"
|
||||
repo-clean -m c -s _repo/remote/
|
||||
|
||||
# create new pacman database
|
||||
title2 "creating pacman database"
|
||||
rm -rf _repo/remote/*.db.tar.gz
|
||||
pushd _repo/remote/
|
||||
repo-add $_cur_repo.db.tar.gz *.pkg.*
|
||||
popd
|
||||
|
||||
# sync local -> server
|
||||
title2 "syncing up"
|
||||
rsync -avh --progress --delay-updates --delete-after _repo/remote/ $_rsync_user@$_rsync_server::$_rsync_dir
|
||||
}
|
||||
|
||||
#
|
||||
# startup
|
||||
#
|
||||
title "${_script_name} - $_cur_repo"
|
||||
|
||||
check_configs
|
||||
load_configs
|
||||
|
||||
check_rsync
|
||||
check_accounts
|
||||
|
||||
time sync_complete
|
||||
newline
|
||||
|
||||
title "All done"
|
||||
newline
|
54
sync-down.sh
Executable file
54
sync-down.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#
|
||||
# setup
|
||||
#
|
||||
_script_name="sync down"
|
||||
_build_arch="$_arch"
|
||||
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
|
||||
_needed_functions="config_handling helpers messages"
|
||||
# load functions
|
||||
for subroutine in ${_needed_functions}
|
||||
do
|
||||
source _buildscripts/functions/${subroutine}
|
||||
done
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
sync_down()
|
||||
{
|
||||
title2 "syncing down"
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
rsync -avh --progress $_rsync_user@$_rsync_server::$_rsync_dir/* _repo/remote/
|
||||
}
|
||||
|
||||
#
|
||||
# startup
|
||||
#
|
||||
title "${_script_name} - $_cur_repo"
|
||||
|
||||
check_configs
|
||||
load_configs
|
||||
|
||||
check_rsync
|
||||
check_accounts
|
||||
|
||||
time sync_down
|
||||
newline
|
||||
|
||||
title "All done"
|
||||
newline
|
60
sync-up-nodb.sh
Executable file
60
sync-up-nodb.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#
|
||||
# setup
|
||||
#
|
||||
_script_name="sync down nodb"
|
||||
_build_arch="$_arch"
|
||||
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
|
||||
_needed_functions="config_handling helpers messages"
|
||||
# load functions
|
||||
for subroutine in ${_needed_functions}
|
||||
do
|
||||
source _buildscripts/functions/${subroutine}
|
||||
done
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
sync_up()
|
||||
{
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
|
||||
# move new packages from $ROOT/repos/$REPO/build into thr repo dir
|
||||
title2 "adding new packages"
|
||||
mv -v _repo/local/*.pkg* _repo/remote/
|
||||
|
||||
# sync local -> server
|
||||
title2 "upload pkgs to server"
|
||||
rsync -avh --progress --delay-updates _repo/remote/ $_rsync_user@$_rsync_server::$_rsync_dir
|
||||
}
|
||||
|
||||
#
|
||||
# startup
|
||||
#
|
||||
title "${_script_name} - $_cur_repo"
|
||||
|
||||
check_configs
|
||||
load_configs
|
||||
|
||||
check_rsync
|
||||
check_accounts
|
||||
|
||||
time sync_up
|
||||
newline
|
||||
|
||||
title "All done"
|
||||
newline
|
70
sync-up.sh
Executable file
70
sync-up.sh
Executable file
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#
|
||||
# setup
|
||||
#
|
||||
_script_name="sync up"
|
||||
_build_arch="$_arch"
|
||||
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
|
||||
_needed_functions="config_handling helpers messages"
|
||||
# load functions
|
||||
for subroutine in ${_needed_functions}
|
||||
do
|
||||
source _buildscripts/functions/${subroutine}
|
||||
done
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
sync_up()
|
||||
{
|
||||
export RSYNC_PASSWORD=`echo $_rsync_pass`
|
||||
|
||||
# move new packages from $ROOT/repos/$REPO/build into thr repo dir
|
||||
title2 "adding new packages"
|
||||
mv -v _repo/local/*.pkg.* _repo/remote/
|
||||
|
||||
# run repo-clean on it
|
||||
title2 "running repo-clean"
|
||||
repo-clean -m c -s _repo/remote/
|
||||
|
||||
# create new pacman database
|
||||
title2 "creating pacman database"
|
||||
rm -rf _repo/remote/*.db.tar.*
|
||||
pushd _repo/remote/
|
||||
repo-add $_cur_repo.db.tar.gz *.pkg.*
|
||||
popd
|
||||
|
||||
# sync local -> server
|
||||
title2 "sync local -> server"
|
||||
rsync -avh --progress --delay-updates --delete-after _repo/remote/ $_rsync_user@$_rsync_server::$_rsync_dir
|
||||
}
|
||||
|
||||
#
|
||||
# startup
|
||||
#
|
||||
title "${_script_name} - $_cur_repo"
|
||||
|
||||
check_configs
|
||||
load_configs
|
||||
|
||||
check_rsync
|
||||
check_accounts
|
||||
|
||||
time sync_up
|
||||
|
||||
title "All done"
|
||||
newline
|
Loading…
Reference in New Issue
Block a user