From ed9681e1bbbd58b926f0c716616f8a229edbd840 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Wed, 2 Aug 2017 23:46:06 +0800 Subject: [PATCH] updated --- buildpkg | 17 +------ functions | 17 ++++++- install.sh | 2 - installpkg | 8 +--- removepkg | 8 +--- scratch | 80 +++++++++---------------------- scratchpkg.conf | 19 ++++---- scratchpkg.conf.d/ports/base.git | 1 - scratchpkg.conf.d/ports/blfs.git | 1 - scratchpkg.conf.d/ports/extra.git | 1 - scratchpkg.conf.d/ports/xorg.git | 1 - scratchpkg.conf.d/purge | 1 - 12 files changed, 53 insertions(+), 103 deletions(-) delete mode 100644 scratchpkg.conf.d/ports/base.git delete mode 100644 scratchpkg.conf.d/ports/blfs.git delete mode 100644 scratchpkg.conf.d/ports/extra.git delete mode 100644 scratchpkg.conf.d/ports/xorg.git delete mode 100755 scratchpkg.conf.d/purge diff --git a/buildpkg b/buildpkg index f370064..3493af4 100755 --- a/buildpkg +++ b/buildpkg @@ -247,14 +247,12 @@ packaging() { purgefiles() { - if [ -f /etc/scratchpkg.conf.d/$PURGE_FILE ]; then - for option in $(cat /etc/scratchpkg.conf.d/$PURGE_FILE); do + for option in ${PURGE_FILE[@]}; do if [ -e $option ]; then msg2 "Purging $option..." rm -fr $option fi done - fi } strip_files() { @@ -468,13 +466,7 @@ main() { . /usr/share/scratchpkg/functions || exit 1 - ### LOAD CONFIGURATION FILE ### - if [ -f $CONF_FILE ]; then - . $CONF_FILE - else - msg "${color_red}Configuration file not found.${color_reset}" - exit 1 - fi + loadconfigfile parse_options "$@" @@ -505,11 +497,6 @@ main() { PKGNAME="$name#$version-$release.spkg.txz" - ### SET NO STRIP ### - #if [ $NO_STRIP ]; then - # STRIP_PACKAGE="no" - #fi - ### UPDATE CHECKSUM ### if [ "$UPDATE_CHECKSUM" ]; then getsource diff --git a/functions b/functions index ce597be..c773bc7 100644 --- a/functions +++ b/functions @@ -19,7 +19,6 @@ color_reset='\e[0m' #Reset color ### DECLARE SOME VALUE ### CONF_FILE="/etc/scratchpkg.conf" -PURGE_FILE="purge" BUILD_SCRIPT="spkgbuild" ROOT_DIR=/ @@ -142,6 +141,22 @@ getpkginfofrompkg() { } +loadconfigfile() { + + if [ -f $CONF_FILE ]; then + . $CONF_FILE + PACKAGE_DIR=$(cat $CONF_FILE | grep ^'# PACKAGE_DIR' | tr -d '=' | tr -d '"' | cut -d ' ' -f 3-) + SOURCE_DIR=$(cat $CONF_FILE | grep ^'# SOURCE_DIR' | tr -d '=' | tr -d '"' | cut -d ' ' -f 3-) + WORK_DIR=$(cat $CONF_FILE | grep ^'# WORK_DIR' | tr -d '=' | tr -d '"' | cut -d ' ' -f 3-) + PORT_REPO=$(cat $CONF_FILE | grep ^'# PORT_REPO' | tr -d '=' | tr -d '"' | cut -d ' ' -f 3-) + PURGE_FILE=$(cat $CONF_FILE | grep ^'# PURGE_FILE' | tr -d '=' | tr -d '"' | cut -d ' ' -f 3-) + else + msg "${color_red}Configuration file not found.${color_reset}" + exit 1 + fi + +} + createtemplate() { if [ -d $TEMPLATE_NAME ]; then diff --git a/install.sh b/install.sh index 3e35c7f..f536b93 100755 --- a/install.sh +++ b/install.sh @@ -18,10 +18,8 @@ fi if [ ! -d $confdir ]; then mkdir -pv $confdir [ ! -f $confdir/scratchpkg.conf ] && cp -v scratchpkg.conf $confdir - [ ! -d $confdir/scratchpkg.conf.d ] && cp -Rv scratchpkg.conf.d $confdir else [ ! -f $confdir/scratchpkg.conf ] && cp -v scratchpkg.conf $confdir || echo "$confdir/scratchpkg.conf exists" - [ ! -d $confdir/scratchpkg.conf.d ] && cp -Rv scratchpkg.conf.d $confdir || echo "$confdir/scratchpkg.conf.d exists" fi if [ ! -d $funcdir ]; then diff --git a/installpkg b/installpkg index c32190d..c852684 100755 --- a/installpkg +++ b/installpkg @@ -303,13 +303,7 @@ main() { nocolor fi - ### LOAD CONFIGURATION FILE ### - if [ -f $CONF_FILE ]; then - . $CONF_FILE - else - msg "${color_red}Configuration file not found.${color_reset}" - exit 1 - fi + loadconfigfile ### CHECK IF PACKAGE IS VALID PACKAGE ### #if [ ! $(tar -tf "$PACKAGE_INFO" | grep ".pkginfo") ]; then diff --git a/removepkg b/removepkg index 7ce6825..bf32e1d 100755 --- a/removepkg +++ b/removepkg @@ -174,13 +174,7 @@ main() { nocolor fi - ### LOAD CONFIGURATION FILE ### - if [ -f $CONF_FILE ]; then - . $CONF_FILE - else - msg "${color_red}Configuration file not found.${color_reset}" - exit 1 - fi + loadconfigfile ### CHECK FOR ROOT ACCESS ### if [ "$UID" != "0" ]; then diff --git a/scratch b/scratch index 9868b14..7c1c476 100755 --- a/scratch +++ b/scratch @@ -24,8 +24,8 @@ run_installpkg() { pushtoport() { for port in ${PORT_REPO[@]}; do - if [ -d $PORT_DIR/$port/$PORTNAME ]; then - pushd $PORT_DIR/$port/$PORTNAME + if [ -d $port/$PORTNAME ]; then + pushd $port/$PORTNAME if [ -d $INDEX_DIR/fakeroot ] && [ -d $INDEX_DIR/sudo ] && [ "$UID" != "0" ]; then fakeroot buildpkg if [ $? = 0 ]; then @@ -89,25 +89,26 @@ searchpkg() { for port in ${PORT_REPO[@]}; do OUTPUT=() - if [ -d $PORT_DIR/$port ]; then - for list in $(ls $PORT_DIR/$port); do - if [ -d $PORT_DIR/$port/$list ]; then - if [ "$(cat $PORT_DIR/$port/$list/$BUILD_SCRIPT | grep ^'# description' | tr -d ':' | cut -d ' ' -f 3- | grep -i $SEARCH_PKG)" ] || [ "$(echo $list | grep -i $SEARCH_PKG)" ]; then + if [ -d $port ]; then + for list in $(ls $port); do + if [ -f $port/$list/$BUILD_SCRIPT ]; then + if [ "$(cat $port/$list/$BUILD_SCRIPT | grep ^'# description' | tr -d ':' | cut -d ' ' -f 3- | grep -i $SEARCH_PKG)" ] || [ "$(echo $list | grep -i $SEARCH_PKG)" ]; then OUTPUT+=($list) fi fi done for out in ${OUTPUT[@]}; do - if [ -f $PORT_DIR/$port/$out/$BUILD_SCRIPT ]; then - pushd $PORT_DIR/$port/$out + if [ -f $port/$out/$BUILD_SCRIPT ]; then + pushd $port/$out getpkginfo . $BUILD_SCRIPT popd if [ ! -z "$name" ] && [ ! -z "$version" ] && [ ! -z "$release" ]; then + portname=$(basename $port) if [ -d $INDEX_DIR/$name ]; then - msg "($port) ${color_green}$name${color_reset} $version-$release $description" + msg "($portname) ${color_green}$name${color_reset} $version-$release $description" else - msg "($port) $name $version-$release $description" + msg "($portname) $name $version-$release $description" fi unset description fi @@ -203,8 +204,8 @@ showpackageinfo() { showdepends() { for portdepends in ${PORT_REPO[@]}; do - if [ -f $PORT_DIR/$portdepends/$PACKAGE_DEPENDS/$BUILD_SCRIPT ]; then - pushd $PORT_DIR/$portdepends/$PACKAGE_DEPENDS + if [ -f $portdepends/$PACKAGE_DEPENDS/$BUILD_SCRIPT ]; then + pushd $portdepends/$PACKAGE_DEPENDS getpkginfo . $BUILD_SCRIPT popd @@ -222,7 +223,7 @@ showdepends() { else PORT_EXIST=no for port in ${PORT_REPO[@]}; do - if [ -f $PORT_DIR/$port/$dep/$BUILD_SCRIPT ]; then + if [ -f $port/$dep/$BUILD_SCRIPT ]; then PORT_EXIST=yes break fi @@ -240,7 +241,7 @@ showdepends() { else PORT_EXIST=no for port in ${PORT_REPO[@]}; do - if [ -f $PORT_DIR/$port/$mdep/$BUILD_SCRIPT ]; then + if [ -f $port/$mdep/$BUILD_SCRIPT ]; then PORT_EXIST=yes break fi @@ -257,8 +258,8 @@ showupdate() { for package_name in $(ls $INDEX_DIR); do for port in ${PORT_REPO[@]}; do - if [ -f $PORT_DIR/$port/$package_name/$BUILD_SCRIPT ]; then - . $PORT_DIR/$port/$package_name/$BUILD_SCRIPT + if [ -f $port/$package_name/$BUILD_SCRIPT ]; then + . $port/$package_name/$BUILD_SCRIPT getinstalledname $name if [ "$name-$version-$release" != "$installedname" ]; then msg "$name ${color_red}$iversion-$irelease${color_reset} => ${color_green}$version-$release${color_reset}" @@ -297,10 +298,10 @@ showglobaldependent() { msg "Package ${color_red}$GLOBAL_PACKAGE_DEPENDENT${color_reset} not installed." fi for port in ${PORT_REPO[@]}; do - if [ -d $PORT_DIR/$port ]; then - for all in $(ls $PORT_DIR/$port); do - if [ -f $PORT_DIR/$port/$all/$BUILD_SCRIPT ]; then - depend=$(cat $PORT_DIR/$port/$all/$BUILD_SCRIPT | grep ^'# depends' | tr -d ':' | cut -d " " -f3-) + if [ -d $port ]; then + for all in $(ls $port); do + if [ -f $port/$all/$BUILD_SCRIPT ]; then + depend=$(cat $port/$all/$BUILD_SCRIPT | grep ^'# depends' | tr -d ':' | cut -d " " -f3-) for dep in ${depend[@]}; do if [ $dep = $GLOBAL_PACKAGE_DEPENDENT ]; then if [ -d $INDEX_DIR/$all ]; then @@ -316,28 +317,6 @@ showglobaldependent() { done } -syncports() { - - for port in ${PORT_REPO[@]}; do - if [ -f /etc/scratchpkg.conf.d/ports/$port.git ]; then - git_link=$(cat /etc/scratchpkg.conf.d/ports/$port.git) - pushd $PORT_DIR - if [ ! -d $port ]; then - mkdir $port - fi - if [ -d $port/.git ]; then - msg "Syncing ${color_green}$port${color_reset} from ${color_green}$git_link${color_reset}" - (cd $port && git pull) - else - git clone $git_link - fi - popd - else - msg "No git file for ${color_yellow}$port${color_reset}." - fi - done -} - interrupted() { echo "" msg "${color_yellow}Interrupted!${color_reset}" @@ -366,9 +345,6 @@ parse_options() { -cu|--check-update) CHECK_UPDATE=yes ;; - --sync) - SYNC_PORTS=yes - ;; --no-color) NO_COLOR=yes ;; @@ -463,19 +439,7 @@ main() { nocolor fi - ### LOAD CONFIGURATION FILE ### - if [ -f $CONF_FILE ]; then - . $CONF_FILE - else - msg "${color_red}Configuration file not found.${color_reset}" - exit 1 - fi - - ### SYNC PORTS ### - if [ $SYNC_PORTS ]; then - syncports - exit 0 - fi + loadconfigfile ### CREATE PORT TEMPLATE ### if [ $TEMPLATE_NAME ]; then diff --git a/scratchpkg.conf b/scratchpkg.conf index 9c9008a..9613cc3 100644 --- a/scratchpkg.conf +++ b/scratchpkg.conf @@ -1,13 +1,16 @@ +### CONFIGURATION FOR SCRATCHPKG (A SIMPLE PACKAGE MANAGER FOR LINUX FROM SCRATCH) ### + export CFLAGS="-O2 -march=x86-64 -pipe" export CXXFLAGS="${CFLAGS}" +export MAKEFLAGS="-j6" -export MAKEFLAGS='-j2' +# PACKAGE_DIR = /var/spkg/packages +# SOURCE_DIR = /var/spkg/sources +# WORK_DIR = /tmp -PACKAGE_DIR=/usr/scratch/packages -SOURCE_DIR=/usr/scratch/sources -WORK_DIR=/usr/scratch/work -PORT_DIR=/usr/scratch/ports +# PORT_REPO = /home/emmett/github/scratchpkgPorts/lfs-stable/base +# PORT_REPO = /home/emmett/github/scratchpkgPorts/lfs-stable/blfs +# PORT_REPO = /home/emmett/github/scratchpkgPorts/lfs-stable/xorg +# PORT_REPO = /home/emmett/github/scratchpkgPorts/extra -PORT_REPO="base blfs xorg extra tmp_ports" - -STRIP_PACKAGE="yes" +# PURGE_FILE = usr/share/locale diff --git a/scratchpkg.conf.d/ports/base.git b/scratchpkg.conf.d/ports/base.git deleted file mode 100644 index f32cd89..0000000 --- a/scratchpkg.conf.d/ports/base.git +++ /dev/null @@ -1 +0,0 @@ -https://github.com/emmett1/base \ No newline at end of file diff --git a/scratchpkg.conf.d/ports/blfs.git b/scratchpkg.conf.d/ports/blfs.git deleted file mode 100644 index b363dc7..0000000 --- a/scratchpkg.conf.d/ports/blfs.git +++ /dev/null @@ -1 +0,0 @@ -https://github.com/emmett1/blfs \ No newline at end of file diff --git a/scratchpkg.conf.d/ports/extra.git b/scratchpkg.conf.d/ports/extra.git deleted file mode 100644 index 5475a7e..0000000 --- a/scratchpkg.conf.d/ports/extra.git +++ /dev/null @@ -1 +0,0 @@ -https://github.com/emmett1/extra \ No newline at end of file diff --git a/scratchpkg.conf.d/ports/xorg.git b/scratchpkg.conf.d/ports/xorg.git deleted file mode 100644 index 8a9a967..0000000 --- a/scratchpkg.conf.d/ports/xorg.git +++ /dev/null @@ -1 +0,0 @@ -https://github.com/emmett1/xorg \ No newline at end of file diff --git a/scratchpkg.conf.d/purge b/scratchpkg.conf.d/purge deleted file mode 100755 index ac63ff3..0000000 --- a/scratchpkg.conf.d/purge +++ /dev/null @@ -1 +0,0 @@ -usr/share/locale \ No newline at end of file