Commit bc7d900b authored by claes's avatar claes

New package handler

parent 77685925
#!/bin/bash
pkg_install_func ()
{
if [ ! -e "$1" ]; then
echo "No package $1"
exit 1
fi
pkg=`eval locate $1`
pkg_remove_func "force"
echo "-- Installing package $1"
cd /tmp
if ! tar -xzf $pkg pkg_unpack.sh; then
echo "Package $1 incomplete"
exit 1
fi
chmod a+x pkg_unpack.sh
./pkg_unpack.sh
}
pkg_list_func ()
{
if [ -z $1 ]; then
# List installed package
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
exit 1
fi
datfile=$pwrp_load/pwr_pkg.dat
else
# Extract datfile from package
if [ ! -e $1 ]; then
echo "-- No such package"
exit 1
fi
pkg=`eval locate $1`
echo "-- Opening file $pkg"
cd /tmp
if ! tar -xzf $pkg pwr_pkg.dat; then
echo "Package $1 incomplete"
exit 1
fi
datfile=/tmp/pwr_pkg.dat
fi
{
let printout=0
while read line; do
if [ "$line" = "%Description:" ]; then
printout=1
else
if [ "$line" = "%Files:" ]; then
break
fi
if [ $printout -eq 1 ]; then
echo $line
fi
fi
done
} < $datfile
}
pkg_listfiles_func ()
{
if [ -z $1 ]; then
# List installed package
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
exit 1
fi
datfile=$pwrp_load/pwr_pkg.dat
else
# Extract datfile from package
if [ ! -e $1 ]; then
echo "-- No such package"
exit 1
fi
pkg=`eval locate $1`
echo "-- Opening file $pkg"
cd /tmp
if ! tar -xzf $pkg pwr_pkg.dat; then
echo "Package $1 incomplete"
exit 1
fi
datfile=/tmp/pwr_pkg.dat
fi
{
let printout=0
while read line date time; do
if [ "$line" = "%Files:" ]; then
printout=1
else
if [ "$line" = "%End:" ]; then
break
fi
if [ $printout -eq 1 ]; then
echo $date $time $line
fi
fi
done
} < $datfile
}
pkg_brief_func ()
{
if [ -z $1 ]; then
# List installed package
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
exit 1
fi
datfile=$pwrp_load/pwr_pkg.dat
{
let printout=0
while read line; do
if [ "$line" = "%Brief:" ]; then
printout=1
else
if [ "$line" = "%Description:" ]; then
break
fi
if [ $printout -eq 1 ]; then
echo $line
fi
fi
done
} < $datfile
else
# Extract datfile from package
for file
do
if [ ! -e $file ]; then
echo "-- No such package"
exit 1
fi
pkg=`eval locate $file`
dir=`eval pwd`
cd /tmp
if ! tar -xzf $pkg pwr_pkg.dat; then
echo "Package $pkg incomplete"
else
datfile=/tmp/pwr_pkg.dat
{
let printout=0
while read line; do
if [ "$line" = "%Brief:" ]; then
printout=1
else
if [ "$line" = "%Description:" ]; then
break
fi
if [ $printout -eq 1 ]; then
echo $line
fi
fi
done
} < $datfile
fi
cd $dir
done
fi
}
pkg_remove_func ()
{
if [ ! -e $pwrp_load/pwr_pkg.dat ]; then
echo "-- No package installed"
return
fi
# Get the name of the current package
{
let found=0
while read line; do
if [ "$line" = "%Package:" ]; then
found=1
else
if [ $found -eq 1 ]; then
pkg=$line
break
fi
fi
done
} < $pwrp_load/pwr_pkg.dat
if [ ! $1 = "force" ]; then
echo ""
echo -n "Do you wan't to remove package $pkg (y/n) [n] "
read remove_pkg
if [ ! "$remove_pkg" = "y" ]; then
return
fi
fi
echo "-- Removing package $pkg"
{
let removefile=0
while read line date time; do
if [ "$line" = "%Files:" ]; then
removefile=1
else
if [ "$line" = "%End:" ]; then
break
fi
if [ $removefile -eq 1 ]; then
file=`eval echo $line`
#echo "rm $file"
rm $file
fi
fi
done
} < $pwrp_load/pwr_pkg.dat
rm $pwrp_load/pwr_pkg.dat
}
force="no"
while getopts ":i:l:b:fra:" opt; do
case $opt in
i ) pkg_install_func $OPTARG ;;
l ) pkg_list_func $OPTARG ;;
a ) pkg_listfiles_func $OPTARG;;
b ) shift
pkg_brief_func $@ ;;
r ) pkg_remove_func $force ;;
f ) force="force" ;;
\? ) echo 'usage: pwr_pkg [-i pkg] [-l] [-b] [-r]'
exit 1
esac
done
! pwrb_c_distribute.wb_load -- Defines the class Distribute.
!
! PROVIEW/R
! Copyright (C) 1996 by Comator Process AB.
!
! <Description>.
!
!/**
! @Version 1.0
! @Group ProjectConfiguration
! @Summary Configures distribution of files.
! The Distribute object configures distribution of files to process and
! operator stations.
!
! The object reside in the project volume beneath a NodeConfig object.
! The specified file will be copied to the node configured by the
! NodeConfig object.
!
! @b See also
! @classlink NodeConfig pwrb_nodeconfig.html
! @classlink ApplDistribute pwrb_appldistribute.html
!*/
SObject pwrb:Class
Object Distribute $ClassDef 321
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_RtAndDevBodies
EndBody
Object DevBody $ObjBodyDef 2
!/**
! @Summary Specification of components included in the distribution.
! Specification of components that are included in the distribution
! package.
!*/
Object Components $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$Mask"
EndBody
EndObject
EndObject
EndObject
EndSObject
......@@ -12,11 +12,30 @@
#include "wb_ldh.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
lfu_eDistrSts_Normal = 0,
lfu_eDistrSts_NoRootVolume = 1 << 0
} lfu_eDistrSts;
typedef enum {
lfu_mDistrComponents_UserDatabase = 1 << 0,
lfu_mDistrComponents_LoadFiles = 1 << 1,
lfu_mDistrComponents_ApplFile = 1 << 2,
lfu_mDistrComponents_PwrpAliasFile = 1 << 3,
lfu_mDistrComponents_IncludeFiles = 1 << 4,
lfu_mDistrComponents_GraphFiles = 1 << 5,
lfu_mDistrComponents_XttHelpFile = 1 << 6,
lfu_mDistrComponents_XttResourceFile = 1 << 7,
lfu_mDistrComponents_XttSetupFile = 1 << 8,
lfu_mDistrComponents_FlowFiles = 1 << 9,
lfu_mDistrComponents_RHostsFile = 1 << 10,
lfu_mDistrComponents_WebFiles = 1 << 11
} lfu_mDistrComponents;
typedef enum {
lfu_eAccessType_StdLgi = 0,
lfu_eAccessType_Proxy = 1,
......@@ -106,4 +125,8 @@ pwr_tStatus lfu_WriteSysObjectFile(
ldh_tSesContext ldhses
);
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
#ifndef wb_pkg_h
#define wb_pkg_h
#include <iostream.h>
#include <vector>
#include <string>
#include "pwr.h"
#include "pwr_class.h"
#include "wb_nav_macros.h"
#include "wb_lfu.h"
class pkg_node;
class pkg_file {
friend class pkg_node;
private:
char m_source[200];
char m_target[200];
char m_arname[80];
pwr_tTime m_date;
public:
pkg_file( char *source, char *target);
char *source() { return m_source;}
char *target() { return m_target;}
pwr_tTime date() { return m_date;}
};
class pkg_pattern {
friend class pkg_node;
private:
char m_source[200];
char m_target[200];
vector<pkg_file> m_filelist;
public:
pkg_pattern( char *source, char *target) {
strcpy( m_source, source);
strcpy( m_target, target);
}
pkg_pattern( char *source) {
strcpy( m_source, source);
strcpy( m_target, "");
}
pkg_pattern( const pkg_pattern& x) : m_filelist(x.m_filelist) {
strcpy( m_source, x.m_source);
strcpy( m_target, x.m_target);
}
char *source() { return m_source;}
char *target() { return m_target;}
bool hasTarget() { return m_target[0] != 0;}
void fetchFiles();
};
class pkg_node {
private:
vector<pkg_pattern> m_pattern;
vector<pkg_file> m_filelist;
char m_name[80];
pwr_mOpSys m_opsys;
int m_bus;
lfu_eDistrSts m_dstatus;
bool m_valid;
public:
pkg_node( char *name): m_opsys(pwr_mOpSys__), m_bus(0),
m_dstatus(lfu_eDistrSts_Normal), m_valid(false) { strcpy( m_name, name);}
pkg_node( char *name, pwr_mOpSys opsys, int bus, lfu_eDistrSts dstatus) :
m_opsys(opsys), m_bus(bus), m_dstatus(dstatus),
m_valid(true) { strcpy( m_name, name); }
char *name() { return m_name;}
pwr_mOpSys opsys() { return m_opsys;}
int bus() { return m_bus;}
lfu_eDistrSts dstatus() { return m_dstatus;}
bool valid() { return m_valid;}
void setOpsys( pwr_mOpSys opsys) { m_opsys = opsys;}
void setBus( int bus) { m_bus = bus;}
void setDStatus( lfu_eDistrSts dstatus) { m_dstatus = dstatus;}
void setValid() { m_valid = true;}
void push_back( pkg_pattern& pattern) {
m_pattern.push_back( pattern);
}
void fetchFiles();
};
class wb_pkg {
private:
vector<pkg_node> m_nodelist;
bool m_allnodes;
void readConfig();
public:
wb_pkg( char *nodelist);
pkg_node& getNode( char *name);
void fetchFiles() {
for ( int i = 0; i < (int)m_nodelist.size(); i++) m_nodelist[i].fetchFiles();
}
};
#endif
......@@ -67,6 +67,7 @@ extern "C" {
#include "wb_erep.h"
#include "wb_vrepwbl.h"
#include "wb_vrepmem.h"
#include "wb_pkg.h"
#define WNAV_MENU_CREATE 0
#define WNAV_MENU_ADD 1
......@@ -150,6 +151,8 @@ static int wnav_generate_func( void *client_data,
void *client_flag);
static int wnav_crossref_func( void *client_data,
void *client_flag);
static int wnav_distribute_func( void *client_data,
void *client_flag);
dcli_tCmdTable wnav_command_table[] = {
{
......@@ -378,6 +381,11 @@ dcli_tCmdTable wnav_command_table[] = {
{ "dcli_arg1", "/NAME", "/FILE", "/STRING", "/BRIEF",
"/FUNCTION", "/CASE_SENSITIVE", ""}
},
{
"DISTRIBUTE",
&wnav_distribute_func,
{ "/NODE", ""}
},
{"",}};
......@@ -4141,6 +4149,33 @@ static int wnav_crossref_func( void *client_data,
return sts;
}
static int wnav_distribute_func( void *client_data,
void *client_flag)
{
WNav *wnav = (WNav *)client_data;
int sts;
char *node_ptr;
char node_str[80];
if ( ODD( dcli_get_qualifier( "/NODE", node_str)))
node_ptr = node_str;
else
node_ptr = NULL;
sts = WNAV__SUCCESS;
try {
wb_pkg *pkg = new wb_pkg( node_ptr);
delete pkg;
}
catch ( wb_error &e) {
wnav->message(' ', (char *)e.what().c_str());
sts = e.sts();
}
if ( EVEN(sts))
return sts;
return 1;
}
int WNav::show_database()
{
int sts;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment