Skip to content

Commit

Permalink
ugh, git cleanup - should be in line with main now
Browse files Browse the repository at this point in the history
  • Loading branch information
bartreardon committed Aug 30, 2023
2 parents 9ebcd3b + 008229a commit ef84e94
Show file tree
Hide file tree
Showing 11 changed files with 309 additions and 66 deletions.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
_A clear and concise description of what the bug is._

**To Reproduce**
_Steps to reproduce the behavior:_

**Expected behavior**
_A clear and concise description of what you expected to happen._

**Screenshots**
_If applicable, add screenshots to help explain your problem._

**System Details:**
- OS:
- Architecture
- Version [e.g. 4.0]

**Additional context**
_Add any other context about the problem here._
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
_A clear and concise description of what the problem is._

**Describe the solution you'd like**
_A clear and concise description of what you want to happen._

**Describe alternatives you've considered**
_A clear and concise description of any alternative solutions or features you've considered._

**Additional context**
_Add any other context or screenshots about the feature request here._
74 changes: 74 additions & 0 deletions .github/workflows/build_outset_release_manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build Outset Release (Manual)

env:
NOTARY_APP_PASSWORD: ${{ secrets.NOTARY_APP_PASSWORD_MAOS }}

on: [workflow_dispatch]

jobs:
build:
runs-on: macos-12

steps:
- name: Checkout outset repo
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
with:
fetch-depth: 0

- name: Install Apple Xcode certificates
uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0
with:
keychain-password: ${{ github.run_id }}
p12-file-base64: ${{ secrets.APP_CERTIFICATES_P12_MAOS }}
p12-password: ${{ secrets.APP_CERTIFICATES_P12_PASSWORD_MAOS }}

- name: Install Apple Installer certificates
uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0
with:
create-keychain: false # do not create a new keychain for this value
keychain-password: ${{ github.run_id }}
p12-file-base64: ${{ secrets.PKG_CERTIFICATES_P12_MAOS }}
p12-password: ${{ secrets.PKG_CERTIFICATES_P12_PASSWORD_MAOS }}

- name: Run build package script
run: ./build_outset.zsh "CREATE_PKG" "$NOTARY_APP_PASSWORD"

- name: get environment variables
id: get_env_var
run: |
echo "OUTSET_VERSION=$(/bin/cat ./build_info.txt)" >> $GITHUB_ENV
echo "OUTSET_MAIN_VERSION=$(/bin/cat ./build_info_main.txt)" >> $GITHUB_ENV
- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@afdcb9470aebdb2252c0c95a1c130723c9e21f3a # v4.1
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
reverse: 'true'

