Merge branch 'restructure-add-base-proj' into restructure-as-describe-in-doc

This commit is contained in:
6543 2018-05-21 16:21:10 +02:00
commit 7601e2b93f
4 changed files with 72 additions and 4 deletions

View File

@ -3,6 +3,6 @@
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; } [ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }


#<PROJECT_NAME> #<PROJECT_NAME>
# . -> <PROJECT_PARENT> -> <PROJECT_BASE> #<project_relation>
source <LIBDIR>/proj/<PROJECT_PARENT> source <LIBDIR>/proj/<BASE>
project_relation="<PROJECT_NAME> $project_relation" project_relation="<PROJECT_NAME> $project_relation"

34
script/add_project.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash

#check param
[ -z "$1" ] && { echo "$0 \"name\" [base]"; exit 1; }
name="$1"
base="$2"

#gen project
cp "doc/proj-head" "src/proj/$name"

#set base_relations
if [ -z "$base" ]; then
base_relations="base"
base="base"
sed -i "/project_relation=/c\project_relation=\"<PROJECT_NAME>\"" "src/proj/$name"
else
[ -f "src/proj/$base" ] || {
echo "BASE: $base dont exist"
exit 1
}
#get base of $base
base_base=`grep '# . ->' src/proj/$base`
base_relations=`echo $base_base | sed "s/#\ \./$base/g"`
fi

## replace strings
# . -> <PROJECT_PARENT> -> base
sed -i "s/<project_relation>/\ \.\ ->\ $base_relations/g" "src/proj/$name"
#<PROJECT_NAME>
sed -i "s/<PROJECT_NAME>/$name/g" "src/proj/$name"
sed -i "s/<BASE>/$base/g" "src/proj/$name"

#open
editor "src/proj/$name"

30
src/proj/base Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
#remaster lib
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }

##################
##### B a s e ####
##################
# .
project_relation=""
[ -z "$project" ] && project=base

#tools_add [chroot_dir] [tools_list]
function tools_add() {
echo "$project: tools_add ot available"
}

#os_update [chroot_dir]
function os_update() {
echo "$project: os_update ot available"
}

#proxy_enable [chroot_dir] [proxy_host] [proxy_port]
function proxy_enable() {
echo "$project: proxy_enable ot available"
}

#dns_set [chroot_dir] [domain] [nameserver]
function dns_set() {
echo "$project: dns_set ot available"
}

View File

@ -2,11 +2,15 @@
#remaster lib #remaster lib
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; } [ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }


source <LIBDIR>/proj/base
#debian
# . -> base
project_relation="debian"

#################################### ####################################
##### Base Template D E B I A N #### ##### Base Template D E B I A N ####
#################################### ####################################
# .
project_relation="debian"


#tools_add [chroot_dir] [tools_list] #tools_add [chroot_dir] [tools_list]
function tools_add() { function tools_add() {