33FPKGDIR=" /usr/local/fpkg/" # where all packages are located at
44EDIOR=" vim" # change this to your favorite editor
55
6- VERSION=" 2.0 .0" # not sure why i want a variable for that honestly
6+ VERSION=" 2.1 .0" # not sure why i want a variable for that honestly
77
88quit () {
99 popd > /dev/null # restore user's working directory
@@ -83,7 +83,13 @@ case $1 in
8383 " install" | " i" )
8484 exist_check $2
8585
86- ./ii/$2 .ii
86+ ./ii/$2 .ii install
87+ ;;
88+
89+ " remove" | " r" )
90+ exist_check $2
91+
92+ ./ii/$2 .ii remove
8793 ;;
8894
8995 " list" | " l" )
@@ -95,12 +101,33 @@ case $1 in
95101 " add" | " a" )
96102 write_check
97103
98- exist_check $2
104+ if [[ -z $1 ]]; then
105+ error " package name was not provided!"
106+ fi
99107
100108 stty echo
109+
110+ # add the package to the list
101111 echo $2 >> pkg.list
102- echo -e " # Writing installation instructions for package $2 " \\ n > ii/$pkg_name .ii
112+
113+ # write a template for it to make it easier for the user
114+ echo -e " # Installation instructions for package $2 " \\ n > ii/$2 .ii
115+ echo " # Inside install (), write the commands for" >> ii/$2 .ii
116+ echo " # installing the package," >> ii/$2 .ii
117+ echo " # and inside remove (), write the commands for" >> ii/$2 .ii
118+ echo -e " # uninstalling it too." \\ n >> ii/$2 .ii
119+
120+ echo -e " install () {" \\ n\\ n" }" \\ n >> ii/$2 .ii
121+ echo -e " remove () {" \\ n\\ n" }" \\ n >> ii/$2 .ii
122+
123+ # this is necessary for being able to call one of the functions when needed
124+ echo " call=\$ 1; \$ call" >> ii/$2 .ii
125+
126+ # open up the text editor so that the user can write on
127+ # that template
103128 $EDITOR ii/$2 .ii
129+
130+ # finally, make it executable so that fpkg can run it
104131 chmod +x ii/$2 .ii
105132 ;;
106133
@@ -115,11 +142,12 @@ case $1 in
115142
116143 exist_check $2
117144
118- export FPKGDIR=$FPKGDIR
119- export PKG_DIR=$2
120- sh -c ' cd $FPKGDIR/$PKG_DIR;
121- echo "Working on $PKG_DIR/, ^D to exit";
122- exec "${SHELL:-sh}"'
145+ export FPKGDIR # those are necessary to make it able to start the
146+ export PKG_DIR=$2 # shell at the desired directory
147+
148+ sh -c ' cd $FPKGDIR/$PKG_DIR; # change to the directory
149+ echo "Working on $PKG_DIR/, ^D to exit"; # make the user aware of it
150+ exec bash --rcfile $FPKGDIR/.bashrc' # and here it goes
123151 ;;
124152
125153 # editing a package's .ii?
@@ -183,6 +211,7 @@ case $1 in
183211 echo " help | h - shows this help message"
184212 echo " update | u - git pull every package listed in pkg.list"
185213 echo " install | i <pkg> - install <pkg> using $FPKGDIR /ii/<pkg>.ii"
214+ echo " remove | r <pkg> - uninstall <pkg> using $FPKGDIR /ii/<pkg>.ii also"
186215 echo " list | l - list registered packages"
187216 echo " add | a <pkg> - register <pkg>"
188217 echo " peek | p <pkg> - take a peek at <pkg>'s .ii"
0 commit comments