- name: Create Release
id: create_release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
name: Outset ${{env.OUTSET_VERSION}}
tag_name: v${{env.OUTSET_VERSION}}
draft: true
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
body: |
# Notes
This is a version of Outset created by GitHub Actions.
Outset.app has been signed and notarized. The package has been signed, notarized and stapled.
# Changelog
${{ steps.changelog_reader.outputs.changes }}
# Changes
${{ steps.changelog.outputs.changelog }}
files: ${{github.workspace}}/outputs/*.pkg

- name: Upload packages
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: packages
path: outputs/
4 changes: 2 additions & 2 deletions Outset.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0;
MARKETING_VERSION = 4.0.4;
PRODUCT_BUNDLE_IDENTIFIER = io.macadmins.Outset;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -585,7 +585,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 4.0;
MARKETING_VERSION = 4.0.4;
PRODUCT_BUNDLE_IDENTIFIER = io.macadmins.Outset;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
32 changes: 26 additions & 6 deletions Outset/Functions/FileUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ func ensureWorkingFolders() {
}

func migrateLegacyPreferences() {
let newoldRootUserDefaults = "/var/root/Library/Preferences/io.macadmins.Outset.plist"
// shared folder should not contain any executable content, iterate and update as required
if checkFileExists(path: shareDirectory) {
writeLog("\(shareDirectory) exists. Migrating prefrences to user defaults", logLevel: .debug)
if checkFileExists(path: shareDirectory) || checkFileExists(path: newoldRootUserDefaults) {
writeLog("Legacy preferences exist. Migrating to user defaults", logLevel: .debug)

let legacyOutsetPreferencesFile = "\(shareDirectory)com.chilcote.outset.plist"
let legacyRootRunOncePlistFile = "com.github.outset.once.\(getConsoleUserInfo().userID).plist"
Expand All @@ -125,6 +126,7 @@ func migrateLegacyPreferences() {
shareFiles.append(legacyOutsetPreferencesFile)
shareFiles.append(legacyRootRunOncePlistFile)
shareFiles.append(legacyUserRunOncePlistFile)
shareFiles.append(newoldRootUserDefaults)

for filename in shareFiles where checkFileExists(path: filename) {

Expand All @@ -133,7 +135,22 @@ func migrateLegacyPreferences() {
let data = try Data(contentsOf: url)
switch filename {

case newoldRootUserDefaults:
if isRoot() {
writeLog("\(newoldRootUserDefaults) migration", logLevel: .debug)
let legacyDefaultKeys = CFPreferencesCopyKeyList(Bundle.main.bundleIdentifier! as CFString, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
for key in legacyDefaultKeys as! [CFString] {
let keyValue = CFPreferencesCopyValue(key, Bundle.main.bundleIdentifier! as CFString, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
CFPreferencesSetValue(key as CFString,
keyValue as CFPropertyList,
Bundle.main.bundleIdentifier! as CFString,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost)
}
deletePath(newoldRootUserDefaults)
}
case legacyOutsetPreferencesFile:
writeLog("\(legacyOutsetPreferencesFile) migration", logLevel: .debug)
do {
let legacyPreferences = try PropertyListDecoder().decode(OutsetPreferences.self, from: data)
writePreferences(prefs: legacyPreferences)
Expand All @@ -144,6 +161,7 @@ func migrateLegacyPreferences() {
}

case legacyRootRunOncePlistFile, legacyUserRunOncePlistFile:
writeLog("\(legacyRootRunOncePlistFile) and \(legacyUserRunOncePlistFile) migration", logLevel: .debug)
do {
let legacyRunOncePlistData = try PropertyListDecoder().decode([String: Date].self, from: data)
writeRunOnce(runOnceData: legacyRunOncePlistData)
Expand All @@ -166,7 +184,7 @@ func migrateLegacyPreferences() {

}

if folderContents(path: shareDirectory).isEmpty {
if checkFileExists(path: shareDirectory) && folderContents(path: shareDirectory).isEmpty {
deletePath(shareDirectory)
}
}
Expand Down Expand Up @@ -332,14 +350,14 @@ func sha256(for url: URL) -> String? {
}
}

func shaAllFiles() {
// compute sha256sum for all files in the outset directory
func checksumAllFiles() {
// compute checksum (SHA256) for all files in the outset directory
// returns data in two formats to stdout:
// plaintext
// as plist format ready for import into an MDM or converting to a .mobileconfig

let url = URL(fileURLWithPath: outsetDirectory)
writeLog("SHASUM", logLevel: .info)
writeLog("CHECKSUM", logLevel: .info)
var shasumPlist = FileHashes()
if let enumerator = FileManager.default.enumerator(at: url, includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) {
for case let fileURL as URL in enumerator {
Expand Down Expand Up @@ -391,3 +409,5 @@ extension URL {
(try? resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true
}
}

// swiftlint:enable large_tuple line_length force_cast file_length cyclomatic_complexity function_body_length
17 changes: 13 additions & 4 deletions Outset/Functions/Processing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ func processItems(_ path: String, deleteItems: Bool=false, once: Bool=false, ove
var scripts: [String] = [] // array of scripts once they have passed checks
var runOnceDict: [String: Date] = [:]

let shasumFileList = shasumLoadApprovedFileHashList()
let shasumsAvailable = !shasumFileList.isEmpty
let checksumList = checksumLoadApprovedFiles()
let checksumsAvailable = !checksumList.isEmpty

// See if there's any old stuff to migrate
// Perform this each processing run to pick up individual user preferences as well
migrateLegacyPreferences()

// Get a list of all the files to process
Expand All @@ -49,7 +50,7 @@ func processItems(_ path: String, deleteItems: Bool=false, once: Bool=false, ove

// loop through the packages list and process installs.
for package in packages {
if shasumsAvailable && !verifySHASUMForFile(filename: package, shasumArray: shasumFileList) {
if checksumsAvailable && !verifySHASUMForFile(filename: package, shasumArray: checksumList) {
continue
}

Expand Down Expand Up @@ -79,14 +80,16 @@ func processItems(_ path: String, deleteItems: Bool=false, once: Bool=false, ove

// loop through the scripts list and process.
for script in scripts {
if shasumsAvailable && !verifySHASUMForFile(filename: script, shasumArray: shasumFileList) {
if checksumsAvailable && !verifySHASUMForFile(filename: script, shasumArray: checksumList) {
continue
}

if once {
writeLog("Processing run-once \(script)", logLevel: .debug)
// If this is supposed to be a runonce item then we want to check to see if has an existing runonce entry
// looks for a key with the full script path. Writes the full path and run date when done
if !runOnceDict.contains(where: {$0.key == script}) {
writeLog("run-once not yet processed. proceeding", logLevel: .debug)
let (output, error, status) = runShellCommand(script, args: [consoleUser], verbose: true)
if status != 0 {
writeLog(error, logLevel: .error)
Expand All @@ -96,6 +99,7 @@ func processItems(_ path: String, deleteItems: Bool=false, once: Bool=false, ove
}
} else {
// there's a run-once plist entry for this script. Check to see if there's an override
writeLog("checking for override", logLevel: .debug)
if override.contains(where: {$0.key == script}) {
writeLog("override for \(script) dated \(override[script]!)", logLevel: .debug)
if override[script]! > runOnceDict[script]! {
Expand All @@ -110,9 +114,12 @@ func processItems(_ path: String, deleteItems: Bool=false, once: Bool=false, ove
}
}
}
} else {
writeLog("no override for \(script)", logLevel: .debug)
}
}
} else {
writeLog("Processing script \(script)", logLevel: .debug)
let (_, error, status) = runShellCommand(script, args: [consoleUser], verbose: true)
if status != 0 {
writeLog(error, logLevel: .error)
Expand All @@ -128,3 +135,5 @@ func processItems(_ path: String, deleteItems: Bool=false, once: Bool=false, ove
}

}

// swiftlint:enable function_body_length cyclomatic_complexity
2 changes: 2 additions & 0 deletions Outset/Functions/Services.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ class ServiceManager {
status(loginWindowAgent)
}
}

// swiftlint:enable line_length
Loading

0 comments on commit ef84e94

Please sign in to comment.