Skip to content

Commit

Permalink
automataCI: finalized zip library
Browse files Browse the repository at this point in the history
Since we want to release soon, we must finalize the library. Hence,
let's deal with .zip library.

This patch finalizes zip library capabiltiies in automataCI/
directory.

Co-authored-by: Galyna, Cory <[email protected]>
Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]>
Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
  • Loading branch information
hollowaykeanho and corygalyna committed Dec 15, 2023
1 parent bd1ac53 commit 9524eae
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions automataCI/_package-archive_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PACKAGE::run_archive() {
fi

OS::print_status info "checking zip functions availability...\n"
ZIP::is_available
ZIP_Is_Available
if [ $? -ne 0 ]; then
OS::print_status error "check failed.\n"
return 1
Expand Down Expand Up @@ -115,7 +115,7 @@ PACKAGE::run_archive() {
windows)
_target_path="${_target_path}.zip"
OS::print_status info "packaging ${_target_path}\n"
ZIP::create "$_target_path" "*"
ZIP_Create "$_target_path" "*"
__exit=$?
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion automataCI/_package-chocolatey_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PACKAGE_Run_Chocolatey() {

# validate input
I18N_Status_Print_Check_Availability "ZIP"
ZIP::is_available
ZIP_Is_Available
if [ $? -ne 0 ]; then
I18N_Status_Print_Check_Availability_Incompatible "ZIP"
return 1
Expand Down
7 changes: 4 additions & 3 deletions automataCI/services/archive/zip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ function ZIP-Create {

# execute
try {
Compress-Archive -Path $___source -DestinationPath $___destination
if (Test-Path $___destination) {
$null = Compress-Archive -Path $___source -DestinationPath $___destination
$___process = FS-Is-File "${___destination}"
if ($___process -eq 0) {
return 0
}
} catch {
Expand Down Expand Up @@ -61,7 +62,7 @@ function ZIP-Extract {
# execute
try {
$null = FS-Make-Directory "${___destination}"
Expand-Archive -Path $___source -DestinationPath $___destination
$null = Expand-Archive -Path $___source -DestinationPath $___destination
} catch {
return 1
}
Expand Down
33 changes: 19 additions & 14 deletions automataCI/services/archive/zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
. "${LIBS_AUTOMATACI}/services/io/os.sh"
. "${LIBS_AUTOMATACI}/services/io/fs.sh"




ZIP::create() {
# __destination="$1"
# __source="$2"
ZIP_Create() {
#___destination="$1"
#___source="$2"


# validate input
ZIP::is_available
ZIP_Is_Available
if [ $? -ne 0 ]; then
return 1
fi


# execute
zip -9 -r "$1" $2
if [ $? -ne 0 ]; then
return 1
fi


# report status
if [ $? -eq 0 ]; then
return 0
fi

return 1
return 0
}


Expand All @@ -48,15 +48,18 @@ ZIP_Extract() {


# validate input
if [ -z "$(type -t unzip)" ]; then
OS::is_command_available "unzip"
if [ $? -ne 0 ]; then
return 1
fi

if [ ! -f "$___source" ]; then
FS::is_file "$___source"
if [ $? -ne 0 ]; then
return 1
fi

if [ -f "$___destination" ]; then
FS::is_file "$___destination"
if [ $? -eq 0 ]; then
return 1
fi

Expand All @@ -76,12 +79,14 @@ ZIP_Extract() {



ZIP::is_available() {
ZIP_Is_Available() {
# execute
if [ ! -z "$(type -t zip)" ]; then
OS::is_command_available "zip"
if [ $? -eq 0 ]; then
return 0
fi


# report status
return 1
}
4 changes: 2 additions & 2 deletions automataCI/services/publishers/chocolatey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ CHOCOLATEY_Archive() {
return 1
fi

ZIP::is_available
ZIP_Is_Available
if [ $? -ne 0 ]; then
return 1
fi


# execute
___current_path="$PWD" && cd "$2"
ZIP::create "$1" "*"
ZIP_Create "$1" "*"
___process=$?
cd "$___current_path" && unset ___current_path
if [ $___process -ne 0 ]; then
Expand Down

0 comments on commit 9524eae

Please sign in to comment.