Skip to content

Commit

Permalink
More fixes to build and setup process
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinTimperio committed Sep 12, 2020
1 parent 222aa06 commit 090205f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 63 deletions.
2 changes: 2 additions & 0 deletions build/BUILDPKG_FULL_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ package() {
cp -dr --no-preserve='ownership' LICENSE "${pkgdir}"/usr/share/licences/pacback
cp -dr --no-preserve='ownership' config "${pkgdir}"/etc/pacback.conf
ln -sf /usr/share/pacback/core/pacback.py "${pkgdir}"/usr/bin/pacback
mkdir -p /var/lib/pacback/restore-points
mkdir -p /var/lib/pacback/snapshots
}
2 changes: 2 additions & 0 deletions build/BUILDPKG_GIT_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ package() {
cp -dr --no-preserve='ownership' pacback/build/config "${pkgdir}"/etc/pacback.conf
cp -dr --no-preserve='ownership' pacback/build/alpha-upgrade.sh "${pkgdir}"/tmp
ln -sf /usr/share/pacback/core/pacback.py "${pkgdir}"/usr/bin/pacback
mkdir -p /var/lib/pacback/restore-points
mkdir -p /var/lib/pacback/snapshots
}
11 changes: 0 additions & 11 deletions build/INSTALL_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@
post_install() {
# Installs Snapshot Hook
pacback -ih

# Create Directories
if [ ! -d '/var/lib/pacback']; then
mkdir '/var/lib/pacback'
fi
if [ ! -d '/var/lib/pacback/snapshots']; then
mkdir '/var/lib/pacback/snapshots'
fi
if [ ! -d '/var/lib/pacback/restore-points']; then
mkdir '/var/lib/pacback/restore-points'
fi
}

post_upgrade() {
Expand Down
52 changes: 27 additions & 25 deletions build/alpha-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,40 @@

base_path='/var/lib/pacback'

# Fix First Line
find $base_path -type f -name '*.meta' -exec sed -i '1 s/^====== Pacback RP.*/======= Pacback Info =======/' {} +
if [ -d '$base_path' ]; then
# Fix First Line
find $base_path -type f -name '*.meta' -exec sed -i '1 s/^====== Pacback RP.*/======= Pacback Info =======/' {} +

# Fix Version Field
find $base_path -type f -name '*.meta' -exec sed -i 's/^Pacback Version:/Version:/' {} +
# Fix Version Field
find $base_path -type f -name '*.meta' -exec sed -i 's/^Pacback Version:/Version:/' {} +

## Removed For Safety During Multiple Runs
## This Value is Not Essential For Runtime
# Add Creation Time
# find $base_path -type f -name '*.meta' -exec sed -i '/^Date Created:.*/a Time Created: 00:00:00' {} +
## Removed For Safety During Multiple Runs
## This Value is Not Essential For Runtime
# Add Creation Time
# find $base_path -type f -name '*.meta' -exec sed -i '/^Date Created:.*/a Time Created: 00:00:00' {} +

# Add Type Fields
find $base_path -type f -name '*.meta' -exec sed -i '/^Time Created:.*/a Type: Restore Point' {} +
find $base_path -type f -name '*.meta' -exec sed -i 's/^Packages in RP: 0/SubType: Light/' {} +
# Add Type Fields
find $base_path -type f -name '*.meta' -exec sed -i '/^Time Created:.*/a Type: Restore Point' {} +
find $base_path -type f -name '*.meta' -exec sed -i 's/^Packages in RP: 0/SubType: Light/' {} +

# Remove Fields If No Packages Are Cached
find $base_path -type f -name '*.meta' -exec sed -i '/^Size of Packages in RP: 0B/d' {} +
# Remove Fields If No Packages Are Cached
find $base_path -type f -name '*.meta' -exec sed -i '/^Size of Packages in RP: 0B/d' {} +


##############################
# Patch Full Restore Points
############################
##############################
# Patch Full Restore Points
############################

# Add SubType Field
find $base_path -type f -name '*.meta' -exec sed -i '/^Packages in RP:.*/i SubType: Full' {} +
# Add SubType Field
find $base_path -type f -name '*.meta' -exec sed -i '/^Packages in RP:.*/i SubType: Full' {} +

# Fix Fields If Package Are Cached
find $base_path -type f -name '*.meta' -exec sed -i 's/^Packages in RP:/Packages Cached:/' {} +
find $base_path -type f -name '*.meta' -exec sed -i 's/^Size of Packages in RP:/Package Cache Size:/' {} +
# Fix Fields If Package Are Cached
find $base_path -type f -name '*.meta' -exec sed -i 's/^Packages in RP:/Packages Cached:/' {} +
find $base_path -type f -name '*.meta' -exec sed -i 's/^Size of Packages in RP:/Package Cache Size:/' {} +

# Fix Custom Dir Fields
find $base_path -type f -name '*.meta' -exec sed -i 's/^Dirs /Dir /' {} +
# Fix Custom Dir Fields
find $base_path -type f -name '*.meta' -exec sed -i 's/^Dirs /Dir /' {} +

# Change Package Cache Folder Name
find $base_path/restore-points -type d -name 'pac_cache' -exec rename 'pac_cache' 'pkg-cache' {} +
# Change Package Cache Folder Name
find $base_path/restore-points -type d -name 'pac_cache' -exec rename 'pac_cache' 'pkg-cache' {} +
fi
1 change: 0 additions & 1 deletion core/pacback.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@

# Safely Init the Environment
session.lock(config)
session.setup(config)
signal.signal(signal.SIGINT, partial(session.sig_catcher, config))

######################
Expand Down
29 changes: 3 additions & 26 deletions core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ def lock(config):
paf.start_log(fname, config['log'])
paf.write_to_log(fname, 'Passed Root Check', config['log'])
paf.write_to_log(fname, 'Started Active Session', config['log'])
if os.path.exists('/etc/pacback.conf') is False:
paf.write_to_log(fname, 'User Config File Is Missing!', config['log'])

except (IOError, OSError):
sys.exit('Critical Error! Pacback Already Has An Active Session Running.')



def unlock(config):
'''
Removes the session lock defined by config['slock'].
Expand Down Expand Up @@ -151,29 +154,3 @@ def load_config():
default.update(user_config)

return default


##################
# Setup Pacback
################

def setup(config):
'''
Check if all the need folders and files are present for a active session
'''
fname = 'session.setup()'
# Init Base Paths if First Run
if os.path.exists(config['basepath']) is False:
paf.mk_dir(config['basepath'], sudo=False)
paf.write_to_log(fname, 'Created Basepath Folder at ' + config['basepath'], config['log'])

if os.path.exists(config['rp_paths']) is False:
paf.mk_dir(config['rp_paths'], sudo=False)
paf.write_to_log(fname, 'Created Restore Point Folder at ' + config['rp_paths'], config['log'])

if os.path.exists(config['ss_paths']) is False:
paf.mk_dir(config['ss_paths'], sudo=False)
paf.write_to_log(fname, 'Created Snapshot Folder at ' + config['ss_paths'], config['log'])

if os.path.exists('/etc/pacback.conf') is False:
paf.write_to_log(fname, 'User Config File Is Missing!', config['log'])

0 comments on commit 090205f

Please sign in to comment.